Răsfoiți Sursa

feat(RichMan): Add legacy mall resource checks and OCR configurations

Migs 10 luni în urmă
părinte
comite
d9c30cfdaa

+ 11 - 0
tasks/RichMan/assets.py

@@ -213,6 +213,17 @@ class RichManAssets:
 	O_MALL_RESOURCE_7 = RuleOcr(roi=(1100,54,150,38), area=(1100,54,150,38), mode="Quantity", method="Default", keyword="", name="mall_resource_7")
 
 
+	# Ocr Rule Assets
+	# 左数第一个(插画屋/寄售屋) 
+	O_LEGACY_MALL_RESOURCE_1 = RuleOcr(roi=(533,9,107,38), area=(533,9,107,38), mode="Quantity", method="Default", keyword="", name="legacy_mall_resource_1")
+	# 左数第二个(插画屋/寄售屋) 
+	O_LEGACY_MALL_RESOURCE_2 = RuleOcr(roi=(739,8,100,39), area=(739,8,100,39), mode="Quantity", method="Default", keyword="", name="legacy_mall_resource_2")
+	# 左数第三个(插画屋/寄售屋) 
+	O_LEGACY_MALL_RESOURCE_3 = RuleOcr(roi=(935,11,100,37), area=(935,11,100,37), mode="Quantity", method="Default", keyword="", name="legacy_mall_resource_3")
+	# 左数第四个(插画屋/寄售屋) 
+	O_LEGACY_MALL_RESOURCE_4 = RuleOcr(roi=(1129,6,100,41), area=(1129,6,100,41), mode="Quantity", method="Default", keyword="", name="legacy_mall_resource_4")
+
+
 	# Click Rule Assets
 	# 一号位 
 	C_SCA_DEMON_1 = RuleClick(roi_front=(255,158,100,100), roi_back=(255,158,100,100), name="sca_demon_1")

+ 2 - 1
tasks/RichMan/mall/consignment.py

@@ -31,7 +31,8 @@ class Consignment(Buy, MallNavbar):
         self.ui_click(self.I_CON_ENTER, self.I_CON_ENTER_CHECK)
         time.sleep(0.5)
         self.screenshot()
-        if not self.mall_check_money(3, 100):
+        #检查勾玉是否足够
+        if not self.mall_check_money_legacy(1, 100):
             logger.warning('Consignment money is not enough')
             return
         remain_number = self.O_CON_NUMBER.ocr(self.device.image)

+ 29 - 0
tasks/RichMan/mall/navbar.py

@@ -118,6 +118,35 @@ class MallNavbar(GameUi, RichManAssets):
 
     def mall_check_money(self, index: int, least: int) -> bool:
         return self.mall_resource(index) >= least
+    
+    #add legacy check money method for compatibility, for consignment task
+    def mall_check_money_legacy(self, index: int, least: int) -> bool:
+        """
+        Legacy implementation.
+        旧版商城资源判断逻辑(包含资源获取 + 校验)用于插画屋和寄售屋任务
+        :param index: 从左开始数 1-4 对应第1-4个资源 least 最少多少
+        :return: bool
+        """
+
+        match = {
+            1: self.O_LEGACY_MALL_RESOURCE_1,
+            2: self.O_LEGACY_MALL_RESOURCE_2,
+            3: self.O_LEGACY_MALL_RESOURCE_3,
+            4: self.O_LEGACY_MALL_RESOURCE_4,
+        }
+
+        self.screenshot()
+        result = match[index].ocr(self.device.image)
+
+        if not isinstance(result, int):
+            logger.warning(f'Get mall resource {index} error, result: {result}')
+            return False
+
+        if result == 0:
+            logger.warning(f'Get mall resource {index} error, result: {result}')
+            return False
+
+        return result >= least
 
 if __name__ == '__main__':
     from module.config.config import Config

+ 38 - 0
tasks/RichMan/mall/navbar/ocr_legacy.json

@@ -0,0 +1,38 @@
+[
+  {
+    "itemName": "legacy_mall_resource_1",
+    "roiFront": "533,9,107,38",
+    "roiBack": "533,9,107,38",
+    "mode": "Quantity",
+    "method": "Default",
+    "keyword": "",
+    "description": "左数第一个(插画屋/寄售屋)"
+  },
+  {
+    "itemName": "legacy_mall_resource_2",
+    "roiFront": "739,8,100,39",
+    "roiBack": "739,8,100,39",
+    "mode": "Quantity",
+    "method": "Default",
+    "keyword": "",
+    "description": "左数第二个(插画屋/寄售屋)"
+  },
+  {
+    "itemName": "legacy_mall_resource_3",
+    "roiFront": "935,11,100,37",
+    "roiBack": "935,11,100,37",
+    "mode": "Quantity",
+    "method": "Default",
+    "keyword": "",
+    "description": "左数第三个(插画屋/寄售屋)"
+  },
+  {
+    "itemName": "legacy_mall_resource_4",
+    "roiFront": "1129,6,100,41",
+    "roiBack": "1129,6,100,41",
+    "mode": "Quantity",
+    "method": "Default",
+    "keyword": "",
+    "description": "左数第四个(插画屋/寄售屋)"
+  }
+]