Prechádzať zdrojové kódy

fix(Exploration): Add wait_world_stable to recover from stuck chapter entry screen #1588

ryland 5 mesiacov pred
rodič
commit
e3be60cdd9
2 zmenil súbory, kde vykonal 22 pridanie a 14 odobranie
  1. 18 3
      tasks/Exploration/base.py
  2. 4 11
      tasks/Exploration/solo.py

+ 18 - 3
tasks/Exploration/base.py

@@ -422,6 +422,22 @@ class BaseExploration(GameUi, GeneralBattle, GeneralRoom, GeneralInvite, Replace
         self.minions_cnt += 1
         return True
 
+    def wait_world_stable(self) -> bool:
+        """
+        # 打开右边箭头 and https://github.com/runhey/OnmyojiAutoScript/pull/1589/
+        https://github.com/runhey/OnmyojiAutoScript/issues/1588
+        @return:
+        """
+        while 1:
+            scene = self.get_current_scene(reuse_screenshot=False)
+            if scene == Scene.WORLD and self.appear(self.I_EXP_ARROW_RIGHT):
+                return True
+            if scene == Scene.ENTRANCE:
+                logger.warning('World scene unstable, possibly transient frame after paper doll collection')
+                return False
+            if self.appear_then_click(self.I_E_EXPLORATION_CLICK, interval=2):
+                continue
+
 
 if __name__ == "__main__":
     from module.config.config import Config
@@ -436,10 +452,9 @@ if __name__ == "__main__":
     # image = load_image(IMAGE_FILE)
     # t.device.image = image
     while 1:
-    # print(t.search_up_fight(UpType.EXP))
+        # print(t.search_up_fight(UpType.EXP))
         t.screenshot()
-        print(t.I_UP_DARUMA.test_match(t.device.image))
-        time.sleep(0.2)
+        print(t.get_current_scene())
     from PIL import Image
     # Image.fromarray(t.device.image.astype(np.uint8)).show()
 

+ 4 - 11
tasks/Exploration/solo.py

@@ -39,14 +39,12 @@ class SoloExploration(BaseExploration):
             #
             if scene == Scene.WORLD:
                 # 打开右边箭头
-                self.ui_click(click=self.I_EXP_ARROW_LEFT, stop=self.I_EXP_ARROW_RIGHT, interval=2, timeout=3)
+                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 not self.appear(self.I_CHECK_EXPLORATION):
-                    continue
                 if self.check_exit():
                     break
                 self.open_expect_level()
@@ -112,11 +110,8 @@ class SoloExploration(BaseExploration):
             logger.info(f'[run_leader] Current scene: {scene.name}')
             # 探索大世界
             if scene == Scene.WORLD:
-                self.wait_until_stable(self.I_CHECK_EXPLORATION, timeout=5)
                 # 打开右边箭头
-                self.ui_click(click=self.I_EXP_ARROW_LEFT, stop=self.I_EXP_ARROW_RIGHT,timeout=3, interval=2)
-                # 处理识别页面出错的情况
-                if not self.appear(self.I_CHECK_EXPLORATION):
+                if not self.wait_world_stable():
                     continue
                 if self.appear(self.I_TREASURE_BOX_CLICK):
                     # 宝箱
@@ -251,9 +246,7 @@ class SoloExploration(BaseExploration):
             #
             if scene == Scene.WORLD:
                 # 打开右边箭头
-                self.ui_click(click=self.I_EXP_ARROW_LEFT, stop=self.I_EXP_ARROW_RIGHT, interval=2)
-                # 处理识别页面出错的情况
-                if not self.appear(self.I_CHECK_EXPLORATION):
+                if not self.wait_world_stable():
                     continue
                 if self.appear(self.I_TREASURE_BOX_CLICK):
                     # 宝箱