浏览代码

fix(WantedQuests): 修复OCR识别\"式神\"与用户配置\"挑战\"不匹配的问题

- OCR识别文本可能返回\"式神\"而非\"挑战\",对此添加类型映射处理
- 更新探索界面返回按钮检测,从红色按钮切换至黄色按钮(I_UI_BACK_RED → I_UI_BACK_YELLOW)
- 调整多项ROI坐标以适配当前游戏画面布局(challenge/image.json, ocr.json, page_img.json)
- 更新模板匹配图像资源(challenge unlock/lock, page_check_exploration)
- 移除不再使用的wq_list_top_bottom_check图像及配置项
yuyuyuyuyu 6 月之前
父节点
当前提交
7ee5797c77

+ 1 - 1
tasks/GameUi/assets.py

@@ -44,7 +44,7 @@ class GameUiAssets:
 	# description 
 	I_MAIN_GOTO_EXPLORATION = RuleImage(roi_front=(493,116,45,75), roi_back=(243,100,933,211), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_main_goto_exploration.png")
 	# description 
-	I_CHECK_EXPLORATION = RuleImage(roi_front=(1103,675,23,20), roi_back=(1063,643,91,76), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_check_exploration.png")
+	I_CHECK_EXPLORATION = RuleImage(roi_front=(681,12,27,36), roi_back=(661,0,70,61), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_check_exploration.png")
 	# 探索前往觉醒 
 	I_EXPLORATION_GOTO_AWAKE_ZONE = RuleImage(roi_front=(65,632,50,41), roi_back=(33,619,1125,98), threshold=0.65, method="Template matching", file="./tasks/GameUi/page/page_exploration_goto_awake_zone.png")
 	# 探索前往御魂 

二进制
tasks/GameUi/page/page_check_exploration.png


+ 2 - 2
tasks/GameUi/page/page_img.json

@@ -29,8 +29,8 @@
   {
     "itemName": "check_exploration",
     "imageName": "page_check_exploration.png",
-    "roiFront": "1103,675,23,20",
-    "roiBack": "1063,643,91,76",
+    "roiFront": "681,12,27,36",
+    "roiBack": "661,0,70,61",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"

+ 10 - 7
tasks/WantedQuests/assets.py

@@ -23,7 +23,7 @@ class WantedQuestsAssets:
 	# 挑战券的数量 
 	O_WQ_NUMBER = RuleOcr(roi=(569,13,50,32), area=(569,13,50,32), mode="Digit", method="Default", keyword="", name="wq_number")
 	# 悬赏封印 
-	O_WQ_WANTED = RuleOcr(roi=(9,145,123,381), area=(9,145,123,381), mode="Full", method="Default", keyword="", name="wq_wanted")
+	O_WQ_WANTED = RuleOcr(roi=(15,116,85,401), area=(15,116,85,401), mode="Full", method="Default", keyword="", name="wq_wanted")
 	# Ocr-description 
 	O_WQ_TEXT_1 = RuleOcr(roi=(67,233,52,32), area=(67,233,52,32), mode="Single", method="Default", keyword="封印", name="wq_text_1")
 	# Ocr-description 
@@ -55,16 +55,16 @@ class WantedQuestsAssets:
 	# 怪物名称,如酒吞,阎魔等 
 	O_WQ_MONSTER_TYPE = RuleOcr(roi=(165,215,45,175), area=(165,215,45,175), mode="Full", method="Default", keyword="", name="wq_monster_type")
 	#  
-	O_WQ_TEXT_ALL = RuleOcr(roi=(20,140,110,390), area=(20,140,110,390), mode="Full", method="Default", keyword="", name="wq_text_all")
+	O_WQ_TEXT_ALL = RuleOcr(roi=(12,119,88,393), area=(12,119,88,393), mode="Full", method="Default", keyword="", name="wq_text_all")
 
 
 	# Image Rule Assets
 	# description 
-	I_WQC_LOCK = RuleImage(roi_front=(620,528,27,31), roi_back=(620,528,27,31), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/chanllenge/chanllenge_wqc_lock.png")
+	I_WQC_LOCK = RuleImage(roi_front=(1083,509,27,31), roi_back=(1083,509,27,31), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/chanllenge/chanllenge_wqc_lock.png")
 	# description 
-	I_WQC_UNLOCK = RuleImage(roi_front=(621,527,26,28), roi_back=(621,527,26,28), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/chanllenge/chanllenge_wqc_unlock.png")
+	I_WQC_UNLOCK = RuleImage(roi_front=(1083,510,26,28), roi_back=(1083,510,26,28), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/chanllenge/chanllenge_wqc_unlock.png")
 	# 挑战 
-	I_WQC_FIRE = RuleImage(roi_front=(893,503,123,64), roi_back=(871,485,164,91), threshold=0.7, method="Template matching", file="./tasks/WantedQuests/chanllenge/chanllenge_wqc_fire.png")
+	I_WQC_FIRE = RuleImage(roi_front=(1082,587,97,44), roi_back=(1049,551,169,139), threshold=0.7, method="Template matching", file="./tasks/WantedQuests/chanllenge/chanllenge_wqc_fire.png")
 
 
 	# Image Rule Assets
@@ -170,8 +170,11 @@ class WantedQuestsAssets:
 	I_WQ_TRACE_ONE_CHECK_OPENED = RuleImage(roi_front=(510,175,210,60), roi_back=(510,175,210,60), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_trace_one_check_opened.png")
 	# 庭院悬赏任务界面 单个任务点开后的界面 是否为现世任务标志 
 	I_WQ_TRACE_ONE_REALWORLD = RuleImage(roi_front=(850,470,180,180), roi_back=(850,470,180,180), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_trace_one_realworld.png")
-	# 探索界面,左侧任务列表右上角右下角标志 
-	I_WQ_LIST_TOP_BOTTOM_CHECK = RuleImage(roi_front=(120,125,25,425), roi_back=(120,125,25,425), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_list_top_bottom_check.png")
+
+
+	# Ocr Rule Assets
+	# 检测是否有悬赏封印 
+	O_WQ_LIST_CHECK = RuleOcr(roi=(15,116,85,397), area=(15,116,85,397), mode="Full", method="Default", keyword="封印", name="wq_list_check")
 
 
 	# Image Rule Assets

二进制
tasks/WantedQuests/chanllenge/chanllenge_wqc_fire.png


二进制
tasks/WantedQuests/chanllenge/chanllenge_wqc_lock.png


二进制
tasks/WantedQuests/chanllenge/chanllenge_wqc_unlock.png


+ 6 - 6
tasks/WantedQuests/chanllenge/image.json

@@ -2,8 +2,8 @@
   {
     "itemName": "wqc_lock",
     "imageName": "chanllenge_wqc_lock.png",
-    "roiFront": "620,528,27,31",
-    "roiBack": "620,528,27,31",
+    "roiFront": "1083,509,27,31",
+    "roiBack": "1083,509,27,31",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"
@@ -11,8 +11,8 @@
   {
     "itemName": "wqc_unlock",
     "imageName": "chanllenge_wqc_unlock.png",
-    "roiFront": "621,527,26,28",
-    "roiBack": "621,527,26,28",
+    "roiFront": "1083,510,26,28",
+    "roiBack": "1083,510,26,28",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"
@@ -20,8 +20,8 @@
   {
     "itemName": "wqc_fire",
     "imageName": "chanllenge_wqc_fire.png",
-    "roiFront": "893,503,123,64",
-    "roiBack": "871,485,164,91",
+    "roiFront": "1082,587,97,44",
+    "roiBack": "1049,551,169,139",
     "method": "Template matching",
     "threshold": 0.7,
     "description": "挑战"

+ 2 - 2
tasks/WantedQuests/explore.py

@@ -28,7 +28,7 @@ class WQExplore(BaseExploration, HighLight):
         search_fail_cnt = 0
         while 1:
             self.screenshot()
-            if self.appear(self.I_UI_BACK_RED) and self.appear(self.I_E_EXPLORATION_CLICK):
+            if self.appear(self.I_UI_BACK_YELLOW) and self.appear(self.I_E_EXPLORATION_CLICK):
                 break
             if self.appear_then_click(goto, interval=2):
                 continue
@@ -39,7 +39,7 @@ class WQExplore(BaseExploration, HighLight):
             if scene == Scene.ENTRANCE:
                 if _cnt_exploration >= num:
                     logger.info('Execution exploration end')
-                    self.ui_click_until_disappear(self.I_UI_BACK_RED)
+                    self.ui_click_until_disappear(self.I_UI_BACK_YELLOW)
                     if explore_only_boss:
                         raise ExploreWantedBoss
                     break

+ 4 - 4
tasks/WantedQuests/ocr.json

@@ -10,8 +10,8 @@
   },
   {
     "itemName": "wq_wanted",
-    "roiFront": "9,145,123,381",
-    "roiBack": "9,145,123,381",
+    "roiFront": "15,116,85,401",
+    "roiBack": "15,116,85,401",
     "mode": "Full",
     "method": "Default",
     "keyword": "",
@@ -154,8 +154,8 @@
   },
   {
     "itemName": "wq_text_all",
-    "roiFront": "20,140,110,390",
-    "roiBack": "20,140,110,390",
+    "roiFront": "12,119,88,393",
+    "roiBack": "12,119,88,393",
     "mode": "Full",
     "method": "Default",
     "keyword": "",

+ 13 - 6
tasks/WantedQuests/script_task.py

@@ -311,7 +311,7 @@ class ScriptTask(WQExplore, SecretScriptTask, WantedQuestsAssets):
         OCR_WQ_INFO = [self.O_WQ_INFO_1, self.O_WQ_INFO_2, self.O_WQ_INFO_3, self.O_WQ_INFO_4]
         GOTO_BUTTON = [self.I_GOTO_1, self.I_GOTO_2, self.I_GOTO_3, self.I_GOTO_4]
         name_funcs: dict = {
-            '挑战': self.challenge,
+            '式神': self.challenge,
             '探索': self.explore,
             '秘闻': self.secret
         }
@@ -357,7 +357,9 @@ class ScriptTask(WQExplore, SecretScriptTask, WantedQuestsAssets):
             order_list = self.config.model.wanted_quests.wanted_quests_config.battle_priority
             order_list = order_list.replace(' ', '').replace('\n', '')
             order_list: list = re.split(r'>', order_list)
-            result[0] = order_list.index(type_wq) if type_wq in order_list else -1
+            # OCR识别"式神"但用户配置用"挑战",做映射
+            type_wq_for_order = '挑战' if type_wq == '式神' else type_wq
+            result[0] = order_list.index(type_wq_for_order) if type_wq_for_order in order_list else -1
             result[4] = name_funcs.get(type_wq, lambda: logger.warning('No task can be challenged'))
             result[5] = type_wq
             logger.info(f'[Wanted Quests] type: {type_wq} destination: {wq_destination} number: {wq_number} ')
@@ -395,7 +397,7 @@ class ScriptTask(WQExplore, SecretScriptTask, WantedQuestsAssets):
             return False
         # sort
         info_wq_list.sort(key=lambda x: x[0])
-        filtered = list(filter(lambda x: (x[5] == '秘闻' or x[5] == '挑战') and x[2] >= 3, info_wq_list))
+        filtered = list(filter(lambda x: (x[5] == '秘闻' or x[5] == '式神') and x[2] >= 3, info_wq_list))
         if not filtered and len(filtered) != 0:
             info_wq_list = filtered
         best_type, destination, once_number, goto_button, func, _ = info_wq_list[0]
@@ -414,8 +416,13 @@ class ScriptTask(WQExplore, SecretScriptTask, WantedQuestsAssets):
         wq_config = GeneralBattleConfig(lock_team_enable=True)
         self.run_general_battle(config=wq_config)
         self.wait_until_appear(self.I_WQC_FIRE, wait_time=4)
-        self.ui_click_until_disappear(self.I_UI_BACK_RED)
-        # 我忘记了打完后是否需要关闭 挑战界面
+        # 关闭 挑战界面
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_CHECK_EXPLORATION):
+                break
+            if self.appear_then_click(self.I_UI_BACK_YELLOW, interval=1.5):
+                continue
 
     def secret(self, goto, num=1):
         self.ui_click(goto, self.I_WQSE_FIRE)
@@ -750,7 +757,7 @@ class ScriptTask(WQExplore, SecretScriptTask, WantedQuestsAssets):
 
     def is_wq_remained(self):
         # 检测是否还存在任务
-        return self.appear(self.I_WQ_LIST_TOP_BOTTOM_CHECK)
+        return self.appear(self.O_WQ_WANTED)
 
 
 

+ 0 - 9
tasks/WantedQuests/wq/image.json

@@ -142,14 +142,5 @@
     "method": "Template matching",
     "threshold": 0.8,
     "description": "庭院悬赏任务界面 单个任务点开后的界面 是否为现世任务标志"
-  },
-  {
-    "itemName": "wq_list_top_bottom_check",
-    "imageName": "wq_list_top_bottom_check.png",
-    "roiFront": "120,125,25,425",
-    "roiBack": "120,125,25,425",
-    "method": "Template matching",
-    "threshold": 0.8,
-    "description": "探索界面,左侧任务列表右上角右下角标志"
   }
 ]

二进制
tasks/WantedQuests/wq/wq_list_top_bottom_check.png