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

Merge pull request #1724 from runhey/dev

Automated PR 2026.08.06
huangrunheng 3 месяцев назад
Родитель
Сommit
46a2ddd10a

+ 7 - 1
assets/i18n/zh-CN.json

@@ -41,5 +41,11 @@
   "emulator_startup_lead_time": "模拟器预热时间",
   "emulator_startup_lead_time_help": "在开始运行任务之前提前启动模拟器的时间",
   "exit_four_help": "支持打九退四,保证稳定57级,要求设置好战斗主题,即 脚本->全局配置->游戏装饰自定义->战斗主题",
-  "costume_main_15": "茨心乐园"
+  "costume_main_15": "茨心乐园",
+  "check_true_orochi_enable": "是否在结束后检测真蛇",
+  "check_true_orochi_enable_help": "开启后会在任务结束后检测是否出现真蛇, 若出现则自动拉起真蛇",
+  "enable_book_auto": "自动选择",
+  "enable_book_auto_help": "游戏内是否开启自动选择御魂",
+  "earn_money": "获取樱灯饰",
+  "earn_money_help": "通过放置借处式神获取500樱灯饰\n开启前确保已放置借出式神"
 }

+ 41 - 2
tasks/BondlingFairyland/script_task.py

@@ -290,6 +290,8 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
                     elif bondling_config.bondling_search_enable and bondling_config.user_status == UserStatus.ALONE:
                         if self.run_search(bondling_config, limit_cnt=random.randint(5, 20)):
                             logger.info('Bondling search finish, try to run catch')
+                            # 切御魂
+                            self._switch_soul_capture()
                             continue
                         else:
                             break  # 时间到了或次数到了直接退出
@@ -345,19 +347,24 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
             self.ui_click_until_disappear(self.I_STONE_CLOSE, interval=1.2)
             logger.warning(f'已经没有鸣契石召唤契灵了')
             return False
+        cnt = 0
         while 1:
             self.screenshot()
             if not self.appear(self.I_STONE_SURE):
                 sleep(random.uniform(1.5, 2))  # 等待购买后的动画, 否则已经买了但是下次再点击还会出现该界面
                 return True
+            if cnt >= 6:
+                logger.warning("")
+                return False
             for i in range(3):
                 if self.appear_then_click(self.I_BUY_PLUS, interval=1):
                     sleep(0.5)
             if self.appear_then_click(self.I_GI_SURE, interval=1):
                 continue
-            if self.appear_then_click(self.I_STONE_SURE, interval=1):
+            if self.appear_then_click(self.I_STONE_SURE, interval=2):
                 continue
 
+
     def run_search(self, bondling_config: BondlingConfig, limit_cnt: int = None):
         """
         运行探查
@@ -368,6 +375,7 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
         (4) 打满对应limit_cnt次, (探查界面)返回True
         """
         self.lock_team()
+        self._switch_soul_search()
         while 1:
             # 检查是不是在探查界面,
             if not self.in_search_ui(screenshot=True):
@@ -816,6 +824,37 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
             type_str, (group, team) = bondling_switch_soul.get_switch_by_name('search_switch')
             do_switch_soul(type_str, group, team)
 
+    def _switch_soul_to(self, ts, g, te):
+        def _do_switch_soul(ts: str, g: str | int, te: str | int):
+            if ts is None:
+                raise ValueError(f'Invalid switch soul config on {self.config.bondling_fairyland.bondling_config.bondling_stone_class.value}')
+            if ts == 'int':
+                self.run_switch_soul((g, te))
+            if ts == 'str':
+                self.run_switch_soul_by_name(g, te)
+
+        if ts is None:
+            logger.warning('Switch soul preset not configured, skip')
+            return
+
+        self.goto_shikigami_records(self.I_GOTO_SHIKIGAMI_COMMON)
+        _do_switch_soul(ts, g, te)
+        self.exit_shikigami_records()
+
+
+    def _switch_soul_search(self):
+        logger.info("切换御魂-探查")
+        if not self.config.bondling_fairyland.bondling_switch_soul.enable: return
+        ts, (g, te) = self.config.bondling_fairyland.bondling_switch_soul.get_switch_by_name('search_switch')
+        self._switch_soul_to(ts, g, te)
+
+    def _switch_soul_capture(self):
+        logger.info("切换御魂-捕获")
+        cong = self.config.bondling_fairyland
+        if not cong.bondling_switch_soul.enable: return
+        ts, (g, te) = cong.bondling_switch_soul.get_switch_by_enum(cong.bondling_config.bondling_stone_class)
+        self._switch_soul_to(ts, g, te)
+
 
 if __name__ == '__main__':
     from module.config.config import Config
@@ -824,7 +863,7 @@ if __name__ == '__main__':
     config = Config('oas1')
     device = Device(config)
     t = ScriptTask(config, device)
-    # t.run()
+    t.run()
     t.ui_get_current_page()
     t.ui_goto(page_bondling_fairyland)
     # image = task.screenshot()

+ 2 - 2
tasks/Component/Buy/assets.py

@@ -14,7 +14,7 @@ class BuyAssets:
 	# description 
 	C_BUY_ONE = RuleClick(roi_front=(551,506,174,36), roi_back=(551,506,174,36), name="buy_one")
 	# description 
-	C_BUY_MORE = RuleClick(roi_front=(551,540,174,40), roi_back=(551,540,174,40), name="buy_more")
+	C_BUY_MORE = RuleClick(roi_front=(551,563,174,17), roi_back=(551,563,174,17), name="buy_more")
 	# 取消购买 
 	C_BUY_CANCEL = RuleClick(roi_front=(121,2,100,22), roi_back=(121,2,100,22), name="buy_cancel")
 
@@ -34,6 +34,6 @@ class BuyAssets:
 
 	# Ocr Rule Assets
 	# Ocr-description 
-	O_BUY_NUMBER = RuleOcr(roi=(578,416,52,46), area=(578,416,52,46), mode="Digit", method="Default", keyword="", name="buy_number")
+	O_BUY_NUMBER = RuleOcr(roi=(578,416,52,71), area=(578,416,52,71), mode="Digit", method="Default", keyword="", name="buy_number")
 
 

+ 2 - 2
tasks/Component/Buy/buy/click.json

@@ -7,8 +7,8 @@
   },
   {
     "itemName": "buy_more",
-    "roiFront": "551,540,174,40",
-    "roiBack": "551,540,174,40",
+    "roiFront": "551,563,174,17",
+    "roiBack": "551,563,174,17",
     "description": "description"
   },
   {

+ 2 - 2
tasks/Component/Buy/buy/ocr.json

@@ -1,8 +1,8 @@
 [
   {
     "itemName": "buy_number",
-    "roiFront": "578,416,52,46",
-    "roiBack": "578,416,52,46",
+    "roiFront": "578,416,52,71",
+    "roiBack": "578,416,52,71",
     "mode": "Digit",
     "method": "Default",
     "keyword": "",

+ 57 - 0
tasks/Component/GeneralBattle/general_battle.py

@@ -253,6 +253,63 @@ class GeneralBattle(GeneralBuff, GeneralBattleAssets):
 
         return win
 
+    def battle_wait_v2(self, random_click_swipt_enable: bool) -> bool:
+        """
+        第二版战斗等待,参考 Orochi 和 Secret 的优化版本。
+        :return: 胜利返回 True,失败返回 False
+        """
+        # 统一点击名称,防止 GameTooManyClickError 误报
+        self.C_REWARD_1.name, self.C_REWARD_2.name, self.C_REWARD_3.name = 'C_REWARD', 'C_REWARD', 'C_REWARD'
+        self.device.stuck_record_add('BATTLE_STATUS_S')
+        self.device.click_record_clear()
+
+        logger.info("Start battle process")
+        while 1:
+            self.screenshot()
+            # 出现赢的鼓,点击直到消失
+            if self.appear_then_click(self.I_WIN, interval=0.8):
+                continue
+            # 逢魔胜利图
+            if self.appear(self.I_DE_WIN):
+                self.ui_click_until_disappear(self.I_DE_WIN)
+                continue
+            if self.appear(self.I_FALSE, threshold=0.8):
+                logger.warning('False battle')
+                self.ui_click_until_disappear(self.I_FALSE)
+                return False
+            appear_ghost, appear_reward, appear_gold = (
+                self.appear(self.I_GREED_GHOST),
+                self.appear(self.I_REWARD),
+                self.appear(self.I_REWARD_GOLD)
+            )
+            if appear_ghost or appear_reward or appear_gold:
+                logger.info('Win battle')
+                timer = Timer(20).start()
+                while 1:
+                    self.screenshot()
+
+                    _appear_ghost, _appear_reward, _appear_gold = (
+                        self.appear(self.I_GREED_GHOST, threshold=0.6),
+                        self.appear(self.I_REWARD),
+                        self.appear(self.I_REWARD_GOLD)
+                    )
+                    # logger.info(f'_appear_ghost: {_appear_ghost} _appear_reward: {_appear_reward} _appear_gold: {_appear_gold}')
+                    if any([_appear_ghost, _appear_reward, _appear_gold]):
+                        action_click = random.choice([self.C_REWARD_1, self.C_REWARD_2, self.C_REWARD_3])
+                        self.click(action_click, interval=1.5)
+                    else:
+                        logger.info('Battle done')
+                        return True
+                    if self._hook_special_reward():
+                        continue
+                    if timer.reached_and_reset():
+                        logger.warning('battle ')
+                        break
+            # 随机滑动
+            if random_click_swipt_enable:
+                self.random_click_swipt()
+        return False
+
     def _hook_special_reward(self) -> bool:
         """
         For overwrite https://github.com/runhey/OnmyojiAutoScript/issues/1580

+ 1 - 1
tasks/Component/SwitchAccount/login_account.py

@@ -90,7 +90,7 @@ class LoginAccount(BaseTask, SwitchAccountAssets):
         """
         logger.info("start switch_character")
         # 改成对比是否出现 已有角色 
-        self.ui_click(self.C_SA_LOGIN_FORM_SWITCH_SVR_BTN, self.O_SA_CHECK_SELCET_SVR)
+        self.ui_click(self.C_SA_LOGIN_FORM_SWITCH_SVR_BTN, self.O_SA_CHECK_SELECT_SVR)
         # 展开底部角色列表,显示角色所属服务器
         self.screenshot()
         while (not self.appear(self.I_SA_CHECK_SELECT_SVR_2)) and self.appear(self.I_SA_CHECK_SELECT_SVR_1):

+ 2 - 0
tasks/Component/SwitchSoul/assets.py

@@ -66,6 +66,8 @@ class SwitchSoulAssets:
 	I_SOU_CLICK_PRESENT = RuleImage(roi_front=(978,304,25,26), roi_back=(965,142,48,480), threshold=0.9, method="Template matching", file="./tasks/Component/SwitchSoul/ss/ss_sou_click_present.png")
 	# 误触点到式神检查 
 	I_CHECK_BLOCK = RuleImage(roi_front=(572,408,137,49), roi_back=(572,408,137,49), threshold=0.8, method="Template matching", file="./tasks/Component/SwitchSoul/ss/ss_check_block.png")
+	# 通用进入式神录 
+	I_GOTO_SHIKIGAMI_COMMON = RuleImage(roi_front=(1037,567,36,36), roi_back=(617,503,487,134), threshold=0.8, method="Template matching", file="./tasks/Component/SwitchSoul/ss/ss_goto_shikigami_common.png")
 
 
 	# Ocr Rule Assets

+ 9 - 0
tasks/Component/SwitchSoul/ss/image.json

@@ -160,5 +160,14 @@
     "method": "Template matching",
     "threshold": 0.8,
     "description": "误触点到式神检查"
+  },
+  {
+    "itemName": "goto_shikigami_common",
+    "imageName": "ss_goto_shikigami_common.png",
+    "roiFront": "1037,567,36,36",
+    "roiBack": "617,503,487,134",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "通用进入式神录"
   }
 ]

BIN
tasks/Component/SwitchSoul/ss/ss_goto_shikigami_common.png


+ 30 - 14
tasks/Component/SwitchSoul/switch_soul.py

@@ -8,11 +8,14 @@ from module.atom.click import RuleClick
 from module.atom.long_click import RuleLongClick
 from module.atom.ocr import RuleOcr
 from module.base.timer import Timer
+from module.logger import logger
+
 from tasks.base_task import BaseTask
+from tasks.GameUi.assets import GameUiAssets
 from tasks.Component.GeneralInvite.assets import GeneralInviteAssets
 from tasks.Component.GeneralInvite.config_invite import InviteConfig, InviteNumber, FindMode
 from tasks.Component.SwitchSoul.assets import SwitchSoulAssets
-from module.logger import logger
+
 
 
 def switch_parser(switch_str: str) -> tuple:
@@ -24,6 +27,32 @@ def switch_parser(switch_str: str) -> tuple:
 
 class SwitchSoul(BaseTask, SwitchSoulAssets):
 
+    def goto_shikigami_records(self, button):
+        """
+        进入式神录
+        """
+        while 1:
+            self.screenshot()
+            if self.appear(GameUiAssets.I_CHECK_RECORDS):
+                break
+            if self.appear_then_click(button, interval=1.5):
+                continue
+        logger.info('Entry shikigami records')
+
+    def exit_shikigami_records(self) -> None:
+        """
+        退出式神录的界面
+        :return:
+        """
+        while 1:
+            self.screenshot()
+            if not self.appear(self.I_SOU_CHECK_IN):
+                break
+            if self.appear_then_click(self.I_RECORD_SOUL_BACK, interval=3.5):
+                continue
+        logger.info('Exit shikigami records')
+
+
     def run_switch_soul(self, target: tuple | list[tuple] | str):
         """
         保证在式神录的界面
@@ -153,19 +182,6 @@ class SwitchSoul(BaseTask, SwitchSoulAssets):
             team = int(team)
             self.switch_soul_one(group, team)
 
-    def exit_shikigami_records(self) -> None:
-        """
-        退出式神录的界面
-        :return:
-        """
-        while 1:
-            self.screenshot()
-            if not self.appear(self.I_SOU_CHECK_IN):
-                break
-            if self.appear_then_click(self.I_RECORD_SOUL_BACK, interval=3.5):
-                continue
-        logger.info('Exit shikigami records')
-
     def run_switch_soul_by_name(self, groupName, teamName):
         """
         保证在式神录的界面

+ 157 - 153
tasks/FallenSun/script_task.py

@@ -292,7 +292,9 @@ class ScriptTask(GeneralBattle, GeneralInvite, GeneralBuff, GeneralRoom, GameUi,
             self.screenshot()
             if not self.appear(self.I_FORM_TEAM):
                 break
-            if self.appear_then_click(self.I_BACK_BL, interval=1):
+            if self.appear_then_click(self.I_BACK_BL, interval=2):
+                continue
+            if self.appear_then_click(self.I_UI_BACK_YELLOW, interval=2):
                 continue
 
         self.ui_current = page_soul_zones
@@ -302,159 +304,161 @@ class ScriptTask(GeneralBattle, GeneralInvite, GeneralBuff, GeneralRoom, GameUi,
         logger.error('Wild mode is not implemented')
         pass
 
+    # def battle_wait(self, random_click_swipt_enable: bool) -> bool:
+    #     """
+    #     重写战斗等待
+    #     # https://github.com/runhey/OnmyojiAutoScript/issues/95
+    #     :param random_click_swipt_enable:
+    #     :return:
+    #     """
+    #     """
+    #     # 重写
+    #     self.device.stuck_record_add('BATTLE_STATUS_S')
+    #     self.device.click_record_clear()
+    #     self.C_REWARD_1.name = 'C_REWARD'
+    #     self.C_REWARD_2.name = 'C_REWARD'
+    #     self.C_REWARD_3.name = 'C_REWARD'
+    #     # 战斗过程 随机点击和滑动 防封
+    #     logger.info("Start battle process")
+    #     while 1:
+    #         self.screenshot()
+    #         action_click = random.choice([self.C_WIN_1, self.C_WIN_2, self.C_WIN_3])
+    #         if self.appear_then_click(self.I_WIN, action=action_click ,interval=0.8):
+    #             # 赢的那个鼓
+    #             continue
+    #         if self.appear(self.I_GREED_GHOST):
+    #             # 贪吃鬼
+    #             logger.info('Win battle')
+    #             self.wait_until_appear(self.I_REWARD, wait_time=1.5)
+    #             self.screenshot()
+    #             if not self.appear(self.I_GREED_GHOST):
+    #                 logger.warning('Greedy ghost disappear. Maybe it is a false battle')
+    #                 continue
+    #             while 1:
+    #                 self.screenshot()
+    #                 action_click = random.choice([self.C_REWARD_1, self.C_REWARD_2, self.C_REWARD_3])
+    #                 if not self.appear(self.I_GREED_GHOST):
+    #                     break
+    #                 if self.click(action_click, interval=1.5):
+    #                     continue
+    #             return True
+    #         if self.appear(self.I_REWARD):
+    #             # 魂
+    #             logger.info('Win battle')
+    #             while 1:
+    #                 self.screenshot()
+    #                 action_click = random.choice([self.C_REWARD_1, self.C_REWARD_2, self.C_REWARD_3])
+    #                 if self.appear_then_click(self.I_REWARD, action=action_click, interval=1.5):
+    #                     continue
+    #                 if not self.appear(self.I_REWARD):
+    #                     break
+    #             return True
+    #
+    #         if self.appear(self.I_FALSE):
+    #             logger.warning('False battle')
+    #             self.ui_click_until_disappear(self.I_FALSE)
+    #             return False
+    #
+    #         # 如果开启战斗过程随机滑动
+    #         if random_click_swipt_enable:
+    #             self.random_click_swipt()
+    #             """
+    #     """
+    #     等待战斗结束 !!!
+    #     很重要 这个函数是原先写的, 优化版本在tasks/Secret/script_task下。本着不改动原先的代码的原则,所以就不改了
+    #     :param random_click_swipt_enable:
+    #     :return:
+    #     """
+    #     # 有的时候是长战斗,需要在设置stuck检测为长战斗
+    #     # 但是无需取消设置,因为如果有点击或者滑动的话 handle_control_check会自行取消掉
+    #     self.device.stuck_record_add('BATTLE_STATUS_S')
+    #     self.device.click_record_clear()
+    #     # 战斗过程 随机点击和滑动 防封
+    #     logger.info("Start battle process")
+    #     win: bool = False
+    #     while 1:
+    #         self.screenshot()
+    #         # 如果出现赢 就点击, 第二个是针对封魔的图片
+    #         if self.appear(self.I_WIN, threshold=0.8) or self.appear(self.I_DE_WIN):
+    #             logger.info("Battle result is win")
+    #             if self.appear(self.I_DE_WIN):
+    #                 self.ui_click_until_disappear(self.I_DE_WIN)
+    #             win = True
+    #             break
+    #
+    #         # 如果出现失败 就点击,返回False
+    #         if self.appear(self.I_FALSE, threshold=0.8):
+    #             logger.info("Battle result is false")
+    #             win = False
+    #             break
+    #
+    #         # 如果领奖励
+    #         if self.appear(self.I_REWARD, threshold=0.6):
+    #             win = True
+    #             break
+    #
+    #         # 如果领奖励出现金币
+    #         if self.appear(self.I_REWARD_GOLD, threshold=0.8):
+    #             win = True
+    #             break
+    #         if self.appear(self.I_REWARD_PURPLE_SNAKE_SKIN, threshold=0.8):
+    #             win = True
+    #             break
+    #         # 如果开启战斗过程随机滑动
+    #         if random_click_swipt_enable:
+    #             self.random_click_swipt()
+    #
+    #     # 再次确认战斗结果
+    #     logger.info("Reconfirm the results of the battle")
+    #     while 1:
+    #         self.screenshot()
+    #         if win:
+    #             # 点击赢了
+    #             action_click = random.choice([self.C_WIN_1, self.C_WIN_2, self.C_WIN_3])
+    #             if self.appear_then_click(self.I_WIN, action=action_click, interval=0.5):
+    #                 continue
+    #             if not self.appear(self.I_WIN):
+    #                 break
+    #         else:
+    #             # 如果失败且 点击失败后
+    #             if self.appear_then_click(self.I_FALSE, threshold=0.6):
+    #                 continue
+    #             if not self.appear(self.I_FALSE, threshold=0.6):
+    #                 return False
+    #     # 最后保证能点击 获得奖励
+    #     if not self.wait_until_appear(self.I_REWARD):
+    #         # 有些的战斗没有下面的奖励,所以直接返回
+    #         logger.info("There is no reward, Exit battle")
+    #         return win
+    #     logger.info("Get reward")
+    #     while 1:
+    #         self.screenshot()
+    #         # 如果出现领奖励
+    #         action_click = random.choice([self.C_REWARD_1, self.C_REWARD_2, self.C_REWARD_3])
+    #         if (self.appear_then_click(self.I_REWARD, action=action_click, interval=1.5) or
+    #             self.appear_then_click(self.I_REWARD_GOLD, action=action_click, interval=1.5)  or
+    #             # self.appear_then_click(self.I_REWARD_STATISTICS, action=action_click, interval=1.5) or
+    #             self.appear_then_click(self.I_REWARD_PURPLE_SNAKE_SKIN, action=action_click, interval=1.5) #or
+    #             # self.appear_then_click(self.I_REWARD_GOLD_SNAKE_SKIN, action=action_click, interval=1.5) or
+    #             # self.appear_then_click(self.I_REWARD_EXP_SOUL_4, action=action_click, interval=1.5) or
+    #             # self.appear_then_click(self.I_REWARD_SOUL_5, action=action_click, interval=1.5) or
+    #             # self.appear_then_click(self.I_REWARD_SOUL_6, action=action_click, interval=1.5)
+    #             ):
+    #             continue
+    #         if (not self.appear(self.I_REWARD) and
+    #             not self.appear(self.I_REWARD_GOLD)  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_GOLD_SNAKE_SKIN) and
+    #             # not self.appear(self.I_REWARD_EXP_SOUL_4) and
+    #             # not self.appear(self.I_REWARD_SOUL_5) and
+    #             # not self.appear(self.I_REWARD_SOUL_6)
+    #             ):
+    #             break
+    #
+    #     return win
     def battle_wait(self, random_click_swipt_enable: bool) -> bool:
-        """
-        重写战斗等待
-        # https://github.com/runhey/OnmyojiAutoScript/issues/95
-        :param random_click_swipt_enable:
-        :return:
-        """
-        """
-        # 重写
-        self.device.stuck_record_add('BATTLE_STATUS_S')
-        self.device.click_record_clear()
-        self.C_REWARD_1.name = 'C_REWARD'
-        self.C_REWARD_2.name = 'C_REWARD'
-        self.C_REWARD_3.name = 'C_REWARD'
-        # 战斗过程 随机点击和滑动 防封
-        logger.info("Start battle process")
-        while 1:
-            self.screenshot()
-            action_click = random.choice([self.C_WIN_1, self.C_WIN_2, self.C_WIN_3])
-            if self.appear_then_click(self.I_WIN, action=action_click ,interval=0.8):
-                # 赢的那个鼓
-                continue
-            if self.appear(self.I_GREED_GHOST):
-                # 贪吃鬼
-                logger.info('Win battle')
-                self.wait_until_appear(self.I_REWARD, wait_time=1.5)
-                self.screenshot()
-                if not self.appear(self.I_GREED_GHOST):
-                    logger.warning('Greedy ghost disappear. Maybe it is a false battle')
-                    continue
-                while 1:
-                    self.screenshot()
-                    action_click = random.choice([self.C_REWARD_1, self.C_REWARD_2, self.C_REWARD_3])
-                    if not self.appear(self.I_GREED_GHOST):
-                        break
-                    if self.click(action_click, interval=1.5):
-                        continue
-                return True
-            if self.appear(self.I_REWARD):
-                # 魂
-                logger.info('Win battle')
-                while 1:
-                    self.screenshot()
-                    action_click = random.choice([self.C_REWARD_1, self.C_REWARD_2, self.C_REWARD_3])
-                    if self.appear_then_click(self.I_REWARD, action=action_click, interval=1.5):
-                        continue
-                    if not self.appear(self.I_REWARD):
-                        break
-                return True
-
-            if self.appear(self.I_FALSE):
-                logger.warning('False battle')
-                self.ui_click_until_disappear(self.I_FALSE)
-                return False
-
-            # 如果开启战斗过程随机滑动
-            if random_click_swipt_enable:
-                self.random_click_swipt()
-                """
-        """
-        等待战斗结束 !!!
-        很重要 这个函数是原先写的, 优化版本在tasks/Secret/script_task下。本着不改动原先的代码的原则,所以就不改了
-        :param random_click_swipt_enable:
-        :return:
-        """
-        # 有的时候是长战斗,需要在设置stuck检测为长战斗
-        # 但是无需取消设置,因为如果有点击或者滑动的话 handle_control_check会自行取消掉
-        self.device.stuck_record_add('BATTLE_STATUS_S')
-        self.device.click_record_clear()
-        # 战斗过程 随机点击和滑动 防封
-        logger.info("Start battle process")
-        win: bool = False
-        while 1:
-            self.screenshot()
-            # 如果出现赢 就点击, 第二个是针对封魔的图片
-            if self.appear(self.I_WIN, threshold=0.8) or self.appear(self.I_DE_WIN):
-                logger.info("Battle result is win")
-                if self.appear(self.I_DE_WIN):
-                    self.ui_click_until_disappear(self.I_DE_WIN)
-                win = True
-                break
-
-            # 如果出现失败 就点击,返回False
-            if self.appear(self.I_FALSE, threshold=0.8):
-                logger.info("Battle result is false")
-                win = False
-                break
-
-            # 如果领奖励
-            if self.appear(self.I_REWARD, threshold=0.6):
-                win = True
-                break
-
-            # 如果领奖励出现金币
-            if self.appear(self.I_REWARD_GOLD, threshold=0.8):
-                win = True
-                break
-            if self.appear(self.I_REWARD_PURPLE_SNAKE_SKIN, threshold=0.8):
-                win = True
-                break
-            # 如果开启战斗过程随机滑动
-            if random_click_swipt_enable:
-                self.random_click_swipt()
-
-        # 再次确认战斗结果
-        logger.info("Reconfirm the results of the battle")
-        while 1:
-            self.screenshot()
-            if win:
-                # 点击赢了
-                action_click = random.choice([self.C_WIN_1, self.C_WIN_2, self.C_WIN_3])
-                if self.appear_then_click(self.I_WIN, action=action_click, interval=0.5):
-                    continue
-                if not self.appear(self.I_WIN):
-                    break
-            else:
-                # 如果失败且 点击失败后
-                if self.appear_then_click(self.I_FALSE, threshold=0.6):
-                    continue
-                if not self.appear(self.I_FALSE, threshold=0.6):
-                    return False
-        # 最后保证能点击 获得奖励
-        if not self.wait_until_appear(self.I_REWARD):
-            # 有些的战斗没有下面的奖励,所以直接返回
-            logger.info("There is no reward, Exit battle")
-            return win
-        logger.info("Get reward")
-        while 1:
-            self.screenshot()
-            # 如果出现领奖励
-            action_click = random.choice([self.C_REWARD_1, self.C_REWARD_2, self.C_REWARD_3])
-            if (self.appear_then_click(self.I_REWARD, action=action_click, interval=1.5) or
-                self.appear_then_click(self.I_REWARD_GOLD, action=action_click, interval=1.5)  or
-                # self.appear_then_click(self.I_REWARD_STATISTICS, action=action_click, interval=1.5) or
-                self.appear_then_click(self.I_REWARD_PURPLE_SNAKE_SKIN, action=action_click, interval=1.5) #or
-                # self.appear_then_click(self.I_REWARD_GOLD_SNAKE_SKIN, action=action_click, interval=1.5) or
-                # self.appear_then_click(self.I_REWARD_EXP_SOUL_4, action=action_click, interval=1.5) or
-                # self.appear_then_click(self.I_REWARD_SOUL_5, action=action_click, interval=1.5) or
-                # self.appear_then_click(self.I_REWARD_SOUL_6, action=action_click, interval=1.5)
-                ):
-                continue
-            if (not self.appear(self.I_REWARD) and
-                not self.appear(self.I_REWARD_GOLD)  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_GOLD_SNAKE_SKIN) and
-                # not self.appear(self.I_REWARD_EXP_SOUL_4) and
-                # not self.appear(self.I_REWARD_SOUL_5) and
-                # not self.appear(self.I_REWARD_SOUL_6)
-                ):
-                break
-
-        return win
+        return self.battle_wait_v2(random_click_swipt_enable=random_click_swipt_enable)
 
 
 if __name__ == '__main__':

+ 7 - 0
tasks/HeroTest/script_task.py

@@ -170,8 +170,15 @@ class ScriptTask(GameUi, GeneralBattle, HeroTestAssets, SwitchSoul):
             SkillMode.PVP: pvp_skill,
         }
         target_skills = target_skill_dict[self.conf.herotest.skill_mode]
+        timer = Timer(10).start()
         while True:
             self.screenshot()
+            if timer.reached_and_reset():
+                if self.appear(self.I_BCMJ_SKILL_ADD_CONFIRM):
+                    logger.warning('No skill selected for 10s, panel still open, retrying')
+                    continue
+                logger.warning('Skill selection panel closed unexpectedly, exit')
+                break
             if any(self.appear_then_click(ts, interval=1) for ts in target_skills):
                 break
         self.ui_click_until_disappear(self.I_BCMJ_SKILL_ADD_CONFIRM, interval=1.5)

+ 2 - 0
tasks/Orochi/config.py

@@ -45,6 +45,8 @@ class OrochiConfig(ConfigBase):
     limit_count: int = Field(default=30, description='limit_count_help')
     # 是否开启御魂加成
     soul_buff_enable: bool = Field(default=False, description='soul_buff_enable_help')
+    # 是否御魂结束检测是否出现真蛇
+    check_true_orochi_enable: bool = Field(default=False, description='check_true_orochi_enable_help')
 
 class SwitchSoulConfig(BaseSwitchSoulConfig):
     enable: bool = Field(default=False)

+ 12 - 1
tasks/Orochi/script_task.py

@@ -14,11 +14,12 @@ from tasks.GameUi.game_ui import GameUi
 from tasks.GameUi.page import page_main, page_soul_zones, page_shikigami_records
 from tasks.Orochi.assets import OrochiAssets
 from tasks.Orochi.config import Orochi, UserStatus, Layer
+from tasks.TrueOrochi.assets import TrueOrochiAssets
 from module.logger import logger
 from module.exception import TaskEnd
 
 
-class ScriptTask(GeneralBattle, GeneralInvite, GeneralBuff, GeneralRoom, GameUi, SwitchSoul, OrochiAssets):
+class ScriptTask(GeneralBattle, GeneralInvite, GeneralBuff, GeneralRoom, GameUi, SwitchSoul, OrochiAssets, TrueOrochiAssets):
 
     def run(self) -> bool:
         # 御魂切换方式一
@@ -59,6 +60,16 @@ class ScriptTask(GeneralBattle, GeneralInvite, GeneralBuff, GeneralRoom, GameUi,
             case UserStatus.WILD: success = self.run_wild()
             case _: logger.error('Unknown user status')
 
+        # 御魂结束后检测是否出现真蛇
+        if config.orochi_config.check_true_orochi_enable:
+            self.ui_get_current_page()
+            self.ui_goto(page_soul_zones)
+            self.orochi_enter()
+            self.screenshot()
+            if self.appear(self.I_FIND_TS):
+                logger.info('Find true orochi after orochi battle, set TrueOrochi task to run now')
+                self.set_next_run(task='TrueOrochi', success=False, finish=False, server=False, target=datetime.now())
+        self.ui_goto(page_main)
         # 记得关掉
         if config.orochi_config.soul_buff_enable:
             self.open_buff()

+ 15 - 3
tasks/RichMan/assets.py

@@ -282,7 +282,7 @@ class RichManAssets:
 	# description 
 	I_SCA_SELECT_3 = RuleImage(roi_front=(972,517,123,50), roi_back=(972,517,123,50), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/scales/scales_sca_select_3.png")
 	# 获得的六星 
-	I_SCA_SIX_STAR = RuleImage(roi_front=(120,216,97,22), roi_back=(113,102,1057,157), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/scales/scales_sca_six_star.png")
+	I_SCA_SIX_STAR = RuleImage(roi_front=(120,216,97,22), roi_back=(113,102,1056,257), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/scales/scales_sca_six_star.png")
 	# 点击屏幕继续 
 	I_SCA_REWARD = RuleImage(roi_front=(584,503,100,100), roi_back=(584,503,100,100), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/scales/scales_sca_reward.png")
 	# 点击兑换 
@@ -297,7 +297,7 @@ class RichManAssets:
 	# 首领御魂剩余可买的 
 	O_SCA_NUMBER_DEMON = RuleOcr(roi=(627,319,30,25), area=(627,319,30,25), mode="Quantity", method="Default", keyword="", name="sca_number_demon")
 	# 永生之海 
-	O_SCA_NUMBER_SEA = RuleOcr(roi=(926,321,30,23), area=(926,321,30,23), mode="Quantity", method="Default", keyword="", name="sca_number_sea")
+	O_SCA_NUMBER_SEA = RuleOcr(roi=(920,320,36,22), area=(920,320,36,22), mode="Quantity", method="Default", keyword="", name="sca_number_sea")
 	# 多少号位 
 	O_SCA_DEMON_POSTION = RuleOcr(roi=(960,244,88,41), area=(960,244,88,41), mode="Single", method="Default", keyword="", name="sca_demon_postion")
 	# 朴素的御魂 
@@ -305,7 +305,7 @@ class RichManAssets:
 	# 首领御魂数量 
 	O_SCA_RES_DEMON = RuleOcr(roi=(968,11,102,35), area=(968,11,102,35), mode="Digit", method="Default", keyword="", name="sca_res_demon")
 	# 永生之海 
-	O_SCA_RES_SEA = RuleOcr(roi=(1136,11,88,38), area=(1136,11,88,38), mode="Digit", method="Default", keyword="", name="sca_res_sea")
+	O_SCA_RES_SEA = RuleOcr(roi=(1134,11,100,38), area=(1134,11,100,38), mode="Digit", method="Default", keyword="", name="sca_res_sea")
 
 
 	# Image Rule Assets
@@ -397,6 +397,18 @@ class RichManAssets:
 	I_TT_BUY_UP = RuleImage(roi_front=(755,427,59,57), roi_back=(740,386,80,146), threshold=0.8, method="Template matching", file="./tasks/RichMan/tt/tt_tt_buy_up.png")
 	# description 
 	I_TT_BUY_CONFIRM = RuleImage(roi_front=(584,512,53,53), roi_back=(553,487,169,115), threshold=0.8, method="Template matching", file="./tasks/RichMan/tt/tt_tt_buy_confirm.png")
+	# 唤妖借处 
+	I_TT_BORROW = RuleImage(roi_front=(1043,262,39,149), roi_back=(960,169,208,309), threshold=0.8, method="Template matching", file="./tasks/RichMan/tt/tt_tt_borrow.png")
+	# 配置式神 
+	I_TT_CONFIGURE = RuleImage(roi_front=(1129,608,42,44), roi_back=(1036,523,240,197), threshold=0.8, method="Template matching", file="./tasks/RichMan/tt/tt_tt_configure.png")
+	# 确认配置 
+	I_TT_CONFIRM = RuleImage(roi_front=(1129,608,42,44), roi_back=(1036,523,240,197), threshold=0.8, method="Template matching", file="./tasks/RichMan/tt/tt_tt_confirm.png")
+	# 选择式神(第四个) 
+	I_TT_SHIKIGAMI = RuleImage(roi_front=(682,257,15,14), roi_back=(652,221,151,148), threshold=0.7, method="Template matching", file="./tasks/RichMan/tt/tt_tt_shikigami.png")
+	# 替换式神 
+	I_TT_SHIKIGAMI_REPLACE = RuleImage(roi_front=(755,641,57,19), roi_back=(703,580,148,134), threshold=0.7, method="Template matching", file="./tasks/RichMan/tt/tt_tt_shikigami_replace.png")
+	# 借出确认 
+	I_TT_BORROW_CONFIRM = RuleImage(roi_front=(960,508,50,53), roi_back=(886,444,222,194), threshold=0.8, method="Template matching", file="./tasks/RichMan/tt/tt_tt_borrow_confirm.png")
 
 
 	# Ocr Rule Assets

+ 2 - 0
tasks/RichMan/config.py

@@ -12,6 +12,7 @@ from tasks.Utils.config_enum import DemonClass
 class ThousandThings(BaseModel):
     # 千物宝箱
     enable: bool = Field(title='Enable', default=False)
+    earn_money: bool = Field(title='Earn Money', default=False, description='earn_money_help')
     mystery_amulet: bool = Field(title='Mystery Amulet', default=False)
     black_daruma_fragment: bool = Field(title='Black Daruma Fragment', default=False)
     ap: bool = Field(title='AP', default=False, description='ap_help')
@@ -29,6 +30,7 @@ class Scales(BaseModel):
     demon_class: DemonClass = Field(title='DemonClass', default=DemonClass.TSUCHIGUMO, description='demon_class_help')
     demon_position: int = Field(title='Demon Position', default=1, description='demon_position_help')
     picture_book_scrap: int = Field(title='Picture Book Scrap', default=30, description='picture_book_scrap_help')
+    enable_book_auto: bool = Field(title='Enable Book Auto', default=False, description='enable_book_auto_help')
     picture_book_rule: str = Field(title='Picture Book Rule', default='auto', description='picture_book_rule_help')
 
 

+ 8 - 2
tasks/RichMan/mall/scales.py

@@ -340,10 +340,16 @@ class Scales(Buy, MallNavbar):
             buy_res_number = buy_number
         if buy_cycles_number:
             for i in range(buy_cycles_number):
-                self._scales_buy_sea_more(self.I_SCA_PICTURE_BOOK)
+                if self.config.rich_man.scales.enable_book_auto:
+                    self._scales_buy_more(self.I_SCA_PICTURE_BOOK)
+                else:
+                    self._scales_buy_sea_more(self.I_SCA_PICTURE_BOOK)
                 time.sleep(0.5)
         if buy_res_number and buy_res_number >= 2:
-            self._scales_buy_sea_more(self.I_SCA_PICTURE_BOOK, buy_res_number)
+            if self.config.rich_man.scales.enable_book_auto:
+                self._scales_buy_more(self.I_SCA_PICTURE_BOOK, buy_res_number)
+            else:
+                self._scales_buy_sea_more(self.I_SCA_PICTURE_BOOK, buy_res_number)
             time.sleep(0.5)
 
 

+ 1 - 1
tasks/RichMan/mall/scales/image.json

@@ -111,7 +111,7 @@
     "itemName": "sca_six_star",
     "imageName": "scales_sca_six_star.png",
     "roiFront": "120,216,97,22",
-    "roiBack": "113,102,1057,157",
+    "roiBack": "113,102,1056,257",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "获得的六星"

+ 4 - 4
tasks/RichMan/mall/scales/ocr.json

@@ -19,8 +19,8 @@
   },
   {
     "itemName": "sca_number_sea",
-    "roiFront": "926,321,30,23",
-    "roiBack": "926,321,30,23",
+    "roiFront": "920,320,36,22",
+    "roiBack": "920,320,36,22",
     "mode": "Quantity",
     "method": "Default",
     "keyword": "",
@@ -55,8 +55,8 @@
   },
   {
     "itemName": "sca_res_sea",
-    "roiFront": "1136,11,88,38",
-    "roiBack": "1136,11,88,38",
+    "roiFront": "1134,11,100,38",
+    "roiBack": "1134,11,100,38",
     "mode": "Digit",
     "method": "Default",
     "keyword": "",

BIN
tasks/RichMan/mall/scales/scales_sca_picture_book.png


+ 27 - 0
tasks/RichMan/thousand_things.py

@@ -25,6 +25,10 @@ class ThousandThings(GameUi, RichManAssets):
         self.ui_get_current_page()
         self.ui_goto(page_travel)
 
+        if con.earn_money:
+            logger.info('Start Earn Money')
+            self.tt_earn_money()
+
         while 1:
             self.screenshot()
             if self.appear(self.I_TT_CHECK):
@@ -167,6 +171,29 @@ class ThousandThings(GameUi, RichManAssets):
                 continue
         return True
 
+    def tt_earn_money(self):
+
+        # 进入界面
+        self.ui_click(self.I_TT_BORROW, self.I_TT_CONFIGURE)
+        self.ui_click(self.I_TT_CONFIGURE, self.I_TT_CONFIRM)
+        #替换式神
+        self.ui_click(self.I_TT_SHIKIGAMI, self.I_TT_SHIKIGAMI_REPLACE)
+        while 1:
+            self.screenshot()
+            if not self.appear(self.I_TT_SHIKIGAMI_REPLACE):
+                break
+            if self.appear_then_click(self.I_UI_CONFIRM):
+                continue
+            if self.appear_then_click(self.I_TT_SHIKIGAMI_REPLACE):
+                continue
+        self.ui_click(self.I_TT_CONFIRM, self.I_TT_BORROW_CONFIRM)
+
+        # 获取奖励
+        self.ui_get_reward(self.I_TT_BORROW_CONFIRM)
+
+        # 退出界面
+        self.ui_click(self.I_UI_BACK_RED, self.I_TT_ENTER)
+
 
 if __name__ == '__main__':
     from module.config.config import Config

+ 54 - 0
tasks/RichMan/tt/image.json

@@ -61,5 +61,59 @@
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"
+  },
+  {
+    "itemName": "tt_borrow",
+    "imageName": "tt_tt_borrow.png",
+    "roiFront": "1043,262,39,149",
+    "roiBack": "960,169,208,309",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "唤妖借处"
+  },
+  {
+    "itemName": "tt_configure",
+    "imageName": "tt_tt_configure.png",
+    "roiFront": "1129,608,42,44",
+    "roiBack": "1036,523,240,197",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "配置式神"
+  },
+  {
+    "itemName": "tt_confirm",
+    "imageName": "tt_tt_confirm.png",
+    "roiFront": "1129,608,42,44",
+    "roiBack": "1036,523,240,197",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "确认配置"
+  },
+  {
+    "itemName": "tt_shikigami",
+    "imageName": "tt_tt_shikigami.png",
+    "roiFront": "682,257,15,14",
+    "roiBack": "652,221,151,148",
+    "method": "Template matching",
+    "threshold": 0.7,
+    "description": "选择式神(第四个)"
+  },
+  {
+    "itemName": "tt_shikigami_replace",
+    "imageName": "tt_tt_shikigami_replace.png",
+    "roiFront": "755,641,57,19",
+    "roiBack": "703,580,148,134",
+    "method": "Template matching",
+    "threshold": 0.7,
+    "description": "替换式神"
+  },
+  {
+    "itemName": "tt_borrow_confirm",
+    "imageName": "tt_tt_borrow_confirm.png",
+    "roiFront": "960,508,50,53",
+    "roiBack": "886,444,222,194",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "借出确认"
   }
 ]

BIN
tasks/RichMan/tt/tt_tt_borrow.png


BIN
tasks/RichMan/tt/tt_tt_borrow_confirm.png


BIN
tasks/RichMan/tt/tt_tt_configure.png


BIN
tasks/RichMan/tt/tt_tt_confirm.png


BIN
tasks/RichMan/tt/tt_tt_shikigami.png


BIN
tasks/RichMan/tt/tt_tt_shikigami_replace.png