Răsfoiți Sursa

fix(WantedQuests): streamline exploration version checks and wanted quest detection

ryland 6 luni în urmă
părinte
comite
8dd3b7a41f

+ 5 - 9
tasks/Exploration/base.py

@@ -376,16 +376,15 @@ class BaseExploration(GameUi, GeneralBattle, GeneralRoom, GeneralInvite, Replace
         logger.info('Quit explore')
         logger.info('Quit explore')
         boss_timer = Timer(15)
         boss_timer = Timer(15)
         boss_timer.start()
         boss_timer.start()
-        click_yellow_button = 0 #用于保证只点一次左上返回按钮,不要直接触发连点回到主界面
+        # click_yellow_button = 0 #用于保证只点一次左上返回按钮,不要直接触发连点回到主界面
         
         
         while 1:
         while 1:
             self.screenshot()
             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_RED) and self.appear(self.I_E_EXPLORATION_CLICK):
                 break
                 break
-            
-            #探索大世界界面
+            # 探索大世界界面
             if self.appear(self.I_CHECK_EXPLORATION) and not self.appear(self.I_E_SETTINGS_BUTTON):
             if self.appear(self.I_CHECK_EXPLORATION) and not self.appear(self.I_E_SETTINGS_BUTTON):
                 break
                 break
   
   
@@ -403,11 +402,8 @@ class BaseExploration(GameUi, GeneralBattle, GeneralRoom, GeneralInvite, Replace
 
 
             if self.appear_then_click(self.I_E_EXIT_CONFIRM, interval=0.8):
             if self.appear_then_click(self.I_E_EXIT_CONFIRM, interval=0.8):
                 continue
                 continue
-            
-            if click_yellow_button == 0:
-                if self.appear_then_click(self.I_BACK_YOLLOW, interval=3.5):
-                    click_yellow_button = 1
-                    continue
+            if self.appear_then_click(self.I_BACK_YOLLOW, interval=3.5):
+                continue
             
             
             if self.appear(self.I_EXPLORATION_TITLE) or self.appear(self.I_CHECK_EXPLORATION):
             if self.appear(self.I_EXPLORATION_TITLE) or self.appear(self.I_CHECK_EXPLORATION):
                 continue
                 continue

+ 16 - 14
tasks/Exploration/version.py

@@ -75,21 +75,23 @@ if __name__ == '__main__':
     # image = highlight(image)
     # image = highlight(image)
     # save_image(image, r'C:\Users\萌萌哒\Desktop\1345.png')
     # save_image(image, r'C:\Users\萌萌哒\Desktop\1345.png')
     #
     #
-    IMAGE_FILE = r"C:\Users\萌萌哒\Desktop\QQ20240818-163854.png"
-    image = load_image(IMAGE_FILE)
-    from tasks.Exploration.assets import ExplorationAssets
-    targe = ExplorationAssets.I_UP_COIN
-    print(targe.test_match(image))
-
-    # from dev_tools.get_images import GetAnimation
-    # from module.config.config import Config
-    # from module.device.device import Device
-    # c = Config('oas1')
-    # d = Device(c)
-    # t = HighLight(c, d)
+    # IMAGE_FILE = r"C:\Users\萌萌哒\Desktop\QQ20240818-163854.png"
+    # image = load_image(IMAGE_FILE)
+    # from tasks.Exploration.assets import ExplorationAssets
+    # targe = ExplorationAssets.I_UP_COIN
+    # print(targe.test_match(image))
+
+    from dev_tools.get_images import GetAnimation
+    from module.logger import logger
+    from module.config.config import Config
+    from module.device.device import Device
+    c = Config('oas1')
+    d = Device(c)
+    t = HighLight(c, d)
     # t.screenshot()
     # t.screenshot()
     #
     #
-    # t.screenshot()
-    # t.appear_then_click(t.TEMPLATE_GIF)
+    for i in range(10):
+        t.screenshot()
+        logger.info(t.appear(t.TEMPLATE_GIF))
 
 
 
 

+ 1 - 6
tasks/WantedQuests/assets.py

@@ -147,7 +147,7 @@ class WantedQuestsAssets:
 	# 取消追踪 
 	# 取消追踪 
 	I_TRACE_DISABLE = RuleImage(roi_front=(1091,586,108,70), roi_back=(1091,586,108,70), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_trace_disable.png")
 	I_TRACE_DISABLE = RuleImage(roi_front=(1091,586,108,70), roi_back=(1091,586,108,70), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_trace_disable.png")
 	# 奖励宝箱 
 	# 奖励宝箱 
-	I_WQ_BOX = RuleImage(roi_front=(48,187,43,38), roi_back=(20,137,100,397), threshold=0.7, method="Template matching", file="./tasks/WantedQuests/wq/wq_wq_box.png")
+	I_WQ_BOX = RuleImage(roi_front=(48,187,43,38), roi_back=(12,78,108,496), threshold=0.7, method="Template matching", file="./tasks/WantedQuests/wq/wq_wq_box.png")
 	# 小号追踪 
 	# 小号追踪 
 	I_TRACE_TRUE = RuleImage(roi_front=(173,187,28,29), roi_back=(173,187,28,29), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_trace_true.png")
 	I_TRACE_TRUE = RuleImage(roi_front=(173,187,28,29), roi_back=(173,187,28,29), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_trace_true.png")
 	# 小号不追踪 
 	# 小号不追踪 
@@ -172,11 +172,6 @@ class WantedQuestsAssets:
 	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_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")
 
 
 
 
-	# 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
 	# Image Rule Assets
 	# 奇怪了之前的不能用 
 	# 奇怪了之前的不能用 
 	I_WQSE_FIRE = RuleImage(roi_front=(1041,556,100,100), roi_back=(1016,534,147,138), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_wqse_fire.png")
 	I_WQSE_FIRE = RuleImage(roi_front=(1041,556,100,100), roi_back=(1016,534,147,138), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_wqse_fire.png")

+ 8 - 8
tasks/WantedQuests/explore.py

@@ -26,6 +26,7 @@ class WQExplore(BaseExploration, HighLight):
         explore_only_boss: bool = True
         explore_only_boss: bool = True
         _cnt_exploration = 0
         _cnt_exploration = 0
         search_fail_cnt = 0
         search_fail_cnt = 0
+        search_fail_timer = Timer(3.2)  # 这里设置的时间一定要大于S_SWIPE_BACKGROUND_RIGHT滑动的时间
         while 1:
         while 1:
             self.screenshot()
             self.screenshot()
             if self.appear(self.I_UI_BACK_YELLOW) and self.appear(self.I_E_EXPLORATION_CLICK):
             if self.appear(self.I_UI_BACK_YELLOW) and self.appear(self.I_E_EXPLORATION_CLICK):
@@ -39,11 +40,11 @@ class WQExplore(BaseExploration, HighLight):
             if scene == Scene.ENTRANCE:
             if scene == Scene.ENTRANCE:
                 if _cnt_exploration >= num:
                 if _cnt_exploration >= num:
                     logger.info('Execution exploration end')
                     logger.info('Execution exploration end')
-                    self.ui_click_until_disappear(self.I_UI_BACK_YELLOW)
+                    # --退出到探索大世界--
+                    self.ui_click(self.I_UI_BACK_YELLOW, stop=self.I_CHECK_EXPLORATION, interval=4)
                     if explore_only_boss:
                     if explore_only_boss:
                         raise ExploreWantedBoss
                         raise ExploreWantedBoss
                     break
                     break
-                logger.info("点击探索")
                 self.ui_click(self.I_E_EXPLORATION_CLICK, stop=self.I_E_SETTINGS_BUTTON)
                 self.ui_click(self.I_E_EXPLORATION_CLICK, stop=self.I_E_SETTINGS_BUTTON)
                 continue
                 continue
             # 探索大世界
             # 探索大世界
@@ -87,17 +88,16 @@ class WQExplore(BaseExploration, HighLight):
                     logger.info(f'Fight, minions cnt {self.minions_cnt}')
                     logger.info(f'Fight, minions cnt {self.minions_cnt}')
                     continue
                     continue
                 # 向后拉,寻找怪
                 # 向后拉,寻找怪
-                if search_fail_cnt >= 4:
-                    search_fail_cnt = 0
-                    if self._match_end.stable(self.device.image):
+                if search_fail_timer.reached():
+                    if self._match_end.stable(self.device.image, refresh_after_stable=True):
                         _cnt_exploration += 1
                         _cnt_exploration += 1
                         self.quit_explore()
                         self.quit_explore()
                         continue
                         continue
                     if self.swipe(self.S_SWIPE_BACKGROUND_RIGHT, interval=3):
                     if self.swipe(self.S_SWIPE_BACKGROUND_RIGHT, interval=3):
                         continue
                         continue
-                else:
-                    search_fail_cnt += 1
-            elif scene==Scene.BATTLE_PREPARE:
+                if not search_fail_timer.started():
+                    search_fail_timer.start()
+            elif scene == Scene.BATTLE_PREPARE:
                 self.ui_click_until_disappear(self.I_PREPARE_HIGHLIGHT, interval=0.5)
                 self.ui_click_until_disappear(self.I_PREPARE_HIGHLIGHT, interval=0.5)
             elif scene == Scene.UNKNOWN:
             elif scene == Scene.UNKNOWN:
                 continue
                 continue

+ 1 - 0
tasks/WantedQuests/script_task.py

@@ -449,6 +449,7 @@ class ScriptTask(WQExplore, SecretScriptTask, WantedQuestsAssets):
         while 1:
         while 1:
             self.screenshot()
             self.screenshot()
             if self.appear(self.I_CHECK_EXPLORATION):
             if self.appear(self.I_CHECK_EXPLORATION):
+                self.wait_until_stable(self.I_CHECK_EXPLORATION)
                 break
                 break
             if self.appear_then_click(self.I_UI_BACK_RED, interval=1):
             if self.appear_then_click(self.I_UI_BACK_RED, interval=1):
                 continue
                 continue

+ 1 - 1
tasks/WantedQuests/wq/image.json

@@ -39,7 +39,7 @@
     "itemName": "wq_box",
     "itemName": "wq_box",
     "imageName": "wq_wq_box.png",
     "imageName": "wq_wq_box.png",
     "roiFront": "48,187,43,38",
     "roiFront": "48,187,43,38",
-    "roiBack": "20,137,100,397",
+    "roiBack": "12,78,108,496",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.7,
     "threshold": 0.7,
     "description": "奖励宝箱"
     "description": "奖励宝箱"