Răsfoiți Sursa

fix: 修改探索滑动到底退出逻辑

doge 3 luni în urmă
părinte
comite
bae6b3aa74

+ 1 - 1
tasks/Exploration/assets.py

@@ -112,7 +112,7 @@ class ExplorationAssets:
 	# 宝箱 
 	I_TREASURE_BOX_CLICK = RuleImage(roi_front=(31,543,27,24), roi_back=(11,520,378,65), threshold=0.65, method="Template matching", file="./tasks/Exploration/res/res_treasure_box_click.png")
 	# 困28滚动到最后 
-	I_SWIPE_END = RuleImage(roi_front=(994,234,119,100), roi_back=(968,196,311,165), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_swipe_end.png")
+	I_SWIPE_END = RuleImage(roi_front=(1213,79,66,265), roi_back=(1213,79,66,265), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_swipe_end.png")
 	# 队伍的表情标志 
 	I_TEAM_EMOJI = RuleImage(roi_front=(36,437,44,46), roi_back=(4,407,100,100), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_team_emoji.png")
 	# 组队按钮 

+ 2 - 2
tasks/Exploration/res/image.json

@@ -182,8 +182,8 @@
   {
     "itemName": "swipe_end",
     "imageName": "res_swipe_end.png",
-    "roiFront": "994,234,119,100",
-    "roiBack": "968,196,311,165",
+    "roiFront": "1213,79,66,265",
+    "roiBack": "1213,79,66,265",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "困28滚动到最后"

BIN
tasks/Exploration/res/res_exp_leader.png


BIN
tasks/Exploration/res/res_swipe_end.png


+ 24 - 88
tasks/Exploration/solo.py

@@ -9,7 +9,7 @@ from module.base.timer import Timer
 
 from tasks.Component.GeneralInvite.config_invite import InviteConfig, InviteNumber, FindMode
 from tasks.Exploration.base import BaseExploration, UpType, Scene
-from tasks.Exploration.config import ChooseRarity, AutoRotate, UserStatus, ExplorationLevel
+from tasks.Exploration.config import ChooseRarity, AutoRotate, UserStatus
 
 
 class SoloExploration(BaseExploration):
@@ -30,18 +30,12 @@ class SoloExploration(BaseExploration):
             default_invite=False
         )
 
-    def _handle_treasure_box(self, roi_back=None) -> bool:
-        original_roi_back = self.I_TREASURE_BOX_CLICK.roi_back
-        if roi_back is not None:
-            self.I_TREASURE_BOX_CLICK.roi_back = roi_back
-        try:
-            if self.appear(self.I_TREASURE_BOX_CLICK):
-                logger.info('Treasure box appear, get it.')
-                self.ui_click_until_disappear(self.I_TREASURE_BOX_CLICK)
-                return True
-            return False
-        finally:
-            self.I_TREASURE_BOX_CLICK.roi_back = original_roi_back
+    def _handle_treasure_box(self) -> bool:
+        if self.appear(self.I_TREASURE_BOX_CLICK):
+            logger.info('Treasure box appear, get it.')
+            self.ui_click_until_disappear(self.I_TREASURE_BOX_CLICK)
+            return True
+        return False
 
     def _check_mate_leave(self, friend_leave_timer: Timer):
         if not self.appear(self.I_TEAM_EMOJI) and not self.appear(self.I_TEAM_EMOJI_FIGHT):
@@ -62,26 +56,9 @@ class SoloExploration(BaseExploration):
             friend_leave_timer = Timer(self.FRIEND_LEAVE_TIMEOUT)
         return friend_leave_timer, False
 
-    # TODO: BaseTask.swipe() 无返回值,避免扩大影响面新起临时函数
-    # 后续 swipe 加返回值后弃用
-    def _swipe_background_right(self, interval: float) -> bool:
-        swipe = self.S_SWIPE_BACKGROUND_RIGHT
-        if swipe.name in self.interval_timer:
-            if self.interval_timer[swipe.name].limit != interval:
-                self.interval_timer[swipe.name] = Timer(interval)
-        else:
-            self.interval_timer[swipe.name] = Timer(interval)
-        if not self.interval_timer[swipe.name].reached():
-            return False
-
-        self.swipe(swipe)
-        self.interval_timer[swipe.name].reset()
-        return True
-
     def run_solo(self):
         logger.hr('solo')
-        search_fail_cnt = 0
-        swipe_unchanged_cnt = 0
+        search_fail_timer = Timer(3.2)  # 这里设置的时间一定要大于S_SWIPE_BACKGROUND_RIGHT滑动的时间
 
         while 1:
             self.screenshot()
@@ -89,21 +66,15 @@ class SoloExploration(BaseExploration):
             logger.info(f'[run_solo] Current scene: {scene.name}')  # TODO 2026.06.22 之后删掉这个刷屏的
             #
             if scene == Scene.WORLD:
-                swipe_unchanged_cnt = 0
                 # 打开右边箭头
                 if not self.wait_world_stable():
                     continue
-                # if self.appear(self.I_TREASURE_BOX_CLICK):
-                #     # 宝箱
-                #     logger.info('Treasure box appear, get it.')
-                #     self.ui_click_until_disappear(self.I_TREASURE_BOX_CLICK)
                 if self.check_exit():
                     break
                 self.open_expect_level()
                 continue
             #
             elif scene == Scene.ENTRANCE:
-                swipe_unchanged_cnt = 0
                 if self.check_exit():
                     break
                 self.ui_click(self.I_E_EXPLORATION_CLICK, stop=self.I_E_SETTINGS_BUTTON)
@@ -125,40 +96,24 @@ class SoloExploration(BaseExploration):
                 # boss
                 if self.appear(self.I_BOSS_BATTLE_BUTTON):
                     if self.fire(self.I_BOSS_BATTLE_BUTTON):
-                        swipe_unchanged_cnt = 0
                         logger.info(f'Boss battle, minions cnt {self.minions_cnt}')
                     continue
                 # 小怪
                 fight_button = self.search_up_fight()
                 if fight_button is not None:
                     if self.fire(fight_button):
-                        swipe_unchanged_cnt = 0
                         logger.info(f'Fight, minions cnt {self.minions_cnt}')
                     continue
                 # 向后拉,寻找怪
-                if search_fail_cnt >= 4:
-                    search_fail_cnt = 0
-                    # I_SWIPE_END 是第 28 章的末尾标识,其他章节不要用它判断退出。
-                    if (
-                            self._config.exploration_config.exploration_level == ExplorationLevel.EXPLORATION_28
-                            and self.appear(self.I_SWIPE_END)
-                    ):
+                if search_fail_timer.reached():
+                    search_fail_timer.reset()
+                    if self._match_end.stable(self.device.image, refresh_after_stable=True):
                         self.quit_explore()
                         continue
-                    before_image = self.device.image.copy()
-                    if self._swipe_background_right(interval=3):
-                        self.screenshot()
-                        # 单次画面没变化可能是偶发,连续两次滑不动才认为到尽头。
-                        if self.is_swipe_unchanged(before_image, self.device.image):
-                            swipe_unchanged_cnt += 1
-                        else:
-                            swipe_unchanged_cnt = 0
-                        if swipe_unchanged_cnt >= 2:
-                            logger.info('Swipe unchanged twice, quit exploration')
-                            self.quit_explore()
-                        continue
-                else:
-                    search_fail_cnt += 1
+                    self.swipe(self.S_SWIPE_BACKGROUND_RIGHT, interval=3)
+                    continue
+                if not search_fail_timer.started():
+                    search_fail_timer.start()
             #
             elif scene == Scene.BATTLE_PREPARE or scene == Scene.BATTLE_FIGHTING:
                 self.check_take_over_battle(is_screenshot=False, config=self._config.general_battle_config)
@@ -167,8 +122,7 @@ class SoloExploration(BaseExploration):
 
     def run_leader(self):
         logger.hr('leader')
-        search_fail_cnt = 0
-        swipe_unchanged_cnt = 0
+        search_fail_timer = Timer(3.2)  # 这里设置的时间一定要大于S_SWIPE_BACKGROUND_RIGHT滑动的时间
         friend_leave_timer = Timer(self.FRIEND_LEAVE_TIMEOUT)
 
         while 1:
@@ -177,7 +131,6 @@ class SoloExploration(BaseExploration):
             logger.info(f'[run_leader] Current scene: {scene.name}')  # TODO 2026.06.22 之后删掉这个刷屏的
             # 探索大世界
             if scene == Scene.WORLD:
-                swipe_unchanged_cnt = 0
                 # 打开右边箭头
                 if not self.wait_world_stable():
                     continue
@@ -196,7 +149,6 @@ class SoloExploration(BaseExploration):
 
             # 邀请好友, 非常有可能是后面邀请好友,然后直接跳到组队了
             elif scene == Scene.ENTRANCE:
-                swipe_unchanged_cnt = 0
                 while 1:
                     self.screenshot()
                     if self.is_in_room():
@@ -256,40 +208,24 @@ class SoloExploration(BaseExploration):
                 # boss
                 if self.appear(self.I_BOSS_BATTLE_BUTTON):
                     if self.fire(self.I_BOSS_BATTLE_BUTTON):
-                        swipe_unchanged_cnt = 0
                         logger.info(f'Boss battle, minions cnt {self.minions_cnt}')
                     continue
                 # 小怪
                 fight_button = self.search_up_fight()
                 if fight_button is not None:
                     if self.fire(fight_button):
-                        swipe_unchanged_cnt = 0
                         logger.info(f'Fight, minions cnt {self.minions_cnt}')
                     continue
                 # 向后拉,寻找怪
-                if search_fail_cnt >= 4:
-                    search_fail_cnt = 0
-                    # I_SWIPE_END 是第 28 章的末尾标识,其他章节不要用它判断退出。
-                    if (
-                            self._config.exploration_config.exploration_level == ExplorationLevel.EXPLORATION_28
-                            and self.appear(self.I_SWIPE_END)
-                    ):
+                if search_fail_timer.reached():
+                    search_fail_timer.reset()
+                    if self._match_end.stable(self.device.image, refresh_after_stable=True):
                         self.quit_explore()
                         continue
-                    before_image = self.device.image.copy()
-                    if self._swipe_background_right(interval=3):
-                        self.screenshot()
-                        # 单次画面没变化可能是偶发,连续两次滑不动才认为到尽头。
-                        if self.is_swipe_unchanged(before_image, self.device.image):
-                            swipe_unchanged_cnt += 1
-                        else:
-                            swipe_unchanged_cnt = 0
-                        if swipe_unchanged_cnt >= 2:
-                            logger.info('Swipe unchanged twice, quit exploration')
-                            self.quit_explore()
-                        continue
-                else:
-                    search_fail_cnt += 1
+                    self.swipe(self.S_SWIPE_BACKGROUND_RIGHT, interval=3)
+                    continue
+                if not search_fail_timer.started():
+                    search_fail_timer.start()
             #
             elif scene == Scene.BATTLE_PREPARE or scene == Scene.BATTLE_FIGHTING:
                 self.check_take_over_battle(is_screenshot=False, config=self._config.general_battle_config)
@@ -314,7 +250,7 @@ class SoloExploration(BaseExploration):
                     break
                 if self.check_then_accept():
                     # 接受邀请后清掉计时器
-                    wait_timer = Timer(50)
+                    wait_timer.reset()
                     continue
                 if wait_timer.started() and wait_timer.reached():
                     logger.warning('Wait timer reached')