Просмотр исходного кода

fix(Exploration): #829 Refresh the record image to prevent repeated triggering of matching

huangrunheng 1 год назад
Родитель
Сommit
cc0c0bf511
2 измененных файлов с 13 добавлено и 3 удалено
  1. 7 1
      module/atom/animate.py
  2. 6 2
      tasks/Exploration/solo.py

+ 7 - 1
module/atom/animate.py

@@ -47,10 +47,11 @@ class RuleAnimate(RuleImage):
     def name(self) -> str:
         return self._name.upper()
 
-    def stable(self, image) -> bool:
+    def stable(self, image, refresh_when_stable: bool = False) -> bool:
         """
         用于判断连续的两张截图,的目标区域是否一致
         @param image:
+        @param refresh_when_stable:
         @return:
         """
         if self._last_image is None:
@@ -62,10 +63,15 @@ class RuleAnimate(RuleImage):
         self._last_image = self.corp(image, self.roi_front)
 
         if matched:
+            if refresh_when_stable:
+                self.refresh()
             logger.info(f'Animation Stable @ {self.name}')
             return True
         return False
 
+    def refresh(self):
+        self._last_image = None
+
 
 if __name__ == '__main__':
     from module.base.utils import load_image

+ 6 - 2
tasks/Exploration/solo.py

@@ -80,7 +80,9 @@ class SoloExploration(BaseExploration):
                 # 向后拉,寻找怪
                 if search_fail_cnt >= 4:
                     search_fail_cnt = 0
-                    if (self._config.exploration_config.exploration_level == ExplorationLevel.EXPLORATION_28 and self.appear(self.I_SWIPE_END)) or self._match_end.stable(self.device.image):
+                    if (self._config.exploration_config.exploration_level == ExplorationLevel.EXPLORATION_28\
+                        and self.appear(self.I_SWIPE_END))\
+                            or self._match_end.stable(self.device.image, refresh_when_stable=True):
                         self.quit_explore()
                         continue
                     if self.swipe(self.S_SWIPE_BACKGROUND_RIGHT, interval=3):
@@ -210,7 +212,9 @@ class SoloExploration(BaseExploration):
                 # 向后拉,寻找怪
                 if search_fail_cnt >= 4:
                     search_fail_cnt = 0
-                    if (self._config.exploration_config.exploration_level == ExplorationLevel.EXPLORATION_28 and self.appear(self.I_SWIPE_END)) or self._match_end.stable(self.device.image):
+                    if (self._config.exploration_config.exploration_level == ExplorationLevel.EXPLORATION_28\
+                        and self.appear(self.I_SWIPE_END))\
+                            or self._match_end.stable(self.device.image, refresh_when_stable=True):
                         self.quit_explore()
                         continue
                     if self.swipe(self.S_SWIPE_BACKGROUND_RIGHT, interval=4.5):