Explorar el Código

Merge pull request #1611 from runhey/dev

Automated PR 2026.06.05
huangrunheng hace 5 meses
padre
commit
3224da1c8f

+ 4 - 3
deploy/config.py

@@ -88,13 +88,14 @@ class DeployConfig(ConfigModel):
         logger.info(f"Rest of the configs are the same as default")
         logger.info(f"Rest of the configs are the same as default")
 
 
     def read(self):
     def read(self):
-        self.config = poor_yaml_read(DEPLOY_TEMPLATE)
+        self.config_template = poor_yaml_read(DEPLOY_TEMPLATE)
+        self.config = copy.deepcopy(self.config_template)
+        self.config.update(poor_yaml_read(self.file))
+
         # https://e.coding.net/onmyojiautoscript/oas/OnmyojiAutoScript.git
         # https://e.coding.net/onmyojiautoscript/oas/OnmyojiAutoScript.git
         # 2025.09.01 腾讯coding跑路了
         # 2025.09.01 腾讯coding跑路了
         if self.config["Repository"].startswith("https://e.coding.net/"):
         if self.config["Repository"].startswith("https://e.coding.net/"):
             self.config["Repository"] = "https://gitcode.com/OnmyojiAutoScript/OnmyojiAutoScript.git"
             self.config["Repository"] = "https://gitcode.com/OnmyojiAutoScript/OnmyojiAutoScript.git"
-        self.config_template = copy.deepcopy(self.config)
-        self.config.update(poor_yaml_read(self.file))
 
 
         for key, value in self.config.items():
         for key, value in self.config.items():
             if hasattr(self, key):
             if hasattr(self, key):

+ 1 - 1
deploy/template

@@ -3,7 +3,7 @@ Deploy:
     # URL of AzurLaneAutoScript repository
     # URL of AzurLaneAutoScript repository
     # [CN user] Use 'https://gitee.com/lmeszinc/azur-lane-auto-script-mirror' for faster and more stable download
     # [CN user] Use 'https://gitee.com/lmeszinc/azur-lane-auto-script-mirror' for faster and more stable download
     # [Other] Use 'https://github.com/LmeSzinc/AzurLaneAutoScript'
     # [Other] Use 'https://github.com/LmeSzinc/AzurLaneAutoScript'
-    Repository: https://e.coding.net/onmyojiautoscript/oas/OnmyojiAutoScript.git
+    Repository: https://gitcode.com/OnmyojiAutoScript/OnmyojiAutoScript.git
     # Branch of Alas
     # Branch of Alas
     # [Developer] Use 'dev', 'app', etc, to try new features
     # [Developer] Use 'dev', 'app', etc, to try new features
     # [Other] Use 'master', the stable branch
     # [Other] Use 'master', the stable branch

+ 3 - 3
dev_tools/assets_test.py

@@ -34,10 +34,10 @@ def detect_ocr(file: str, target: RuleOcr):
 
 
 
 
 # 图片文件路径 可以是相对路径
 # 图片文件路径 可以是相对路径
-IMAGE_FILE = r"C:\Users\Ryland\Desktop\ScreenShot_2026-01-04_222421_055.png"
+IMAGE_FILE = r"C:\Users\Ryland\Desktop\ScreenShot_2026-05-30_141821_235.png"
 if __name__ == '__main__':
 if __name__ == '__main__':
-    from tasks.RichMan.script_task import ScriptTask
-    targe = ScriptTask.I_MALL_BONDLINGS_SURE
+    from tasks.Exploration.script_task import ScriptTask
+    targe = ScriptTask.I_TREASURE_BOX_CLICK
     print(detect_image(IMAGE_FILE, targe))
     print(detect_image(IMAGE_FILE, targe))
 
 
     # ocr demo
     # ocr demo

+ 1 - 1
tasks/Component/GeneralBattle/assets.py

@@ -143,7 +143,7 @@ class GeneralBattleAssets:
 	# 确认按钮 
 	# 确认按钮 
 	I_CONFIRM = RuleImage(roi_front=(732,383,83,43), roi_back=(330,228,615,286), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/gb/gb_confirm.png")
 	I_CONFIRM = RuleImage(roi_front=(732,383,83,43), roi_back=(330,228,615,286), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/gb/gb_confirm.png")
 	# 关闭御魂不一致提示弹窗 
 	# 关闭御魂不一致提示弹窗 
-	I_CONFIRM_CLOSE_DIFF_SOUL = RuleImage(roi_front=(571,404,135,54), roi_back=(508,372,255,161), threshold=0.7, method="Template matching", file="./tasks/Component/GeneralBattle/gb/gb_confirm_close_diff_soul.png")
+	I_CONFIRM_CLOSE_DIFF_SOUL = RuleImage(roi_front=(571,404,135,54), roi_back=(517,374,226,112), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/gb/gb_confirm_close_diff_soul.png")
 	# 禁用御魂不一致提示7天 
 	# 禁用御魂不一致提示7天 
 	I_DISABLE_7DAYS_DIFF_SOUL = RuleImage(roi_front=(547,342,27,36), roi_back=(524,325,70,71), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/gb/gb_disable_7days_diff_soul.png")
 	I_DISABLE_7DAYS_DIFF_SOUL = RuleImage(roi_front=(547,342,27,36), roi_back=(524,325,70,71), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/gb/gb_disable_7days_diff_soul.png")
 
 

+ 2 - 2
tasks/Component/GeneralBattle/gb/img_supplement.json

@@ -21,9 +21,9 @@
     "itemName": "confirm_close_diff_soul",
     "itemName": "confirm_close_diff_soul",
     "imageName": "gb_confirm_close_diff_soul.png",
     "imageName": "gb_confirm_close_diff_soul.png",
     "roiFront": "571,404,135,54",
     "roiFront": "571,404,135,54",
-    "roiBack": "508,372,255,161",
+    "roiBack": "517,374,226,112",
     "method": "Template matching",
     "method": "Template matching",
-    "threshold": 0.7,
+    "threshold": 0.8,
     "description": "关闭御魂不一致提示弹窗"
     "description": "关闭御魂不一致提示弹窗"
   },
   },
   {
   {

+ 14 - 10
tasks/Component/GeneralBattle/general_battle.py

@@ -73,7 +73,7 @@ class GeneralBattle(GeneralBuff, GeneralBattleAssets):
                     continue
                     continue
                 continue
                 continue
             # 未知界面, 既不是准备界面也不是战斗界面
             # 未知界面, 既不是准备界面也不是战斗界面
-            logger.info('Wait for preparation page')
+            # logger.info('Wait for preparation page')  # 这玩意刷屏
             sleep(random.uniform(0.4, 0.8))
             sleep(random.uniform(0.4, 0.8))
         return False
         return False
 
 
@@ -218,10 +218,11 @@ class GeneralBattle(GeneralBuff, GeneralBattleAssets):
                 if not self.appear(self.I_FALSE, threshold=0.6):
                 if not self.appear(self.I_FALSE, threshold=0.6):
                     return False
                     return False
         # 最后保证能点击 获得奖励
         # 最后保证能点击 获得奖励
-        if not self.wait_until_appear(self.I_REWARD):
-            # 有些的战斗没有下面的奖励,所以直接返回
-            logger.info("There is no reward, Exit battle")
-            return win
+        if not self.wait_until_appear(self.I_REWARD, wait_time=10):
+            if not self.appear(self.I_STATISTICS):
+                # 有些的战斗没有下面的奖励,所以直接返回
+                logger.info("There is no reward, Exit battle")
+                return win
         logger.info("Get reward")
         logger.info("Get reward")
         while 1:
         while 1:
             self.screenshot()
             self.screenshot()
@@ -237,13 +238,10 @@ class GeneralBattle(GeneralBuff, GeneralBattleAssets):
                 # self.appear_then_click(self.I_REWARD_SOUL_6, action=action_click, interval=1.5)
                 # self.appear_then_click(self.I_REWARD_SOUL_6, action=action_click, interval=1.5)
                 ):
                 ):
                 continue
                 continue
-            # 未知结算弹窗(皮肤碎片等):点一下空白区域尝试跳过
-            if self.appear(self.I_STATISTICS) and not self.appear(self.I_REWARD)and not self.appear(self.I_WIN):
-                self.click(self.C_RANDOM_CLICK)  #碎片
-                self.appear_then_click(self.I_CONFIRM_CLOSE_DIFF_SOUL) #整个皮肤
+            if self._hook_special_reward():
                 continue
                 continue
             if (not self.appear(self.I_REWARD) and
             if (not self.appear(self.I_REWARD) and
-                not self.appear(self.I_REWARD_GOLD)#  and
+                not self.appear(self.I_REWARD_GOLD)  # and
                 # not self.appear(self.I_REWARD_STATISTICS) and
                 # not self.appear(self.I_REWARD_STATISTICS) and
                 # not self.appear(self.I_REWARD_PURPLE_SNAKE_SKIN) and
                 # not self.appear(self.I_REWARD_PURPLE_SNAKE_SKIN) and
                 # not self.appear(self.I_REWARD_GOLD_SNAKE_SKIN) and
                 # not self.appear(self.I_REWARD_GOLD_SNAKE_SKIN) and
@@ -255,6 +253,12 @@ class GeneralBattle(GeneralBuff, GeneralBattleAssets):
 
 
         return win
         return win
 
 
+    def _hook_special_reward(self) -> bool:
+        """
+        For overwrite https://github.com/runhey/OnmyojiAutoScript/issues/1580
+        """
+        return False
+
     def green_mark(self, enable: bool = False, mark_mode: GreenMarkType = GreenMarkType.GREEN_MAIN):
     def green_mark(self, enable: bool = False, mark_mode: GreenMarkType = GreenMarkType.GREEN_MAIN):
         """
         """
         绿标, 如果不使能就直接返回
         绿标, 如果不使能就直接返回

+ 35 - 87
tasks/Component/GeneralBuff/general_buff.py

@@ -62,7 +62,7 @@ class GeneralBuff(BaseTask, GeneralBuffAssets):
         self.screenshot()
         self.screenshot()
         area = buff.ocr(self.device.image)
         area = buff.ocr(self.device.image)
         if area == tuple([432.0, 143.0, 325.0, 21.0]):
         if area == tuple([432.0, 143.0, 325.0, 21.0]):
-            logger.info('No gold 50 buff')
+            logger.info(f'No {buff.name} buff')
             return None
             return None
 
 
         # 开始的x坐标就是文字的右边
         # 开始的x坐标就是文字的右边
@@ -87,28 +87,19 @@ class GeneralBuff(BaseTask, GeneralBuffAssets):
         :param is_open: 是否打开
         :param is_open: 是否打开
         :return:
         :return:
         """
         """
-        logger.info('Gold 50 buff')
+        logger.info(f'{"Open" if is_open else "Close"} gold 50 buff')
         self.screenshot()
         self.screenshot()
         area = self.get_area(self.O_GOLD_50)
         area = self.get_area(self.O_GOLD_50)
         if not area:
         if not area:
             logger.warning('No gold 50 buff')
             logger.warning('No gold 50 buff')
             return None
             return None
-        self.I_OPEN_YELLOW.roi_back = list(area)  # 动态设置roi
-        self.I_CLOSE_RED.roi_back = list(area)
+        self.set_switch_area(area)
         if is_open:
         if is_open:
-            while 1:
-                self.screenshot()
-                if self.appear(self.I_OPEN_YELLOW):
-                    break
-                if self.appear_then_click(self.I_CLOSE_RED, interval=1):
-                    continue
+            if not self.ui_click(click=self.I_CLOSE_RED, stop=self.I_OPEN_YELLOW, interval=1, timeout=10):
+                logger.warning('Open gold 50 buff failed')
         else:
         else:
-            while 1:
-                self.screenshot()
-                if self.appear(self.I_CLOSE_RED):
-                    break
-                if self.appear_then_click(self.I_OPEN_YELLOW, interval=1):
-                    continue
+            if not self.ui_click(click=self.I_OPEN_YELLOW, stop=self.I_CLOSE_RED, interval=1, timeout=10):
+                logger.warning('Close gold 50 buff failed')
 
 
     def gold_100(self, is_open: bool = True):
     def gold_100(self, is_open: bool = True):
         """
         """
@@ -116,28 +107,19 @@ class GeneralBuff(BaseTask, GeneralBuffAssets):
         :param is_open: 是否打开
         :param is_open: 是否打开
         :return:
         :return:
         """
         """
-        logger.info('Gold 100 buff')
+        logger.info(f'{"Open" if is_open else "Close"} gold 100 buff')
         self.screenshot()
         self.screenshot()
         area = self.get_area(self.O_GOLD_100)
         area = self.get_area(self.O_GOLD_100)
         if not area:
         if not area:
             logger.warning('No gold 100 buff')
             logger.warning('No gold 100 buff')
             return None
             return None
-        self.I_OPEN_YELLOW.roi_back = list(area)
-        self.I_CLOSE_RED.roi_back = list(area)
+        self.set_switch_area(area)
         if is_open:
         if is_open:
-            while 1:
-                self.screenshot()
-                if self.appear(self.I_OPEN_YELLOW):
-                    break
-                if self.appear_then_click(self.I_CLOSE_RED, interval=1):
-                    continue
+            if not self.ui_click(click=self.I_CLOSE_RED, stop=self.I_OPEN_YELLOW, interval=1, timeout=10):
+                logger.warning('Open gold 100 buff failed')
         else:
         else:
-            while 1:
-                self.screenshot()
-                if self.appear(self.I_CLOSE_RED):
-                    break
-                if self.appear_then_click(self.I_OPEN_YELLOW, interval=1):
-                    continue
+            if not self.ui_click(click=self.I_OPEN_YELLOW, stop=self.I_CLOSE_RED, interval=1, timeout=10):
+                logger.warning('Close gold 100 buff failed')
 
 
     def exp_50(self, is_open: bool = True):
     def exp_50(self, is_open: bool = True):
         """
         """
@@ -145,7 +127,7 @@ class GeneralBuff(BaseTask, GeneralBuffAssets):
         :param is_open: 是否打开
         :param is_open: 是否打开
         :return:
         :return:
         """
         """
-        logger.info('Exp 50 buff')
+        logger.info(f'{"Open" if is_open else "Close"} exp 50 buff')
         while 1:
         while 1:
             self.screenshot()
             self.screenshot()
             area = self.get_area(self.O_EXP_50)
             area = self.get_area(self.O_EXP_50)
@@ -155,26 +137,17 @@ class GeneralBuff(BaseTask, GeneralBuffAssets):
             self.set_switch_area(area)
             self.set_switch_area(area)
 
 
             if not self.appear(self.I_OPEN_YELLOW) and not self.appear(self.I_CLOSE_RED):
             if not self.appear(self.I_OPEN_YELLOW) and not self.appear(self.I_CLOSE_RED):
-                logger.info('No exp 50 buff')
                 self.device.swipe(p2=(530, 240), p1=(580, 320))
                 self.device.swipe(p2=(530, 240), p1=(580, 320))
                 time.sleep(1)
                 time.sleep(1)
             else:
             else:
                 break
                 break
 
 
         if is_open:
         if is_open:
-            while 1:
-                self.screenshot()
-                if self.appear(self.I_OPEN_YELLOW):
-                    break
-                if self.appear_then_click(self.I_CLOSE_RED, interval=1):
-                    continue
+            if not self.ui_click(click=self.I_CLOSE_RED, stop=self.I_OPEN_YELLOW, interval=1, timeout=10):
+                logger.warning('Open exp 50 buff failed')
         else:
         else:
-            while 1:
-                self.screenshot()
-                if self.appear(self.I_CLOSE_RED):
-                    break
-                if self.appear_then_click(self.I_OPEN_YELLOW, interval=1):
-                    continue
+            if not self.ui_click(click=self.I_OPEN_YELLOW, stop=self.I_CLOSE_RED, interval=1, timeout=10):
+                logger.warning('Close exp 50 buff failed')
 
 
     def exp_100(self, is_open: bool = True):
     def exp_100(self, is_open: bool = True):
         """
         """
@@ -182,7 +155,7 @@ class GeneralBuff(BaseTask, GeneralBuffAssets):
         :param is_open: 是否打开
         :param is_open: 是否打开
         :return:
         :return:
         """
         """
-        logger.info('Exp 100 buff')
+        logger.info(f'{"Open" if is_open else "Close"} exp 100 buff')
         while 1:
         while 1:
             self.screenshot()
             self.screenshot()
             area = self.get_area(self.O_EXP_100)
             area = self.get_area(self.O_EXP_100)
@@ -192,26 +165,17 @@ class GeneralBuff(BaseTask, GeneralBuffAssets):
             self.set_switch_area(area)
             self.set_switch_area(area)
 
 
             if not self.appear(self.I_OPEN_YELLOW) and not self.appear(self.I_CLOSE_RED):
             if not self.appear(self.I_OPEN_YELLOW) and not self.appear(self.I_CLOSE_RED):
-                logger.info('No exp 100 buff')
                 self.device.swipe(p2=(530, 240), p1=(580, 320))
                 self.device.swipe(p2=(530, 240), p1=(580, 320))
                 time.sleep(1)
                 time.sleep(1)
             else:
             else:
                 break
                 break
 
 
         if is_open:
         if is_open:
-            while 1:
-                self.screenshot()
-                if self.appear(self.I_OPEN_YELLOW):
-                    break
-                if self.appear_then_click(self.I_CLOSE_RED, interval=1):
-                    continue
+            if not self.ui_click(click=self.I_CLOSE_RED, stop=self.I_OPEN_YELLOW, interval=1, timeout=10):
+                logger.warning('Open exp 100 buff failed')
         else:
         else:
-            while 1:
-                self.screenshot()
-                if self.appear(self.I_CLOSE_RED):
-                    break
-                if self.appear_then_click(self.I_OPEN_YELLOW, interval=1):
-                    continue
+            if not self.ui_click(click=self.I_OPEN_YELLOW, stop=self.I_CLOSE_RED, interval=1, timeout=10):
+                logger.warning('Close exp 100 buff failed')
 
 
     def get_area_image(self, target: RuleImage) -> list:
     def get_area_image(self, target: RuleImage) -> list:
         """
         """
@@ -241,7 +205,7 @@ class GeneralBuff(BaseTask, GeneralBuffAssets):
         :param is_open: 是否打开
         :param is_open: 是否打开
         :return:
         :return:
         """
         """
-        logger.info('Awake buff')
+        logger.info(f'{"Open" if is_open else "Close"} awake buff')
         self.screenshot()
         self.screenshot()
         area = self.get_area_image(self.I_AWAKE)
         area = self.get_area_image(self.I_AWAKE)
         if not area:
         if not area:
@@ -249,19 +213,11 @@ class GeneralBuff(BaseTask, GeneralBuffAssets):
             return None
             return None
         self.set_switch_area(area)
         self.set_switch_area(area)
         if is_open:
         if is_open:
-            while 1:
-                self.screenshot()
-                if self.appear(self.I_OPEN_YELLOW):
-                    break
-                if self.appear_then_click(self.I_CLOSE_RED, interval=1):
-                    continue
+            if not self.ui_click(click=self.I_CLOSE_RED, stop=self.I_OPEN_YELLOW, interval=1, timeout=10):
+                logger.warning('Open awake buff failed')
         else:
         else:
-            while 1:
-                self.screenshot()
-                if self.appear(self.I_CLOSE_RED):
-                    break
-                if self.appear_then_click(self.I_OPEN_YELLOW, interval=1):
-                    continue
+            if not self.ui_click(click=self.I_OPEN_YELLOW, stop=self.I_CLOSE_RED, interval=1, timeout=10):
+                logger.warning('Close awake buff failed')
 
 
     def soul(self, is_open: bool = True):
     def soul(self, is_open: bool = True):
         """
         """
@@ -269,7 +225,7 @@ class GeneralBuff(BaseTask, GeneralBuffAssets):
         :param is_open: 是否打开
         :param is_open: 是否打开
         :return:
         :return:
         """
         """
-        logger.info('Soul buff')
+        logger.info(f'{"Open" if is_open else "Close"} soul buff')
         self.screenshot()
         self.screenshot()
         area = self.get_area_image(self.I_SOUL)
         area = self.get_area_image(self.I_SOUL)
         if not area:
         if not area:
@@ -277,19 +233,11 @@ class GeneralBuff(BaseTask, GeneralBuffAssets):
             return None
             return None
         self.set_switch_area(area)
         self.set_switch_area(area)
         if is_open:
         if is_open:
-            while 1:
-                self.screenshot()
-                if self.appear(self.I_OPEN_YELLOW):
-                    break
-                if self.appear_then_click(self.I_CLOSE_RED, interval=1):
-                    continue
+            if not self.ui_click(click=self.I_CLOSE_RED, stop=self.I_OPEN_YELLOW, interval=1, timeout=10):
+                logger.warning('Open soul buff failed')
         else:
         else:
-            while 1:
-                self.screenshot()
-                if self.appear(self.I_CLOSE_RED):
-                    break
-                if self.appear_then_click(self.I_OPEN_YELLOW, interval=1):
-                    continue
+            if not self.ui_click(click=self.I_OPEN_YELLOW, stop=self.I_CLOSE_RED, interval=1, timeout=10):
+                logger.warning('Close soul buff failed')
 
 
     def reject_invite(self):
     def reject_invite(self):
         from tasks.Component.GeneralInvite.assets import GeneralInviteAssets as gia
         from tasks.Component.GeneralInvite.assets import GeneralInviteAssets as gia
@@ -321,7 +269,7 @@ if __name__ == '__main__':
     #
     #
     t.awake(is_open=True)
     t.awake(is_open=True)
     t.soul(is_open=True)
     t.soul(is_open=True)
-    # t.gold_50(is_open=True)
-    t.gold_100(is_open=True)
+    t.gold_50(is_open=False)
+    t.gold_100(is_open=False)
     t.exp_50(is_open=True)
     t.exp_50(is_open=True)
     t.exp_100(is_open=True)
     t.exp_100(is_open=True)

+ 1 - 1
tasks/Exploration/assets.py

@@ -110,7 +110,7 @@ class ExplorationAssets:
 	# description 
 	# description 
 	I_E_EXIT_CONFIRM = RuleImage(roi_front=(694,380,163,49), roi_back=(694,380,163,49), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_e_exit_confirm.png")
 	I_E_EXIT_CONFIRM = RuleImage(roi_front=(694,380,163,49), roi_back=(694,380,163,49), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_e_exit_confirm.png")
 	# 宝箱 
 	# 宝箱 
-	I_TREASURE_BOX_CLICK = RuleImage(roi_front=(33,476,70,49), roi_back=(2,130,135,406), threshold=0.7, method="Template matching", file="./tasks/Exploration/res/res_treasure_box_click.png")
+	I_TREASURE_BOX_CLICK = RuleImage(roi_front=(34,386,47,37), roi_back=(2,130,135,406), threshold=0.65, method="Template matching", file="./tasks/Exploration/res/res_treasure_box_click.png")
 	# 困28滚动到最后 
 	# 困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=(994,234,119,100), roi_back=(968,196,311,165), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_swipe_end.png")
 	# 队伍的表情标志 
 	# 队伍的表情标志 

+ 25 - 3
tasks/Exploration/base.py

@@ -409,6 +409,13 @@ class BaseExploration(GameUi, GeneralBattle, GeneralRoom, GeneralInvite, Replace
             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
 
 
+    def _hook_special_reward(self) -> bool:
+        if self.appear(self.I_STATISTICS) and not self.appear(self.I_REWARD) and not self.appear(self.I_WIN):
+            if self.appear_then_click(self.I_CONFIRM_CLOSE_DIFF_SOUL):
+                return True
+            self.click(self.C_RANDOM_CLICK, interval=1.5)
+        return False
+
     def fire(self, button) -> bool:
     def fire(self, button) -> bool:
         self.ui_click_until_disappear(button, interval=3)
         self.ui_click_until_disappear(button, interval=3)
         self.screenshot()
         self.screenshot()
@@ -422,6 +429,22 @@ class BaseExploration(GameUi, GeneralBattle, GeneralRoom, GeneralInvite, Replace
         self.minions_cnt += 1
         self.minions_cnt += 1
         return True
         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_EXP_ARROW_LEFT, interval=2):
+                continue
+
 
 
 if __name__ == "__main__":
 if __name__ == "__main__":
     from module.config.config import Config
     from module.config.config import Config
@@ -436,10 +459,9 @@ if __name__ == "__main__":
     # image = load_image(IMAGE_FILE)
     # image = load_image(IMAGE_FILE)
     # t.device.image = image
     # t.device.image = image
     while 1:
     while 1:
-    # print(t.search_up_fight(UpType.EXP))
+        # print(t.search_up_fight(UpType.EXP))
         t.screenshot()
         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
     from PIL import Image
     # Image.fromarray(t.device.image.astype(np.uint8)).show()
     # Image.fromarray(t.device.image.astype(np.uint8)).show()
 
 

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

@@ -173,10 +173,10 @@
   {
   {
     "itemName": "treasure_box_click",
     "itemName": "treasure_box_click",
     "imageName": "res_treasure_box_click.png",
     "imageName": "res_treasure_box_click.png",
-    "roiFront": "33,476,70,49",
+    "roiFront": "34,386,47,37",
     "roiBack": "2,130,135,406",
     "roiBack": "2,130,135,406",
     "method": "Template matching",
     "method": "Template matching",
-    "threshold": 0.7,
+    "threshold": 0.65,
     "description": "宝箱"
     "description": "宝箱"
   },
   },
   {
   {

BIN
tasks/Exploration/res/res_treasure_box_click.png


+ 7 - 14
tasks/Exploration/solo.py

@@ -35,18 +35,16 @@ class SoloExploration(BaseExploration):
         while 1:
         while 1:
             self.screenshot()
             self.screenshot()
             scene = self.get_current_scene()
             scene = self.get_current_scene()
-            logger.info(f'[run_solo] Current scene: {scene.name}')
+            logger.info(f'[run_solo] Current scene: {scene.name}')  # TODO 2026.06.22 之后删掉这个刷屏的
             #
             #
             if scene == Scene.WORLD:
             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):
                 if self.appear(self.I_TREASURE_BOX_CLICK):
                     # 宝箱
                     # 宝箱
                     logger.info('Treasure box appear, get it.')
                     logger.info('Treasure box appear, get it.')
                     self.ui_click_until_disappear(self.I_TREASURE_BOX_CLICK)
                     self.ui_click_until_disappear(self.I_TREASURE_BOX_CLICK)
-                # 处理识别页面出错的情况
-                if not self.appear(self.I_CHECK_EXPLORATION):
-                    continue
                 if self.check_exit():
                 if self.check_exit():
                     break
                     break
                 self.open_expect_level()
                 self.open_expect_level()
@@ -109,14 +107,11 @@ class SoloExploration(BaseExploration):
         while 1:
         while 1:
             self.screenshot()
             self.screenshot()
             scene = self.get_current_scene()
             scene = self.get_current_scene()
-            logger.info(f'[run_leader] Current scene: {scene.name}')
+            logger.info(f'[run_leader] Current scene: {scene.name}')  # TODO 2026.06.22 之后删掉这个刷屏的
             # 探索大世界
             # 探索大世界
             if scene == Scene.WORLD:
             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
                     continue
                 if self.appear(self.I_TREASURE_BOX_CLICK):
                 if self.appear(self.I_TREASURE_BOX_CLICK):
                     # 宝箱
                     # 宝箱
@@ -247,13 +242,11 @@ class SoloExploration(BaseExploration):
         while 1:
         while 1:
             self.screenshot()
             self.screenshot()
             scene = self.get_current_scene()
             scene = self.get_current_scene()
-            logger.info(f'[run_member] Current scene: {scene.name}')
+            logger.info(f'[run_member] Current scene: {scene.name}')  # TODO 2026.06.12 之后删掉这个刷屏的
             #
             #
             if scene == Scene.WORLD:
             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
                     continue
                 if self.appear(self.I_TREASURE_BOX_CLICK):
                 if self.appear(self.I_TREASURE_BOX_CLICK):
                     # 宝箱
                     # 宝箱

+ 1 - 1
tasks/GameUi/assets.py

@@ -49,7 +49,7 @@ class GameUiAssets:
 	# description 
 	# 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")
 	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 
 	# description 
-	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_CHECK_EXPLORATION = RuleImage(roi_front=(681,12,27,36), roi_back=(661,0,70,61), threshold=0.65, 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")
 	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")
 	# 探索前往御魂 
 	# 探索前往御魂 

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

@@ -32,7 +32,7 @@
     "roiFront": "681,12,27,36",
     "roiFront": "681,12,27,36",
     "roiBack": "661,0,70,61",
     "roiBack": "661,0,70,61",
     "method": "Template matching",
     "method": "Template matching",
-    "threshold": 0.8,
+    "threshold": 0.65,
     "description": "description"
     "description": "description"
   },
   },
   {
   {

+ 10 - 76
tasks/WantedQuests/script_task.py

@@ -76,7 +76,11 @@ class ScriptTask(WQExplore, SecretScriptTask, WantedQuestsAssets):
             if error_count > 3:
             if error_count > 3:
                 logger.warning('failed too many times, exit')
                 logger.warning('failed too many times, exit')
                 break
                 break
+            if self.current_count >= 30:
+                logger.error(f'current count {self.current_count} >= 20, exit')
+                raise Exception('current count >= 20, exit')
             cu, re, total, area = self.find_wq(self.device.image)
             cu, re, total, area = self.find_wq(self.device.image)
+            logger.info(f"find_wq result: current {cu} remain {re} total {total} area {area}")
             if re == -2:
             if re == -2:
                 logger.info("only completed wanted quests remained")
                 logger.info("only completed wanted quests remained")
                 break
                 break
@@ -87,86 +91,11 @@ class ScriptTask(WQExplore, SecretScriptTask, WantedQuestsAssets):
                 sleep(1)
                 sleep(1)
                 continue
                 continue
             # 找到任务,执行
             # 找到任务,执行
-            error_count=0
+            error_count = 0
             self.O_WQ_TEXT_ALL.area = area
             self.O_WQ_TEXT_ALL.area = area
             self.execute_mission(self.O_WQ_TEXT_ALL, total - cu, number_challenge)
             self.execute_mission(self.O_WQ_TEXT_ALL, total - cu, number_challenge)
             sleep(1.5)
             sleep(1.5)
 
 
-
-
-        # region 旧代码
-        # # 第一个位置
-        # wq_1_done = False
-        # wq_2_done = False
-        # while 1:
-        #     self.screenshot()
-        #     if self.appear(self.I_WQ_BOX):
-        #         self.ui_get_reward(self.I_WQ_BOX)
-        #         continue
-        #     if self.appear(self.I_TREASURE_BOX_CLICK):
-        #         self.ui_get_reward(self.I_TREASURE_BOX_CLICK)
-        #         continue
-        #     if ocr_error_count > 10:
-        #         logger.warning('OCR failed too many times, exit')
-        #         break
-        #     # if self.ocr_appear(self.O_WQ_TEXT_1, interval=1):
-        #     if (not wq_1_done) and self.txt_ocr_appear(self.O_WQ_TEXT_1, r".*[封|野]印.*", self.device.image):
-        #         # cu, re, total = self.O_WQ_NUM_1.ocr(self.device.image)
-        #         cu, re, total = self.process_ocr(self.O_WQ_NUM_1, self.device.image)
-        #         if cu == re == total == 0:
-        #             logger.warning('OCR failed and have a try')
-        #             ocr_error_count += 1
-        #             # 尝试打一次
-        #             unknown_num = self.O_WQ_NUM_UNKNOWN_1.ocr(self.device.image)
-        #             if unknown_num > 14:
-        #                 self.execute_mission(self.O_WQ_TEXT_1, 1, number_challenge)
-        #         if total > 14:
-        #             logger.warning("Total number of wanted quests is greater than 14")
-        #             total = total % 10
-        #         if cu > total:
-        #             logger.warning('Current number of wanted quests is greater than total number')
-        #             cu = cu % 10
-        #         if cu < total and re != 0:
-        #             self.execute_mission(self.O_WQ_TEXT_1, min(total - cu, 20), number_challenge)
-        #         if cu == total:
-        #             wq_1_done = True
-        #
-        #     # if self.ocr_appear(self.O_WQ_TEXT_2, interval=1):
-        #     if self.txt_ocr_appear(self.O_WQ_TEXT_2, r".*[封|野]印.*", self.device.image):
-        #         # cu, re, total = self.O_WQ_NUM_2.ocr(self.device.image)
-        #         cu, re, total = self.process_ocr(self.O_WQ_NUM_2, self.device.image)
-        #         if cu == re == total == 0:
-        #             logger.warning('OCR failed and have a try')
-        #             ocr_error_count += 1
-        #             # 尝试打一次
-        #             unknown_num = self.O_WQ_NUM_UNKNOWN_2.ocr(self.device.image)
-        #             if unknown_num > 14:
-        #                 self.execute_mission(self.O_WQ_TEXT_2, 1, number_challenge)
-        #         if total > 14:
-        #             logger.warning("Total number of wanted quests is greater than 14")
-        #             total = total % 10
-        #         if cu > total:
-        #             logger.warning('Current number of wanted quests is greater than total number')
-        #             cu = cu % 10
-        #         if cu < total and re != 0:
-        #             self.execute_mission(self.O_WQ_TEXT_2, min(total - cu, 20), number_challenge)
-        #         continue
-        #
-        #     # 妖气封印或者年兽,那就四分钟后继续
-        #     if self.appear(self.I_WQ_D1111) or self.appear(self.I_WQ_NIAN):
-        #         logger.warning('Tiger is in the way, wait for 4 minutes')
-        #         logger.info('Time to wait for 4 minutes')
-        #         self.set_next_run('WantedQuests', target=datetime.now() + timedelta(minutes=4))
-        #         raise TaskEnd('WantedQuests')
-        #     if self.appear(self.I_WQ_CHECK_TASK):
-        #         continue
-        #     sleep(1.5)
-        #     self.screenshot()
-        #     if not self.appear(self.I_WQ_CHECK_TASK):
-        #         logger.info('No wanted quests')
-        #         break
-        # endregion
-
         self.next_run()
         self.next_run()
         raise TaskEnd('WantedQuests')
         raise TaskEnd('WantedQuests')
 
 
@@ -728,17 +657,22 @@ class ScriptTask(WQExplore, SecretScriptTask, WantedQuestsAssets):
         reg_progress = re.compile(r'^(\d+)([7/])(\d+)$')
         reg_progress = re.compile(r'^(\d+)([7/])(\d+)$')
         # 没有检测到斜杠,符合格式:前N位与后N位相同,表示已完成
         # 没有检测到斜杠,符合格式:前N位与后N位相同,表示已完成
         reg_XX = re.compile(r'^(\d+)\1$')
         reg_XX = re.compile(r'^(\d+)\1$')
+        # 过滤掉协或者未知悬赏等其他无用字符
+        reg_other = re.compile(r'[??协边]')
         completed_only = False
         completed_only = False
         for index, res in enumerate(res_list):
         for index, res in enumerate(res_list):
             if reg_fengyin.match(res.ocr_text):
             if reg_fengyin.match(res.ocr_text):
                 continue
                 continue
             if reg_time.match(res.ocr_text):
             if reg_time.match(res.ocr_text):
                 continue
                 continue
+            if reg_other.search(res.ocr_text):
+                continue
             if (match := reg_progress.match(res.ocr_text)):
             if (match := reg_progress.match(res.ocr_text)):
                 spliter_index = match.start(2)
                 spliter_index = match.start(2)
                 xywh = calc_xywh(res.box)
                 xywh = calc_xywh(res.box)
                 self.O_WQ_TEXT_ALL.area = xywh
                 self.O_WQ_TEXT_ALL.area = xywh
                 cu, re, total = int(res.ocr_text[:spliter_index]), 1, int(res.ocr_text[spliter_index + 1:])
                 cu, re, total = int(res.ocr_text[:spliter_index]), 1, int(res.ocr_text[spliter_index + 1:])
+                logger.info(f'Matched: {res.ocr_text}')
                 # 识别结果规范性检查
                 # 识别结果规范性检查
                 if total > 14:
                 if total > 14:
                     logger.warning("Total number of wanted quests is greater than 14")
                     logger.warning("Total number of wanted quests is greater than 14")