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

Merge pull request #1116 from runhey/dev

Automated PR 2025.10.02
huangrunheng 1 год назад
Родитель
Сommit
e7cb048ec0
60 измененных файлов с 513 добавлено и 615 удалено
  1. 3 3
      dev_tools/assets_test.py
  2. 26 19
      module/device/platform2/platform_windows.py
  3. 38 30
      module/logger.py
  4. 1 1
      tasks/AbyssShadows/assets.py
  5. 1 1
      tasks/AbyssShadows/res/image.json
  6. 3 3
      tasks/ActivityShikigami/config.py
  7. 24 16
      tasks/ActivityShikigami/script_task.py
  8. 15 9
      tasks/BondlingFairyland/assets.py
  9. BIN
      tasks/BondlingFairyland/ball/ball_ball_fire.png
  10. 25 4
      tasks/BondlingFairyland/battle.py
  11. BIN
      tasks/BondlingFairyland/capture/battle_fail.png
  12. BIN
      tasks/BondlingFairyland/capture/battle_fail_abandon.png
  13. BIN
      tasks/BondlingFairyland/capture/battle_success.png
  14. 27 0
      tasks/BondlingFairyland/capture/capture.json
  15. 4 4
      tasks/BondlingFairyland/click.json
  16. 15 8
      tasks/BondlingFairyland/config.py
  17. 3 147
      tasks/BondlingFairyland/general_invite.py
  18. 10 10
      tasks/BondlingFairyland/ocr.json
  19. 136 251
      tasks/BondlingFairyland/script_task.py
  20. 2 0
      tasks/Component/GeneralInvite/assets.py
  21. 9 0
      tasks/Component/GeneralInvite/gi/image.json
  22. 4 2
      tasks/Component/ReplaceShikigami/assets.py
  23. 11 2
      tasks/Component/ReplaceShikigami/rs/image.json
  24. BIN
      tasks/Component/ReplaceShikigami/rs/rs_rs_smart_exchange.png
  25. 2 0
      tasks/Component/RightActivity/assets.py
  26. BIN
      tasks/Component/RightActivity/ra/as_toggle_button.png
  27. 9 0
      tasks/Component/RightActivity/ra/image.json
  28. 2 1
      tasks/Component/RightActivity/right_activity.py
  29. 2 1
      tasks/Component/SwitchSoul/switch_soul.py
  30. BIN
      tasks/DemonRetreat/DemonRetreat/DemonRetreat_hunt.png
  31. 1 1
      tasks/DemonRetreat/DemonRetreat/image.json
  32. 1 1
      tasks/DemonRetreat/assets.py
  33. 1 1
      tasks/Dokan/assets.py
  34. 1 1
      tasks/Dokan/res/image.json
  35. 4 2
      tasks/FrogBoss/script_task.py
  36. 1 1
      tasks/GameUi/assets.py
  37. BIN
      tasks/GameUi/page/page_check_main.png
  38. 1 1
      tasks/GameUi/page/page_img.json
  39. 9 7
      tasks/Hyakkiyakou/assets.py
  40. BIN
      tasks/Hyakkiyakou/hya/hya_friend_remote_1.png
  41. BIN
      tasks/Hyakkiyakou/hya/hya_friend_remote_2.png
  42. BIN
      tasks/Hyakkiyakou/hya/hya_friend_ryou_1.png
  43. BIN
      tasks/Hyakkiyakou/hya/hya_friend_ryou_2.png
  44. BIN
      tasks/Hyakkiyakou/hya/hya_friend_same_1.png
  45. BIN
      tasks/Hyakkiyakou/hya/hya_friend_same_2.png
  46. 22 13
      tasks/Hyakkiyakou/hya/image5.json
  47. 1 1
      tasks/Hyakkiyakou/script_task.py
  48. 41 27
      tasks/Hyakkiyakou/slave/hya_slave.py
  49. 1 0
      tasks/KekkaiActivation/config.py
  50. 9 5
      tasks/KekkaiActivation/script_task.py
  51. 2 1
      tasks/Restart/config_scheduler.py
  52. 1 1
      tasks/RichMan/assets.py
  53. 1 1
      tasks/RichMan/guild/image.json
  54. 1 1
      tasks/SoulsTidy/assets.py
  55. 9 4
      tasks/SoulsTidy/script_task.py
  56. 2 2
      tasks/SoulsTidy/simple/image.json
  57. BIN
      tasks/SoulsTidy/simple/simple_st_abandoned_selected.png
  58. 12 12
      tasks/WantedQuests/assets.py
  59. 16 16
      tasks/WantedQuests/ocr.json
  60. 4 4
      tasks/WantedQuests/wq/image.json

+ 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\wechat_2025-09-11_130558_801.png"
+IMAGE_FILE = r"C:\Users\Neptine\Desktop\495446880-0f88defd-4d78-45c4-b745-6a7118b40f29.png"
 if __name__ == '__main__':
 if __name__ == '__main__':
-    from tasks.Exploration.script_task import ScriptTask
-    targe = ScriptTask.I_ADD_2
+    from tasks.KekkaiActivation.script_task import ScriptTask
+    targe = ScriptTask.I_RS_RECORDS_SHIKI
     print(detect_image(IMAGE_FILE, targe))
     print(detect_image(IMAGE_FILE, targe))
 
 
     # ocr demo
     # ocr demo

+ 26 - 19
module/device/platform2/platform_windows.py

@@ -289,7 +289,7 @@ class PlatformWindows(PlatformBase, EmulatorManager):
         """
         """
         Returns:
         Returns:
             bool: True if startup completed
             bool: True if startup completed
-                False if timeout
+                False if timeout, unexpected stop, adb preemptive
         """
         """
         logger.hr('Emulator start', level=2)
         logger.hr('Emulator start', level=2)
         current_window = get_focused_window()
         current_window = get_focused_window()
@@ -322,7 +322,7 @@ class PlatformWindows(PlatformBase, EmulatorManager):
             logger.info(f'Found azurlane packages: {m}')
             logger.info(f'Found azurlane packages: {m}')
 
 
         interval = Timer(1).start()
         interval = Timer(1).start()
-        timeout = Timer(180).start()
+        timeout = Timer(120).start()
         struct_window = Timer(10)
         struct_window = Timer(10)
         new_window = 0
         new_window = 0
         while 1:
         while 1:
@@ -341,23 +341,28 @@ class PlatformWindows(PlatformBase, EmulatorManager):
                     set_focus_window(current_window)
                     set_focus_window(current_window)
                 else:
                 else:
                     new_window = 0
                     new_window = 0
-
-            # Check device connection
-            devices = self.list_device().select(serial=serial)
-            # logger.info(devices)
-            if devices:
-                device: AdbDeviceWithStatus = devices.first_or_none()
-                if device.status == 'device':
-                    # Emulator online
-                    pass
-                if device.status == 'offline':
-                    self.adb_client.disconnect(serial)
+            try:
+                logger.info('Try to connect emulator, please waiting......')
+                # Check device connection
+                devices = self.list_device().select(serial=serial)
+                # logger.info(devices)
+                if devices:
+                    device: AdbDeviceWithStatus = devices.first_or_none()
+                    if device.status == 'device':
+                        # Emulator online
+                        pass
+                    if device.status == 'offline':
+                        self.adb_client.disconnect(serial)
+                        adb_connect()
+                        continue
+                else:
+                    # Try to connect
                     adb_connect()
                     adb_connect()
                     continue
                     continue
-            else:
-                # Try to connect
-                adb_connect()
-                continue
+            except Exception as e:
+                logger.warning(f'Error during adb_connect in watch loop: {e}')
+                return False
+
             show_online(devices.first_or_none())
             show_online(devices.first_or_none())
 
 
             # Check command availability
             # Check command availability
@@ -419,8 +424,10 @@ class PlatformWindows(PlatformBase, EmulatorManager):
             # Start
             # Start
             if self._emulator_function_wrapper(self._emulator_start):
             if self._emulator_function_wrapper(self._emulator_start):
                 # Success
                 # Success
-                self.emulator_start_watch()
-                return True
+                if self.emulator_start_watch():
+                    return True
+                # Failed to connect or start, try again
+                continue
             else:
             else:
                 # Failed to start, stop and start again
                 # Failed to start, stop and start again
                 if self._emulator_function_wrapper(self._emulator_stop):
                 if self._emulator_function_wrapper(self._emulator_stop):

+ 38 - 30
module/logger.py

@@ -1,46 +1,55 @@
 # This Python file uses the following encoding: utf-8
 # This Python file uses the following encoding: utf-8
 # @author runhey
 # @author runhey
 # github https://github.com/runhey
 # github https://github.com/runhey
-import datetime
-import logging
-import os
 import sys
 import sys
-import traceback
 
 
+import logging
+import os
+import shutil
+from datetime import datetime, timedelta, date
 from io import TextIOBase
 from io import TextIOBase
-from typing import Callable, List
-
+from pathlib import Path
 from rich.console import Console, ConsoleOptions, ConsoleRenderable, NewLine, RenderResult
 from rich.console import Console, ConsoleOptions, ConsoleRenderable, NewLine, RenderResult
-from rich.highlighter import RegexHighlighter, NullHighlighter
+from rich.highlighter import NullHighlighter
 from rich.logging import RichHandler
 from rich.logging import RichHandler
-from rich.text import Text
 from rich.rule import Rule
 from rich.rule import Rule
-from rich.style import Style
-from rich.theme import Theme
-from rich.traceback import Traceback
-
-import time
-from pathlib import Path
+from typing import Callable, List
 
 
-SECONDS_IN_DAY = 24 * 60 * 60
 
 
 def cleanup_logs(log_dir: str = "./log", keep_days: int = 7):
 def cleanup_logs(log_dir: str = "./log", keep_days: int = 7):
-    """删除 log_dir 下所有早于 keep_days 的普通文件"""
-    cutoff_ts = time.time() - keep_days * SECONDS_IN_DAY
-
+    """删除 log_dir 下所有早于 keep_days 的文件夹和文件"""
     log_path = Path(log_dir)
     log_path = Path(log_dir)
     if not log_path.exists():
     if not log_path.exists():
         return  # 目录都没有,直接退出
         return  # 目录都没有,直接退出
-
-    for p in log_path.iterdir():
-        # 只处理文件;子文件夹一律跳过
-        if p.is_file():
+    keep_days_ago_ts = (datetime.now() - timedelta(days=keep_days)).timestamp()
+    for name in os.listdir(log_path):
+        full_path = os.path.join(log_path, name)
+        # 忽略软链接,仅处理文件和目录
+        if not os.path.exists(full_path):
+            continue
+        if os.path.isfile(full_path):
+            # 处理 log 根目录下超过keep_days的文件
             try:
             try:
-                if p.stat().st_mtime < cutoff_ts:
-                    p.unlink()
-                    logger.info(f"Removed old log finish: {p.name}")
-            except Exception as e:
-                logger.warning(f"Failed to delete {p}: {e}")
+                if os.path.getmtime(full_path) < keep_days_ago_ts:
+                    os.remove(full_path)
+            except OSError as e:
+                logger.error(f"delete file '{full_path}' error: {e}")
+        elif os.path.isdir(full_path):
+            # 检查是否为 error 目录
+            if name != 'error':
+                continue
+            for error_dir_name in os.listdir(full_path):
+                error_dir_path = os.path.join(full_path, error_dir_name)
+                if not os.path.isdir(error_dir_path):
+                    continue
+                # 处理 log/error 根目录下超过keep_days的文件夹
+                try:
+                    if os.path.getmtime(error_dir_path) < keep_days_ago_ts:
+                        # 递归删除整个目录及其内容
+                        shutil.rmtree(error_dir_path)
+                except OSError as e:
+                    logger.error(f"delete dir '{error_dir_path}' error: {e}")
+
 
 
 def empty_function(*args, **kwargs):
 def empty_function(*args, **kwargs):
     pass
     pass
@@ -123,7 +132,7 @@ pyw_name = os.path.splitext(os.path.basename(sys.argv[0]))[0]
 def set_file_logger(name=pyw_name, *, do_cleanup=False):
 def set_file_logger(name=pyw_name, *, do_cleanup=False):
     if '_' in name:
     if '_' in name:
         name = name.split('_', 1)[0]
         name = name.split('_', 1)[0]
-    log_file = f'./log/{datetime.date.today()}_{name}.txt'
+    log_file = f'./log/{date.today()}_{name}.txt'
     try:
     try:
         file = open(log_file, mode='a', encoding='utf-8')
         file = open(log_file, mode='a', encoding='utf-8')
     except FileNotFoundError:
     except FileNotFoundError:
@@ -158,8 +167,7 @@ def set_file_logger(name=pyw_name, *, do_cleanup=False):
     # ---------- 可选:清理旧文件 ----------
     # ---------- 可选:清理旧文件 ----------
     if do_cleanup:
     if do_cleanup:
         cleanup_logs()
         cleanup_logs()
-    if do_cleanup:
-        logger.info("Log cleanup finished")   
+        logger.info("Log cleanup finished")
 
 
 
 
 # ======================================================================================================================
 # ======================================================================================================================

+ 1 - 1
tasks/AbyssShadows/assets.py

@@ -61,7 +61,7 @@ class AbyssShadowsAssets:
 	# 式神录 
 	# 式神录 
 	I_ABYSS_SHIKI = RuleImage(roi_front=(1199,462,47,53), roi_back=(1199,462,47,53), threshold=0.8, method="Template matching", file="./tasks/AbyssShadows/res/res_abyss_shiki.png")
 	I_ABYSS_SHIKI = RuleImage(roi_front=(1199,462,47,53), roi_back=(1199,462,47,53), threshold=0.8, method="Template matching", file="./tasks/AbyssShadows/res/res_abyss_shiki.png")
 	# 狭间暗域 
 	# 狭间暗域 
-	I_ABYSS_SHADOWS = RuleImage(roi_front=(711,489,107,38), roi_back=(711,489,107,38), threshold=0.8, method="Template matching", file="./tasks/AbyssShadows/res/res_abyss_shadows.png")
+	I_ABYSS_SHADOWS = RuleImage(roi_front=(711,489,107,38), roi_back=(711,479,107,48), threshold=0.8, method="Template matching", file="./tasks/AbyssShadows/res/res_abyss_shadows.png")
 	# 开启狭间暗域 
 	# 开启狭间暗域 
 	I_OPEN_ABYSS_SHADOWS = RuleImage(roi_front=(1133,602,74,58), roi_back=(1133,602,74,58), threshold=0.8, method="Template matching", file="./tasks/AbyssShadows/res/res_open_abyss_shadows.png")
 	I_OPEN_ABYSS_SHADOWS = RuleImage(roi_front=(1133,602,74,58), roi_back=(1133,602,74,58), threshold=0.8, method="Template matching", file="./tasks/AbyssShadows/res/res_open_abyss_shadows.png")
 	# 战报页面 
 	# 战报页面 

+ 1 - 1
tasks/AbyssShadows/res/image.json

@@ -75,7 +75,7 @@
     "itemName": "abyss_shadows",
     "itemName": "abyss_shadows",
     "imageName": "res_abyss_shadows.png",
     "imageName": "res_abyss_shadows.png",
     "roiFront": "711,489,107,38",
     "roiFront": "711,489,107,38",
-    "roiBack": "711,489,107,38",
+    "roiBack": "711,479,107,48",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "狭间暗域"
     "description": "狭间暗域"

+ 3 - 3
tasks/ActivityShikigami/config.py

@@ -21,17 +21,17 @@ class ShikigamiType(str, Enum):
 class SwitchSoulConfig(BaseModel):
 class SwitchSoulConfig(BaseModel):
     # 切换门票爬塔御魂
     # 切换门票爬塔御魂
     enable_switch_pass: bool = Field(default=False, description='是否切换门票爬塔御魂')
     enable_switch_pass: bool = Field(default=False, description='是否切换门票爬塔御魂')
-    pass_group_team: str = Field(default='-1,-1', description='组1-7,队伍1-4 中间用英文,分隔。战斗内切换队伍预设使用该值')
+    pass_group_team: str = Field(default='-1,-1', description='组1-7,队伍1-4 中间用英文,分隔。战斗内切换队伍预设也使用该值')
     enable_switch_pass_by_name: bool = Field(default=False, description='是否通过ocr切换御魂')
     enable_switch_pass_by_name: bool = Field(default=False, description='是否通过ocr切换御魂')
     pass_group_team_name: str = Field(default='', description='组名,队伍名 中间用英文,分隔')
     pass_group_team_name: str = Field(default='', description='组名,队伍名 中间用英文,分隔')
     # 切换体力爬塔御魂
     # 切换体力爬塔御魂
     enable_switch_ap: bool = Field(default=False, description='是否切换体力爬塔御魂')
     enable_switch_ap: bool = Field(default=False, description='是否切换体力爬塔御魂')
-    ap_group_team: str = Field(default='-1,-1', description='组1-7,队伍1-4 中间用英文,分隔。战斗内切换队伍预设使用该值')
+    ap_group_team: str = Field(default='-1,-1', description='组1-7,队伍1-4 中间用英文,分隔。战斗内切换队伍预设也使用该值')
     enable_switch_ap_by_name: bool = Field(default=False, description='是否通过ocr切换御魂')
     enable_switch_ap_by_name: bool = Field(default=False, description='是否通过ocr切换御魂')
     ap_group_team_name: str = Field(default='', description='组名,队伍名 中间用英文,分隔')
     ap_group_team_name: str = Field(default='', description='组名,队伍名 中间用英文,分隔')
     # 切换boss爬塔御魂
     # 切换boss爬塔御魂
     enable_switch_boss: bool = Field(default=False, description='是否切换boss爬塔御魂')
     enable_switch_boss: bool = Field(default=False, description='是否切换boss爬塔御魂')
-    boss_group_team: str = Field(default='-1,-1', description='组1-7,队伍1-4 中间用英文,分隔。战斗内切换队伍预设使用该值')
+    boss_group_team: str = Field(default='-1,-1', description='组1-7,队伍1-4 中间用英文,分隔。战斗内切换队伍预设也使用该值')
     enable_switch_boss_by_name: bool = Field(default=False, description='是否通过ocr切换御魂')
     enable_switch_boss_by_name: bool = Field(default=False, description='是否通过ocr切换御魂')
     boss_group_team_name: str = Field(default='', description='组名,队伍名 中间用英文,分隔')
     boss_group_team_name: str = Field(default='', description='组名,队伍名 中间用英文,分隔')
 
 

+ 24 - 16
tasks/ActivityShikigami/script_task.py

@@ -23,6 +23,8 @@ from tasks.GameUi.page import page_main, page_shikigami_records, page_climb_act,
 
 
 
 
 def get_run_order_list(climb_conf: GeneralClimb) -> list[str]:
 def get_run_order_list(climb_conf: GeneralClimb) -> list[str]:
+    if not climb_conf.run_sequence or len(climb_conf.run_sequence.split(',')) == 1:
+        raise ValueError('Run sequence now is empty, must set it')
     run_order_list = [climb_type.strip() for climb_type in climb_conf.run_sequence.split(',')]
     run_order_list = [climb_type.strip() for climb_type in climb_conf.run_sequence.split(',')]
     return [climb_type for climb_type in run_order_list if getattr(climb_conf, f'enable_{climb_type}')]
     return [climb_type for climb_type in run_order_list if getattr(climb_conf, f'enable_{climb_type}')]
 
 
@@ -153,17 +155,19 @@ class ScriptTask(GameUi, BaseActivity, SwitchSoul, ActivityShikigamiAssets):
         :param conf: 切换御魂配置
         :param conf: 切换御魂配置
         :return:
         :return:
         """
         """
-        enabled = getattr(conf, f"enable_switch_{self.climb_type}")
-        if not enabled:
-            return
-        self.ui_get_current_page()
-        self.ui_goto(page_shikigami_records)
-        enable_by_name = getattr(conf, f"enable_switch_{self.climb_type}_by_name")
+        enable_switch = getattr(conf, f"enable_switch_{self.climb_type}", False)
+        enable_by_name = getattr(conf, f"enable_switch_{self.climb_type}_by_name", False)
+        if enable_switch or enable_by_name:
+            self.ui_get_current_page()
+            self.ui_goto(page_shikigami_records)
         if enable_by_name:
         if enable_by_name:
-            group, team = getattr(conf, f"{self.climb_type}_group_team_name").split(",")
+            group_name = getattr(conf, f"{self.climb_type}_group_team_name", '-1,-1')
+            if not group_name or len(group_name.split(',')) != 2:
+                raise ValueError('switch soul by name must be 2 length')
+            group, team = group_name.split(",")
             self.run_switch_soul_by_name(group, team)
             self.run_switch_soul_by_name(group, team)
-        else:
-            group_team = getattr(conf, f"{self.climb_type}_group_team")
+        elif enable_switch:
+            group_team = getattr(conf, f"{self.climb_type}_group_team", '-1,-1')
             self.run_switch_soul(group_team)
             self.run_switch_soul(group_team)
 
 
     def lock_team(self, battle_conf: GeneralBattleConfig):
     def lock_team(self, battle_conf: GeneralBattleConfig):
@@ -174,7 +178,7 @@ class ScriptTask(GameUi, BaseActivity, SwitchSoul, ActivityShikigamiAssets):
         """
         """
         self.ui_get_current_page()
         self.ui_get_current_page()
         self.ui_goto(self.page_map[self.climb_type])
         self.ui_goto(self.page_map[self.climb_type])
-        enable_preset = getattr(battle_conf, f"enable_{self.climb_type}_preset")
+        enable_preset = getattr(battle_conf, f"enable_{self.climb_type}_preset", False)
         if not enable_preset:
         if not enable_preset:
             logger.info(f'Lock {self.climb_type} team')
             logger.info(f'Lock {self.climb_type} team')
             while 1:
             while 1:
@@ -193,7 +197,7 @@ class ScriptTask(GameUi, BaseActivity, SwitchSoul, ActivityShikigamiAssets):
 
 
     def switch_buff(self, climb_conf: GeneralClimb):
     def switch_buff(self, climb_conf: GeneralClimb):
         buffs = getattr(climb_conf, f'{self.climb_type}_buff', None)
         buffs = getattr(climb_conf, f'{self.climb_type}_buff', None)
-        if not buffs:
+        if not buffs or len(buffs.split(',')) == 1:
             logger.info('Not set buff, skip')
             logger.info('Not set buff, skip')
             return
             return
         buff_list = [buff.strip() for buff in buffs.split(',')]
         buff_list = [buff.strip() for buff in buffs.split(',')]
@@ -272,7 +276,8 @@ class ScriptTask(GameUi, BaseActivity, SwitchSoul, ActivityShikigamiAssets):
         :param climb_conf: 爬塔配置
         :param climb_conf: 爬塔配置
         :return: 限制次数
         :return: 限制次数
         """
         """
-        return getattr(climb_conf, f'{self.climb_type}_limit')
+        limit = getattr(climb_conf, f'{self.climb_type}_limit', 0)
+        return 0 if not limit else limit
 
 
     def switch_next(self) -> bool:
     def switch_next(self) -> bool:
         """
         """
@@ -316,15 +321,18 @@ class ScriptTask(GameUi, BaseActivity, SwitchSoul, ActivityShikigamiAssets):
     def get_general_battle_conf(self) -> tasks.Component.GeneralBattle.config_general_battle.GeneralBattleConfig:
     def get_general_battle_conf(self) -> tasks.Component.GeneralBattle.config_general_battle.GeneralBattleConfig:
         from tasks.Component.GeneralBattle.config_general_battle import GeneralBattleConfig as gbc
         from tasks.Component.GeneralBattle.config_general_battle import GeneralBattleConfig as gbc
         conf = self.config.activity_shikigami
         conf = self.config.activity_shikigami
-        enable_preset = getattr(conf.general_battle, f'enable_{self.climb_type}_preset')
-        group, team = (getattr(conf.switch_soul_config, f'{self.climb_type}_group_team').split(','))
+        enable_preset = getattr(conf.general_battle, f'enable_{self.climb_type}_preset', False)
+        group_team = getattr(conf.switch_soul_config, f'{self.climb_type}_group_team')
+        if enable_preset and (not group_team or len(group_team.split(',')) != 2):
+            raise ValueError('Enable preset but group team not set correct!')
+        group, team = group_team.split(',')
         return gbc(lock_team_enable=not enable_preset,
         return gbc(lock_team_enable=not enable_preset,
                    preset_enable=enable_preset,
                    preset_enable=enable_preset,
                    preset_group=group if enable_preset else 1,
                    preset_group=group if enable_preset else 1,
                    preset_team=team if enable_preset else 1,
                    preset_team=team if enable_preset else 1,
-                   green_enable=getattr(conf.general_battle, f'enable_{self.climb_type}_green'),
+                   green_enable=getattr(conf.general_battle, f'enable_{self.climb_type}_green', False),
                    green_mark=getattr(conf.general_battle, f'{self.climb_type}_green_mark'),
                    green_mark=getattr(conf.general_battle, f'{self.climb_type}_green_mark'),
-                   random_click_swipt_enable=getattr(conf.general_battle, f'enable_{self.climb_type}_anti_detect'), )
+                   random_click_swipt_enable=getattr(conf.general_battle, f'enable_{self.climb_type}_anti_detect', False), )
 
 
     def home_main(self) -> bool:
     def home_main(self) -> bool:
         """
         """

+ 15 - 9
tasks/BondlingFairyland/assets.py

@@ -12,13 +12,13 @@ class BondlingFairylandAssets:
 
 
 	# Click Rule Assets
 	# Click Rule Assets
 	# description 
 	# description 
-	C_STONE_1 = RuleClick(roi_front=(239,536,26,24), roi_back=(0,0,100,100), name="stone_1")
+	C_STONE_1 = RuleClick(roi_front=(230,533,23,20), roi_back=(0,0,100,100), name="stone_1")
 	# description 
 	# description 
-	C_STONE_2 = RuleClick(roi_front=(417,490,26,23), roi_back=(0,0,100,100), name="stone_2")
+	C_STONE_2 = RuleClick(roi_front=(441,569,23,20), roi_back=(0,0,100,100), name="stone_2")
 	# description 
 	# description 
-	C_STONE_3 = RuleClick(roi_front=(705,511,28,26), roi_back=(0,0,100,100), name="stone_3")
+	C_STONE_3 = RuleClick(roi_front=(692,537,23,20), roi_back=(0,0,100,100), name="stone_3")
 	# description 
 	# description 
-	C_STONE_4 = RuleClick(roi_front=(911,487,27,24), roi_back=(0,0,100,100), name="stone_4")
+	C_STONE_4 = RuleClick(roi_front=(944,529,23,20), roi_back=(0,0,100,100), name="stone_4")
 	# description 
 	# description 
 	C_STONE_5 = RuleClick(roi_front=(1041,494,25,25), roi_back=(0,0,100,100), name="stone_5")
 	C_STONE_5 = RuleClick(roi_front=(1041,494,25,25), roi_back=(0,0,100,100), name="stone_5")
 	# description 
 	# description 
@@ -29,17 +29,17 @@ class BondlingFairylandAssets:
 	# Ocr-description 
 	# Ocr-description 
 	O_B_BONDLING_CLASS = RuleOcr(roi=(266,271,79,112), area=(287,271,36,112), mode="Single", method="Default", keyword="", name="b_bondling_class")
 	O_B_BONDLING_CLASS = RuleOcr(roi=(266,271,79,112), area=(287,271,36,112), mode="Single", method="Default", keyword="", name="b_bondling_class")
 	# 小盘子 
 	# 小盘子 
-	O_B_LOW_NUMBER = RuleOcr(roi=(490,24,98,36), area=(490,24,98,36), mode="DigitCounter", method="Default", keyword="", name="b_low_number")
+	O_B_LOW_NUMBER = RuleOcr(roi=(543,14,96,33), area=(543,14,96,33), mode="DigitCounter", method="Default", keyword="", name="b_low_number")
 	# 中盘子 
 	# 中盘子 
-	O_B_MEDIUM_NUMBER = RuleOcr(roi=(687,21,101,36), area=(687,21,101,36), mode="DigitCounter", method="Default", keyword="", name="b_medium_number")
+	O_B_MEDIUM_NUMBER = RuleOcr(roi=(734,19,99,25), area=(734,19,99,25), mode="DigitCounter", method="Default", keyword="", name="b_medium_number")
 	# 大盘子 
 	# 大盘子 
-	O_B_HIGH_NUMBER = RuleOcr(roi=(883,23,100,32), area=(883,23,100,32), mode="DigitCounter", method="Default", keyword="", name="b_high_number")
+	O_B_HIGH_NUMBER = RuleOcr(roi=(928,17,94,30), area=(928,17,94,30), mode="DigitCounter", method="Default", keyword="", name="b_high_number")
 	# 鸣契石 
 	# 鸣契石 
-	O_B_STONE_NUMBER = RuleOcr(roi=(858,22,82,40), area=(858,22,82,40), mode="DigitCounter", method="Default", keyword="", name="b_stone_number")
+	O_B_STONE_NUMBER = RuleOcr(roi=(1135,16,78,32), area=(1135,16,78,32), mode="DigitCounter", method="Default", keyword="", name="b_stone_number")
 	# 召唤契灵数量 
 	# 召唤契灵数量 
 	O_B_SUMMON_BALL_NUMBER = RuleOcr(roi=(546,540,100,45), area=(546,540,100,45), mode="Single", method="Default", keyword="", name="b_summon_ball_number")
 	O_B_SUMMON_BALL_NUMBER = RuleOcr(roi=(546,540,100,45), area=(546,540,100,45), mode="Single", method="Default", keyword="", name="b_summon_ball_number")
 	# 抓捕契灵剩余数量 
 	# 抓捕契灵剩余数量 
-	O_B_BALL_NUMBER = RuleOcr(roi=(1190,532,70,30), area=(1190,532,70,30), mode="DigitCounter", method="Default", keyword="", name="b_ball_number")
+	O_B_BALL_NUMBER = RuleOcr(roi=(1186,666,65,26), area=(1186,666,65,26), mode="DigitCounter", method="Default", keyword="", name="b_ball_number")
 	# 好友邀请 
 	# 好友邀请 
 	O_FRIEND = RuleOcr(roi=(357,89,100,54), area=(357,89,100,54), mode="Single", method="Default", keyword="", name="friend")
 	O_FRIEND = RuleOcr(roi=(357,89,100,54), area=(357,89,100,54), mode="Single", method="Default", keyword="", name="friend")
 	# 跨区邀请 
 	# 跨区邀请 
@@ -97,6 +97,12 @@ class BondlingFairylandAssets:
 	I_CAP_SUCCESS = RuleImage(roi_front=(210,445,22,21), roi_back=(210,445,22,21), threshold=0.8, method="Template matching", file="./tasks/BondlingFairyland/capture/capture_cap_success.png")
 	I_CAP_SUCCESS = RuleImage(roi_front=(210,445,22,21), roi_back=(210,445,22,21), threshold=0.8, method="Template matching", file="./tasks/BondlingFairyland/capture/capture_cap_success.png")
 	# description 
 	# description 
 	I_CAP_FAILURE = RuleImage(roi_front=(1192,608,30,39), roi_back=(1192,608,30,39), threshold=0.8, method="Template matching", file="./tasks/BondlingFairyland/capture/capture_cap_failure.png")
 	I_CAP_FAILURE = RuleImage(roi_front=(1192,608,30,39), roi_back=(1192,608,30,39), threshold=0.8, method="Template matching", file="./tasks/BondlingFairyland/capture/capture_cap_failure.png")
+	# description 
+	I_BATTLE_FAIL = RuleImage(roi_front=(740,267,79,84), roi_back=(740,267,79,84), threshold=0.8, method="Template matching", file="./tasks/BondlingFairyland/capture/battle_fail.png")
+	# 放弃结契 
+	I_BATTLE_FAIL_ABANDON = RuleImage(roi_front=(436,606,115,36), roi_back=(436,606,115,36), threshold=0.8, method="Template matching", file="./tasks/BondlingFairyland/capture/battle_fail_abandon.png")
+	# description 
+	I_BATTLE_SUCCESS = RuleImage(roi_front=(651,203,70,81), roi_back=(651,203,70,81), threshold=0.8, method="Template matching", file="./tasks/BondlingFairyland/capture/battle_success.png")
 
 
 
 
 	# Image Rule Assets
 	# Image Rule Assets

BIN
tasks/BondlingFairyland/ball/ball_ball_fire.png


+ 25 - 4
tasks/BondlingFairyland/battle.py

@@ -1,8 +1,11 @@
 # This Python file uses the following encoding: utf-8
 # This Python file uses the following encoding: utf-8
 # @author runhey
 # @author runhey
 # github https://github.com/runhey
 # github https://github.com/runhey
+from datetime import timedelta, datetime
+
 import random
 import random
 
 
+from module.server.i18n import I18n
 from tasks.Component.GeneralBattle.general_battle import GeneralBattle
 from tasks.Component.GeneralBattle.general_battle import GeneralBattle
 from tasks.BondlingFairyland.assets import BondlingFairylandAssets
 from tasks.BondlingFairyland.assets import BondlingFairylandAssets
 from tasks.BondlingFairyland.config_battle import BattleConfig
 from tasks.BondlingFairyland.config_battle import BattleConfig
@@ -20,7 +23,13 @@ class BondlingBattle(GeneralBattle, BondlingFairylandAssets):
         """
         """
         logger.hr("General battle start", 2)
         logger.hr("General battle start", 2)
         self.current_count += 1
         self.current_count += 1
-        logger.info(f"Current count: {self.current_count} / " + str(limit_count))
+        logger.info(f'Current tasks: {I18n.trans_zh_cn(self.config.task.command)}')
+        logger.info(f'Current count: {self.current_count} / {limit_count}')
+
+        task_run_time = datetime.now() - self.start_time
+        # 格式化时间,只保留整数部分的秒
+        task_run_time_seconds = timedelta(seconds=int(task_run_time.total_seconds()))
+        logger.info(f'Current times: {task_run_time_seconds} / {self.limit_time}')
 
 
         if self.check_load():
         if self.check_load():
             # 首先要判断进入战斗的界面
             # 首先要判断进入战斗的界面
@@ -67,8 +76,14 @@ class BondlingBattle(GeneralBattle, BondlingFairylandAssets):
             # 如果领奖励
             # 如果领奖励
             if self.appear(self.I_REWARD, threshold=0.6):
             if self.appear(self.I_REWARD, threshold=0.6):
                 break
                 break
-            if self.appear(self.I_WIN, threshold=0.6):
-                break
+            if self.appear_then_click(self.I_WIN, threshold=0.6):
+                continue
+            if self.appear_then_click(self.I_BATTLE_SUCCESS, threshold=0.6, interval=1):
+                continue
+            if self.appear_then_click(self.I_BATTLE_FAIL_ABANDON, interval=1):
+                continue
+            if self.appear_then_click(self.I_BATTLE_FAIL, threshold=0.6, interval=1):
+                continue
             # 如果开启战斗过程随机滑动
             # 如果开启战斗过程随机滑动
             if random_click_swipt_enable:
             if random_click_swipt_enable:
                 self.random_click_swipt()
                 self.random_click_swipt()
@@ -85,7 +100,13 @@ class BondlingBattle(GeneralBattle, BondlingFairylandAssets):
             if self.appear_then_click(self.I_REWARD, action=action_click, interval=1.5):
             if self.appear_then_click(self.I_REWARD, action=action_click, interval=1.5):
                 continue
                 continue
             if self.appear_then_click(self.I_WIN, threshold=0.6):
             if self.appear_then_click(self.I_WIN, threshold=0.6):
-                break
+                continue
+            if self.appear_then_click(self.I_BATTLE_SUCCESS, threshold=0.6, interval=1):
+                continue
+            if self.appear_then_click(self.I_BATTLE_FAIL_ABANDON, interval=1):
+                continue
+            if self.appear_then_click(self.I_BATTLE_FAIL, threshold=0.6, interval=1):
+                continue
             if not self.appear(self.I_REWARD):
             if not self.appear(self.I_REWARD):
                 break
                 break
         logger.info("Get reward")
         logger.info("Get reward")

BIN
tasks/BondlingFairyland/capture/battle_fail.png


BIN
tasks/BondlingFairyland/capture/battle_fail_abandon.png


BIN
tasks/BondlingFairyland/capture/battle_success.png


+ 27 - 0
tasks/BondlingFairyland/capture/capture.json

@@ -52,5 +52,32 @@
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "description"
     "description": "description"
+  },
+  {
+    "itemName": "battle_fail",
+    "imageName": "battle_fail.png",
+    "roiFront": "740,267,79,84",
+    "roiBack": "740,267,79,84",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "battle_fail_abandon",
+    "imageName": "battle_fail_abandon.png",
+    "roiFront": "436,606,115,36",
+    "roiBack": "436,606,115,36",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "放弃结契"
+  },
+  {
+    "itemName": "battle_success",
+    "imageName": "battle_success.png",
+    "roiFront": "651,203,70,81",
+    "roiBack": "651,203,70,81",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
   }
   }
 ]
 ]

+ 4 - 4
tasks/BondlingFairyland/click.json

@@ -1,25 +1,25 @@
 [
 [
   {
   {
     "itemName": "stone_1",
     "itemName": "stone_1",
-    "roiFront": "239,536,26,24",
+    "roiFront": "230,533,23,20",
     "roiBack": "0,0,100,100",
     "roiBack": "0,0,100,100",
     "description": "description"
     "description": "description"
   },
   },
   {
   {
     "itemName": "stone_2",
     "itemName": "stone_2",
-    "roiFront": "417,490,26,23",
+    "roiFront": "441,569,23,20",
     "roiBack": "0,0,100,100",
     "roiBack": "0,0,100,100",
     "description": "description"
     "description": "description"
   },
   },
   {
   {
     "itemName": "stone_3",
     "itemName": "stone_3",
-    "roiFront": "705,511,28,26",
+    "roiFront": "692,537,23,20",
     "roiBack": "0,0,100,100",
     "roiBack": "0,0,100,100",
     "description": "description"
     "description": "description"
   },
   },
   {
   {
     "itemName": "stone_4",
     "itemName": "stone_4",
-    "roiFront": "911,487,27,24",
+    "roiFront": "944,529,23,20",
     "roiBack": "0,0,100,100",
     "roiBack": "0,0,100,100",
     "description": "description"
     "description": "description"
   },
   },

+ 15 - 8
tasks/BondlingFairyland/config.py

@@ -12,24 +12,21 @@ from tasks.BondlingFairyland.config_battle import BattleConfig
 from tasks.Component.GeneralInvite.config_invite import InviteConfig
 from tasks.Component.GeneralInvite.config_invite import InviteConfig
 from tasks.Component.GeneralBattle.config_general_battle import GeneralBattleConfig
 from tasks.Component.GeneralBattle.config_general_battle import GeneralBattleConfig
 
 
+
+
 class BondlingMode(str, Enum):
 class BondlingMode(str, Enum):
     MODE1 = 'mode_1'
     MODE1 = 'mode_1'
     MODE2 = 'mode_2'
     MODE2 = 'mode_2'
     MODE3 = 'mode_3'
     MODE3 = 'mode_3'
-# 镇墓兽 Tomb Guard  tomb_guard
-# 茨球 Snowball       snowball
-# 小黑 Little Kuro  little_kuro
-# 火灵 Azure Basan azure_basan
+
+
 class BondlingClass(str, Enum):
 class BondlingClass(str, Enum):
     TOMB_GUARD = '镇墓兽'
     TOMB_GUARD = '镇墓兽'
     SNOWBALL = '茨球'
     SNOWBALL = '茨球'
     LITTLE_KURO = '小黑'
     LITTLE_KURO = '小黑'
     AZURE_BASAN = '火灵'
     AZURE_BASAN = '火灵'
 
 
-# 契石 Bondling Stone
-# 低级契灵盘 Low Bondling Discs
-# 中级契灵盘 Medium Bondling Discs
-# 高级契灵盘 High Bondling Discs
+
 class UserStatus(str, Enum):
 class UserStatus(str, Enum):
     LEADER = 'leader'
     LEADER = 'leader'
     MEMBER = 'member'
     MEMBER = 'member'
@@ -37,6 +34,8 @@ class UserStatus(str, Enum):
     handoff1 = 'handoff1'
     handoff1 = 'handoff1'
     handoff2 = 'handoff2'
     handoff2 = 'handoff2'
     # WILD = 'wild'  # 还不打算实现
     # WILD = 'wild'  # 还不打算实现
+
+
 class BondlingConfig(ConfigBase):
 class BondlingConfig(ConfigBase):
     # 身份
     # 身份
     user_status: UserStatus = Field(default=UserStatus.ALONE, description='user_status_help')
     user_status: UserStatus = Field(default=UserStatus.ALONE, description='user_status_help')
@@ -46,6 +45,7 @@ class BondlingConfig(ConfigBase):
     bondling_stone_enable: bool = Field(default=False, description='bondling_stone_enable_help')
     bondling_stone_enable: bool = Field(default=False, description='bondling_stone_enable_help')
     bondling_stone_class: BondlingClass = Field(default=BondlingClass.TOMB_GUARD, description='bondling_stone_class_help')
     bondling_stone_class: BondlingClass = Field(default=BondlingClass.TOMB_GUARD, description='bondling_stone_class_help')
 
 
+
 class BondlingSwitchSoul(ConfigBase):
 class BondlingSwitchSoul(ConfigBase):
     auto_switch_soul: bool = Field(default=False, description='auto_switch_soul_help')
     auto_switch_soul: bool = Field(default=False, description='auto_switch_soul_help')
     # 镇墓兽 config
     # 镇墓兽 config
@@ -57,8 +57,15 @@ class BondlingSwitchSoul(ConfigBase):
     # 火灵 config
     # 火灵 config
     azure_basan_switch: str = Field(default='-1,-1', description='azure_basan_switch_help')
     azure_basan_switch: str = Field(default='-1,-1', description='azure_basan_switch_help')
 
 
+
+class BondlingCheck(ConfigBase):
+    check_enable: bool = Field(default=True, description='是否检查契忆数量')
+    limit_num: int = Field(default=2000, description='契忆数量限制')
+
+
 class BondlingFairyland(ConfigBase):
 class BondlingFairyland(ConfigBase):
     scheduler: Scheduler = Field(default_factory=Scheduler)
     scheduler: Scheduler = Field(default_factory=Scheduler)
+    bondling_check: BondlingCheck = Field(default_factory=BondlingCheck)
     bondling_config: BondlingConfig = Field(default_factory=BondlingConfig)
     bondling_config: BondlingConfig = Field(default_factory=BondlingConfig)
     bondling_switch_soul: BondlingSwitchSoul = Field(default_factory=BondlingSwitchSoul)
     bondling_switch_soul: BondlingSwitchSoul = Field(default_factory=BondlingSwitchSoul)
     invite_config: InviteConfig = Field(default_factory=InviteConfig)
     invite_config: InviteConfig = Field(default_factory=InviteConfig)

+ 3 - 147
tasks/BondlingFairyland/general_invite.py

@@ -40,10 +40,6 @@ class GeneralInvite(BaseTask, BondlingFairylandAssets, GeneralInviteAssets):
     timer_invite = None
     timer_invite = None
     timer_wait = None
     timer_wait = None
 
 
-    """
-
-    """
-
     def run_invite(self, config: InviteConfig, is_first: bool = False, is_over: bool = True) -> bool:
     def run_invite(self, config: InviteConfig, is_first: bool = False, is_over: bool = True) -> bool:
         """
         """
         队长!!身份。。。在组队界面邀请好友( 如果开启is_first) 等待队员进入开启挑战
         队长!!身份。。。在组队界面邀请好友( 如果开启is_first) 等待队员进入开启挑战
@@ -53,7 +49,7 @@ class GeneralInvite(BaseTask, BondlingFairylandAssets, GeneralInviteAssets):
         :param is_first: 如果是第一次开房间的那就要邀请队员,其他情况等待队员进入
         :param is_first: 如果是第一次开房间的那就要邀请队员,其他情况等待队员进入
         :return:
         :return:
         """
         """
-        logger.hr('Invite friend', 2)
+        logger.hr('Invite friend')
         if not self.ensure_enter():
         if not self.ensure_enter():
             logger.warning('Not enter invite page')
             logger.warning('Not enter invite page')
             return False
             return False
@@ -72,7 +68,7 @@ class GeneralInvite(BaseTask, BondlingFairylandAssets, GeneralInviteAssets):
         while 1:
         while 1:
             self.screenshot()
             self.screenshot()
             if self.timer_wait.reached():
             if self.timer_wait.reached():
-                logger.warning('Wait timeout')
+                logger.warning('队长等待超时...')
                 return False
                 return False
             if self.appear(self.I_MATCHING):
             if self.appear(self.I_MATCHING):
                 logger.warning('Timeout, now is no room')
                 logger.warning('Timeout, now is no room')
@@ -86,29 +82,6 @@ class GeneralInvite(BaseTask, BondlingFairylandAssets, GeneralInviteAssets):
             if self.room_type == RoomType.NORMAL_2 and not self.appear(self.I_ADD_1):
             if self.room_type == RoomType.NORMAL_2 and not self.appear(self.I_ADD_1):
                 logger.info('Start challenge and this room can only invite one friend')
                 logger.info('Start challenge and this room can only invite one friend')
                 fire = True
                 fire = True
-            # 如果这个房间最多容纳三个人(意思是可以邀请两个人),且设定邀请一个就开启挑战,那就开启挑战
-            elif self.room_type == RoomType.NORMAL_3 and config.invite_number == InviteNumber.ONE and not self.appear(self.I_ADD_1):
-                logger.info('Start challenge and user only invite one friend')
-                fire = True
-            # 如果这个房间最多容纳三个人(意思是可以邀请两个人),且设定邀请两个就开启挑战,那就开启挑战
-            elif self.room_type == RoomType.NORMAL_3 \
-                    and config.invite_number == InviteNumber.TWO and not self.appear(self.I_ADD_2):
-                logger.info('Start challenge and user invite two friends')
-                fire = True
-            # 如果这个房间是五人的,且设定邀请一个就开启挑战,那就开启挑战
-            elif self.room_type == RoomType.NORMAL_5 \
-                    and config.invite_number == InviteNumber.ONE and not self.appear(self.I_ADD_5_1):
-                logger.info('Start challenge and user only invite one friend')
-                fire = True
-            # 如果这个房间是五人的,且设定邀请两个就开启挑战,那就开启挑战
-            elif self.room_type == RoomType.NORMAL_5 \
-                    and config.invite_number == InviteNumber.TWO and not self.appear(self.I_ADD_5_2):
-                logger.info('Start challenge and user invite two friends')
-                fire = True
-            # 如果是永生之海
-            elif self.room_type == RoomType.ETERNITY_SEA and not self.appear(self.I_ADD_SEA):
-                logger.info('Start challenge and this is lock sea')
-                fire = True
 
 
             # 点击挑战
             # 点击挑战
             if fire:
             if fire:
@@ -457,45 +430,6 @@ class GeneralInvite(BaseTask, BondlingFairylandAssets, GeneralInviteAssets):
                 logger.warning('Invite friend 2 failed')
                 logger.warning('Invite friend 2 failed')
         sleep(0.5)
         sleep(0.5)
 
 
-    def invite_again(self, default_invite: bool=True) -> bool:
-        """
-        作为队长战斗胜利后再次邀请队友,
-        :param default_invite:  是否勾选默认
-        :return:
-        """
-        logger.info('Invite again')
-        # 判断是否进入界面
-        while 1:
-            self.screenshot()
-            if self.appear(self.I_GI_SURE):
-                break
-        # 如果勾选了默认邀请
-        if default_invite:
-            logger.info('Click default invite')
-            while 1:
-                self.screenshot()
-                if self.appear(self.I_I_DEFAULT):
-                    break
-                if self.appear_then_click(self.I_I_NO_DEFAULT, interval=1):
-                    continue
-        else:
-            logger.info('Click no default invite')
-            while 1:
-                self.screenshot()
-                if self.appear(self.I_I_NO_DEFAULT):
-                    break
-                if self.appear_then_click(self.I_I_DEFAULT, interval=1):
-                    continue
-
-        # 点击确认
-        logger.info('Click invite ensure')
-        while 1:
-            self.screenshot()
-            if not self.appear(self.I_GI_SURE):
-                break
-            if self.appear_then_click(self.I_GI_SURE):
-                continue
-
     def check_and_invite(self, default_invite: bool=True) -> bool:
     def check_and_invite(self, default_invite: bool=True) -> bool:
         """
         """
         队长战斗后 邀请队友
         队长战斗后 邀请队友
@@ -525,91 +459,13 @@ class GeneralInvite(BaseTask, BondlingFairylandAssets, GeneralInviteAssets):
 
 
         return True
         return True
 
 
-    def check_then_accept(self) -> bool:
-        """
-        队员接受邀请
-        :return:
-        """
-        if not self.appear(self.I_I_ACCEPT):
-            return False
-        logger.info('Click accept')
-        while 1:
-            self.screenshot()
-            if self.is_in_room():
-                return True
-            # 被秒开
-            # https://github.com/runhey/OnmyojiAutoScript/issues/230
-            if self.appear(GeneralBattleAssets.I_EXIT):
-                return False
-            if self.appear_then_click(self.I_I_NO_DEFAULT, interval=1):
-                continue
-            if self.appear_then_click(self.I_GI_SURE, interval=1):
-                continue
-            if self.appear_then_click(self.I_I_ACCEPT_DEFAULT, interval=1):
-                continue
-            if self.appear_then_click(self.I_I_ACCEPT, interval=1):
-                continue
-        return True
-
-    def wait_battle(self, wait_time: time) -> bool:
-        """
-        在房间等待,(要求保证在房间里面) 队长开启战斗
-        如果队长跑路了,或者的等待了很久还没开始
-        :return: 如果成功进入战斗(反正就是不在房间 )返回 True
-                 如果失败了,(退出房间)返回 False
-        """
-        wait_second = wait_time.second + wait_time.minute * 60
-        self.timer_wait = Timer(wait_second)
-        self.timer_wait.start()
-        logger.info(f'Wait battle {wait_second} seconds')
-        success = True
-        while 1:
-            self.screenshot()
-
-            # 如果自己在探索界面或者是庭院,那就是房间已经被销毁了
-            if self.appear(self.I_GI_HOME) or self.appear(self.I_GI_EXPLORE):
-                logger.warning('Room destroyed')
-                success = False
-                break
-
-
-            if self.timer_wait.reached():
-                logger.warning('Wait battle time out')
-                success = False
-                break
-
-            # 如果队长跑路了,自己变成了队长: 自己也要跑路
-            if self.appear(self.I_FIRE) or self.appear(self.I_FIRE_SEA):
-                logger.warning('Leader run away while wait battle and become leader now')
-                success = False
-                break
-
-            # 判断是否进入战斗
-            if self.is_in_room(is_screenshot=False):
-                pass
-            else:
-                break
-
-        # 调出循环只有这些可能性:
-        # 1. 进入战斗(ui是战斗)
-        # 2. 队长跑路(自己还是在房间里面)
-        # 3. 等待时间到没有开始(还是在房间里面)
-        # 4. 房间的时间到了被迫提出房间(这个时候来到了探索界面)
-        if not success:
-            logger.info('Leave room')
-            self.exit_room()
-
-        return success
-
-
-
 
 
 if __name__ == '__main__':
 if __name__ == '__main__':
     from module.config.config import Config
     from module.config.config import Config
     from module.device.device import Device
     from module.device.device import Device
     import cv2
     import cv2
 
 
-    c = Config('oas1')
+    c = Config('du')
     d = Device(c)
     d = Device(c)
     t = GeneralInvite(c, d)
     t = GeneralInvite(c, d)
 
 

+ 10 - 10
tasks/BondlingFairyland/ocr.json

@@ -10,8 +10,8 @@
   },
   },
   {
   {
     "itemName": "b_low_number",
     "itemName": "b_low_number",
-    "roiFront": "490,24,98,36",
-    "roiBack": "490,24,98,36",
+    "roiFront": "543,14,96,33",
+    "roiBack": "543,14,96,33",
     "mode": "DigitCounter",
     "mode": "DigitCounter",
     "method": "Default",
     "method": "Default",
     "keyword": "",
     "keyword": "",
@@ -19,8 +19,8 @@
   },
   },
   {
   {
     "itemName": "b_medium_number",
     "itemName": "b_medium_number",
-    "roiFront": "687,21,101,36",
-    "roiBack": "687,21,101,36",
+    "roiFront": "734,19,99,25",
+    "roiBack": "734,19,99,25",
     "mode": "DigitCounter",
     "mode": "DigitCounter",
     "method": "Default",
     "method": "Default",
     "keyword": "",
     "keyword": "",
@@ -28,8 +28,8 @@
   },
   },
   {
   {
     "itemName": "b_high_number",
     "itemName": "b_high_number",
-    "roiFront": "883,23,100,32",
-    "roiBack": "883,23,100,32",
+    "roiFront": "928,17,94,30",
+    "roiBack": "928,17,94,30",
     "mode": "DigitCounter",
     "mode": "DigitCounter",
     "method": "Default",
     "method": "Default",
     "keyword": "",
     "keyword": "",
@@ -37,8 +37,8 @@
   },
   },
   {
   {
     "itemName": "b_stone_number",
     "itemName": "b_stone_number",
-    "roiFront": "858,22,82,40",
-    "roiBack": "858,22,82,40",
+    "roiFront": "1135,16,78,32",
+    "roiBack": "1135,16,78,32",
     "mode": "DigitCounter",
     "mode": "DigitCounter",
     "method": "Default",
     "method": "Default",
     "keyword": "",
     "keyword": "",
@@ -55,8 +55,8 @@
   },
   },
   {
   {
     "itemName": "b_ball_number",
     "itemName": "b_ball_number",
-    "roiFront": "1190,532,70,30",
-    "roiBack": "1190,532,70,30",
+    "roiFront": "1186,666,65,26",
+    "roiBack": "1186,666,65,26",
     "mode": "DigitCounter",
     "mode": "DigitCounter",
     "method": "Default",
     "method": "Default",
     "keyword": "",
     "keyword": "",

+ 136 - 251
tasks/BondlingFairyland/script_task.py

@@ -2,33 +2,26 @@
 # @author runhey
 # @author runhey
 # github https://github.com/runhey
 # github https://github.com/runhey
 
 
-from tasks.Component.GeneralRoom.general_room import GeneralRoom
-
-import numpy as np
 from time import sleep
 from time import sleep
-from cached_property import cached_property
-from datetime import datetime, timedelta
-from tasks.BondlingFairyland.general_invite import GeneralInvite
-from tasks.Component.GeneralBattle.assets import GeneralBattleAssets
 
 
-from tasks.base_task import BaseTask
-from tasks.GameUi.game_ui import GameUi
-from tasks.BondlingFairyland.config import (BondlingFairyland, BondlingMode,
-                                            BondlingClass,
-                                            BondlingSwitchSoul, BondlingConfig, UserStatus)
+from cached_property import cached_property
+from datetime import datetime
+from datetime import timedelta, time
+from module.base.timer import Timer
+from module.exception import TaskEnd
+from module.logger import logger
 from tasks.BondlingFairyland.assets import BondlingFairylandAssets
 from tasks.BondlingFairyland.assets import BondlingFairylandAssets
 from tasks.BondlingFairyland.battle import BondlingBattle
 from tasks.BondlingFairyland.battle import BondlingBattle
+from tasks.BondlingFairyland.config import BondlingMode, BondlingClass, BondlingSwitchSoul, BondlingConfig, UserStatus
 from tasks.BondlingFairyland.config_battle import BattleConfig
 from tasks.BondlingFairyland.config_battle import BattleConfig
-from tasks.Component.SwitchSoul.switch_soul import SwitchSoul, switch_parser
+from tasks.BondlingFairyland.general_invite import GeneralInvite
+from tasks.Component.GeneralBattle.assets import GeneralBattleAssets
 from tasks.Component.GeneralBattle.config_general_battle import GeneralBattleConfig
 from tasks.Component.GeneralBattle.config_general_battle import GeneralBattleConfig
-from tasks.GameUi.page import page_main, page_bondling_fairyland, page_shikigami_records
-
-from module.atom.image import RuleImage
-from module.logger import logger
-from module.exception import TaskEnd
-from tasks.Component.GeneralRoom.assets import GeneralRoomAssets
-from module.base.timer import Timer
-from datetime import timedelta, time
+from tasks.Component.GeneralRoom.general_room import GeneralRoom
+from tasks.Component.SwitchSoul.switch_soul import SwitchSoul, switch_parser
+from tasks.GameUi.game_ui import GameUi
+from tasks.GameUi.page import page_main, page_bondling_fairyland, page_shikigami_records, page_mall
+from tasks.RichMan.assets import RichManAssets
 
 
 
 
 class BondlingNumberMax(Exception):
 class BondlingNumberMax(Exception):
@@ -38,15 +31,34 @@ class BondlingNumberMax(Exception):
 """ 契灵 """
 """ 契灵 """
 
 
 
 
-class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul, BondlingFairylandAssets):
+class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul, BondlingFairylandAssets, RichManAssets):
     ball_pos_list = [None, None, None, None, None]  # 用于记录每一个位置的球是否出现
     ball_pos_list = [None, None, None, None, None]  # 用于记录每一个位置的球是否出现
     first_catch = True  # 用于记录是否是第一次捕捉
     first_catch = True  # 用于记录是否是第一次捕捉
-    first_win = False  # 用于记录是不是第一次捕获成功
-    current_ball_index = 5
+
     def run(self):
     def run(self):
         # 引用配置
         # 引用配置
         cong = self.config.bondling_fairyland
         cong = self.config.bondling_fairyland
 
 
+        if cong.bondling_check.check_enable:
+            logger.hr('第一步, 检查契忆数量', 2)
+            self.ui_get_current_page()
+            self.ui_goto(page_mall, confirm_wait=2.5)
+            self.ui_click(self.I_MALL_SCCALES, self.I_MALL_SCCALES_CHECK)
+            self.ui_click(self.I_MALL_BONDLINGS_SURE, self.I_MALL_BONDLINGS_ON)
+
+            MAX_COUNT = cong.bondling_check.limit_num
+            cu, re, total = self.O_BL_CHECK_MONEY.ocr(self.device.image)
+
+            if cu >= MAX_COUNT:
+                logger.info(f'契忆数量: {cu} 大于 {MAX_COUNT}')
+                self.ui_get_current_page()
+                self.ui_goto(page_main)
+                self.set_next_run(task='BondlingFairyland', finish=True, success=True)
+                raise TaskEnd
+
+            logger.info(f'契忆数量: {cu} 小于 {MAX_COUNT}, 继续任务')
+
+        logger.hr('第二步, 切换御魂', 2)
         # 御魂切换方式一
         # 御魂切换方式一
         if cong.switch_soul_config.enable:
         if cong.switch_soul_config.enable:
             self.ui_get_current_page()
             self.ui_get_current_page()
@@ -58,6 +70,7 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
             self.ui_goto(page_shikigami_records)
             self.ui_goto(page_shikigami_records)
             self.run_switch_soul_by_name(cong.switch_soul_config.group_name, cong.switch_soul_config.team_name)
             self.run_switch_soul_by_name(cong.switch_soul_config.group_name, cong.switch_soul_config.team_name)
 
 
+        logger.hr('第三步, 前往契灵主界面', 2)
         self.ui_get_current_page()
         self.ui_get_current_page()
         self.ui_goto(page_bondling_fairyland)
         self.ui_goto(page_bondling_fairyland)
 
 
@@ -70,37 +83,31 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
                 self.ui_goto(page_bondling_fairyland)
                 self.ui_goto(page_bondling_fairyland)
                 continue
                 continue
 
 
-        limit_count = cong.bondling_config.limit_count
+        logger.hr('第四步, 开始战斗准备', 2)
         self.current_count = 0
         self.current_count = 0
-        self.limit_count: int = limit_count
-
-        if UserStatus.handoff1 == cong.bondling_config.user_status:
-            self.limit_count: int = limit_count // 2
-            self.switch_ball()
-        if UserStatus.handoff2 == cong.bondling_config.user_status:
-            self.limit_count: int = limit_count // 2
-            self.run_member()
-            self.current_count = 0
-            self.ui_get_current_page()
-            self.ui_goto(page_bondling_fairyland)
-            self.switch_ball()
+        self.limit_count = cong.bondling_config.limit_count  # 默认limit_count值
 
 
         match cong.bondling_config.user_status:
         match cong.bondling_config.user_status:
-            case UserStatus.LEADER:
+            case UserStatus.handoff1:
+                self.limit_count //= 2
                 self.switch_ball()
                 self.switch_ball()
-            case UserStatus.MEMBER:
+            case UserStatus.handoff2:
+                self.limit_count //= 2
                 self.run_member()
                 self.run_member()
-            case UserStatus.ALONE:
+                self.current_count = 0
+                self.ui_get_current_page()
+                self.ui_goto(page_bondling_fairyland)
                 self.switch_ball()
                 self.switch_ball()
+            case UserStatus.LEADER | UserStatus.ALONE:
+                self.switch_ball()
+            case UserStatus.MEMBER:
+                self.run_member()
             case _:
             case _:
-                logger.error('Unknown user status')
+                logger.error(f'Unknown user status: {cong.bondling_config.user_status}')
 
 
     def run_leader(self):
     def run_leader(self):
-
-        """
-        点击 求援, 组队模式
-        """
-
+        """  点击 求援, 组队模式  """
+        logger.hr('Start run leader', 2)
         success = True
         success = True
         is_first = True
         is_first = True
         while 1:
         while 1:
@@ -125,6 +132,8 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
                         self.appear_then_click(self.I_CREATE_TEAM, interval=2)
                         self.appear_then_click(self.I_CREATE_TEAM, interval=2)
                         continue
                         continue
                     # 求援
                     # 求援
+                    if self.appear(self.I_CHECK_BONDLING_FAIRYLAND, interval=1):
+                        return False
                     if self.appear(self.I_BALL_HELP, interval=1):
                     if self.appear(self.I_BALL_HELP, interval=1):
                         cu, res, total = self.O_B_BALL_NUMBER.ocr(self.device.image)
                         cu, res, total = self.O_B_BALL_NUMBER.ocr(self.device.image)
                         logger.info(f'ball is cu {cu}, total {total}')
                         logger.info(f'ball is cu {cu}, total {total}')
@@ -148,7 +157,7 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
             if self.current_count >= self.limit_count:
             if self.current_count >= self.limit_count:
                 if self.appear(self.I_GI_IN_ROOM):
                 if self.appear(self.I_GI_IN_ROOM):
                     # 次数达到也要邀请好友进房间,然后退出,不然队员无法判断是否完成契灵,出现异常
                     # 次数达到也要邀请好友进房间,然后退出,不然队员无法判断是否完成契灵,出现异常
-                    self.run_invite(config=self.config.bondling_fairyland.invite_config, is_over=False)
+                    self.run_invite(config=self.config.bondling_fairyland.invite_config, is_first=is_first, is_over=False)
                     # 等待三秒让队员进房间,避免队员没进房间出现异常
                     # 等待三秒让队员进房间,避免队员没进房间出现异常
                     sleep(3)
                     sleep(3)
                     logger.info(f'契灵次数:{self.current_count}已完成,退出')
                     logger.info(f'契灵次数:{self.current_count}已完成,退出')
@@ -200,7 +209,7 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
         raise TaskEnd
         raise TaskEnd
 
 
     def run_member(self):
     def run_member(self):
-        logger.info('Start run member')
+        logger.hr('Start run member', 2)
         self.ui_get_current_page()
         self.ui_get_current_page()
         # 开始等待队长拉人
         # 开始等待队长拉人
         wait_time = self.config.bondling_fairyland.invite_config.wait_time
         wait_time = self.config.bondling_fairyland.invite_config.wait_time
@@ -215,15 +224,13 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
 
 
             self.screenshot()
             self.screenshot()
 
 
-            # 等待超时
-            logger.info("开始等待队长拉人:" + str(wait_timer.current()))
             if wait_timer.reached():
             if wait_timer.reached():
-                logger.warning('wait_timer timeout')
+                logger.info(f"队员等待超时:{wait_timer.current()}, 退出")
                 break
                 break
 
 
             # if self.current_count >= self.limit_count:
             # if self.current_count >= self.limit_count:
             #     logger.info('Orochi count limit out')
             #     logger.info('Orochi count limit out')
-            #     break
+            #     breakpush_n
             if datetime.now() - self.start_time >= self.limit_time:
             if datetime.now() - self.start_time >= self.limit_time:
                 logger.info('BondlingFairyland time limit out')
                 logger.info('BondlingFairyland time limit out')
                 break
                 break
@@ -232,7 +239,7 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
                 continue
                 continue
 
 
             if self.is_in_room():
             if self.is_in_room():
-                logger.info("契灵:进入组队房间!")
+                logger.info("契灵:已经在组队房间中")
                 if self.wait_battle(wait_time=self.config.bondling_fairyland.invite_config.wait_time):
                 if self.wait_battle(wait_time=self.config.bondling_fairyland.invite_config.wait_time):
                     self.run_battle(self.config.bondling_fairyland.battle_config, limit_count=self.limit_count)
                     self.run_battle(self.config.bondling_fairyland.battle_config, limit_count=self.limit_count)
                     wait_timer.reset()
                     wait_timer.reset()
@@ -249,8 +256,7 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
 
 
         while 1:
         while 1:
             # 有一种情况是本来要退出的,但是队长邀请了进入的战斗的加载界面
             # 有一种情况是本来要退出的,但是队长邀请了进入的战斗的加载界面
-            if self.appear(self.I_GI_HOME) or self.appear(self.I_GI_EXPLORE) or self.appear(
-                    self.I_CHECK_BONDLING_FAIRYLAND):
+            if self.appear(self.I_GI_HOME) or self.appear(self.I_GI_EXPLORE) or self.appear(self.I_CHECK_BONDLING_FAIRYLAND) or self.appear(self.I_BALL_HELP) :
                 break
                 break
             # 如果可能在房间就退出
             # 如果可能在房间就退出
             if self.exit_room():
             if self.exit_room():
@@ -266,47 +272,50 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
             raise TaskEnd
             raise TaskEnd
 
 
     def switch_ball(self):
     def switch_ball(self):
+        logger.hr('Start switch ball', 2)
         cong = self.config.bondling_fairyland
         cong = self.config.bondling_fairyland
 
 
         bondling_config = cong.bondling_config
         bondling_config = cong.bondling_config
         bondling_switch_soul = cong.bondling_switch_soul
         bondling_switch_soul = cong.bondling_switch_soul
         battle_config = cong.battle_config
         battle_config = cong.battle_config
 
 
-        success = True
+        logger.info(f'抓捕契灵: [{bondling_config.bondling_stone_class}] ')
+        match bondling_config.bondling_stone_class:
+            case BondlingClass.TOMB_GUARD:
+                current_ball_index = 1
+            case BondlingClass.AZURE_BASAN:
+                current_ball_index = 2
+            case BondlingClass.SNOWBALL:
+                current_ball_index = 3
+            case BondlingClass.LITTLE_KURO:
+                current_ball_index = 4
+            case _:
+                current_ball_index = 1
+
         while 1:
         while 1:
-            if not self.first_win:
-                if not self.in_search_ui(screenshot=True):
-                    self.ui_get_current_page()
-                    self.ui_goto(page_bondling_fairyland)
-                    continue
+
+            if not self.in_search_ui(screenshot=True):
+                self.ui_get_current_page()
+                self.ui_goto(page_bondling_fairyland)
+                continue
 
 
             if bondling_config.bondling_mode != BondlingMode.MODE1:
             if bondling_config.bondling_mode != BondlingMode.MODE1:
-                if self.ball_click(self.current_ball_index):
-                    logger.info(f'Current ball number: {self.current_ball_index} ')
+                if self.ball_click(current_ball_index):
+                    logger.info(f'Current ball number: {current_ball_index} ')
                 else:
                 else:
-                    # 如果点击了3次还是没有进去,那可能说明这个位置没有球
-                    if self.current_ball_index == 1:
-                        if self.run_stone(bondling_config.bondling_stone_enable, bondling_config.bondling_stone_class):
-                            self.current_ball_index = 5
-                            continue
-                        else:
-                            break
+                    if self.run_stone(bondling_config.bondling_stone_enable, bondling_config.bondling_stone_class):
+                        continue
                     else:
                     else:
-                        self.current_ball_index -= 1
-                    logger.info(f'Current ball number: {self.current_ball_index} ')
-                    continue
-
+                        logger.info('No bondling stone, exit')
+                        break
                 try:
                 try:
                     # 执行捕捉
                     # 执行捕捉
                     if self.run_catch(bondling_config, bondling_switch_soul, battle_config):
                     if self.run_catch(bondling_config, bondling_switch_soul, battle_config):
-                        logger.info(f'Catch successful and current ball number: {self.current_ball_index} ')
-                        self.first_win = True
+                        logger.info(f'Catch successful and current ball number: {current_ball_index} ')
                     else:
                     else:
                         break
                         break
                 except BondlingNumberMax:
                 except BondlingNumberMax:
                     logger.error('Bondling number max, exit')
                     logger.error('Bondling number max, exit')
-                    self.config.notifier.push(title='契灵之境', content='契灵数量已达上限500,请及时处理')
-                    success = False
                     break
                     break
             else:
             else:
                 # 否则就是模式1
                 # 否则就是模式1
@@ -330,75 +339,33 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
         """
         """
         使用结契石 进行召唤 契灵
         使用结契石 进行召唤 契灵
         :param bondling_stone_class:
         :param bondling_stone_class:
+        :param bondling_stone_enable:
         :return:
         :return:
         (0) 不开启使用结契石,(探查界面)返回False
         (0) 不开启使用结契石,(探查界面)返回False
-        (1) 五个球满了,(探查界面)返回True
-        (2) 没有结契石了,(探查界面)返回False
+        (1) 没有结契石了,(探查界面)返回False
         """
         """
         if not bondling_stone_enable:
         if not bondling_stone_enable:
             return False
             return False
-        self.ui_get_current_page()
-        self.ui_goto(page_bondling_fairyland)
         while 1:
         while 1:
             self.screenshot()
             self.screenshot()
-            # 检查是不是在探查界面,
-            if not self.in_search_ui(screenshot=False):
-                continue
+            if not self.appear(self.I_STONE_SURE):
+                return False
             # 如果没有石头了
             # 如果没有石头了
             cu, res, total = self.O_B_STONE_NUMBER.ocr(self.device.image)
             cu, res, total = self.O_B_STONE_NUMBER.ocr(self.device.image)
             if cu == 0 and cu + res == total:
             if cu == 0 and cu + res == total:
-                logger.warning(f'No bondling stone')
+                logger.warning(f'已经没有鸣契石召唤契灵了')
                 return False
                 return False
-            # 如果五个球满了
-            click_count = 0
             while 1:
             while 1:
                 self.screenshot()
                 self.screenshot()
-                if click_count >= 2:
-                    logger.info(f'Ball is full')
+                if not self.appear(self.I_STONE_SURE):
                     return True
                     return True
-                if not self.appear(self.I_STONE_ENTER):
-                    # 这时进入到了召唤的界面
-                    self.wait_until_appear(self.I_STONE_SURE)
-                    action_click = None
-                    match bondling_stone_class:
-                        case BondlingClass.LITTLE_KURO:
-                            action_click = self.C_LEFT_1
-                        case BondlingClass.SNOWBALL:
-                            action_click = self.C_LEFT_2
-                        case BondlingClass.AZURE_BASAN:
-                            action_click = self.C_LEFT_3
-                        case BondlingClass.TOMB_GUARD:
-                            action_click = self.C_LEFT_4
-                    sleep(0.5)
-                    self.click(action_click)
-
-                    # 点击召唤
-                    while 1:
-                        self.screenshot()
-                        if not self.appear(self.I_STONE_SURE):
-                            break
-                        for i in range(0, 5):
-                            if self.appear_then_click(self.I_BUY_ADD, interval=1):
-                                sleep(0.5)
-                                continue
-                        if self.appear_then_click(self.I_GI_SURE, interval=1):
-                            continue
-                        # current = self.O_B_SUMMON_BALL_NUMBER.ocr(self.device.image)
-                        # try:
-                        #     if int(current) >= 1:
-                        #         if self.appear_then_click(self.I_STONE_SURE, interval=1):
-                        #             continue
-                        # except ValueError:
-                        #     logger.warning(f'No challenge count, exit')
-                        if self.appear_then_click(self.I_STONE_SURE, interval=1):
-                            continue
-
-                    break
-
-                if self.appear_then_click(self.I_STONE_ENTER, interval=1):
-                    click_count += 1
+                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):
                     continue
                     continue
-            return True
 
 
     def run_search(self, bondling_config: BondlingConfig):
     def run_search(self, bondling_config: BondlingConfig):
         """
         """
@@ -439,20 +406,18 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
         (3) 挑战次数到了,返回False (退出页面是结契界面)
         (3) 挑战次数到了,返回False (退出页面是结契界面)
         (4) 捕获成功,返回True (退出页面是捕获的页面)
         (4) 捕获成功,返回True (退出页面是捕获的页面)
         """
         """
-
+        logger.hr('Start run catch', 2)
         self.lock_team()
         self.lock_team()
-        if self.first_catch:
-            self.first_catch = False
-            # self.capture_setting(bondling_config.bondling_mode)
-
-        target_plate = None
-        match bondling_config.bondling_mode:
-            case BondlingMode.MODE2:
-                target_plate = self.O_B_LOW_NUMBER
-            case BondlingMode.MODE3:
-                target_plate = self.O_B_MEDIUM_NUMBER
-
-        def check_plate_number(target_plate):
+
+        def check_plate_number():
+            match bondling_config.bondling_mode:
+                case BondlingMode.MODE2:
+                    target_plate = self.O_B_LOW_NUMBER
+                case BondlingMode.MODE3:
+                    target_plate = self.O_B_MEDIUM_NUMBER
+                case _:
+                    logger.error('Invalid bondling mode')
+                    return False
             self.screenshot()
             self.screenshot()
             cu, res, total = target_plate.ocr(self.device.image)
             cu, res, total = target_plate.ocr(self.device.image)
             if cu == 0 and cu + res == total:
             if cu == 0 and cu + res == total:
@@ -462,56 +427,34 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
 
 
         def check_ball_number():
         def check_ball_number():
             self.screenshot()
             self.screenshot()
-            cu, res, total =  self.O_B_BALL_NUMBER.ocr(self.device.image)
+            cu, res, total = self.O_B_BALL_NUMBER.ocr(self.device.image)
             if cu == 0 and cu + res == total and total == 99:
             if cu == 0 and cu + res == total and total == 99:
                 logger.warning(f'No ball number, exit')
                 logger.warning(f'No ball number, exit')
                 return False
                 return False
             return True
             return True
 
 
-        if not check_plate_number(target_plate):
+        # 检查盘子
+        if not check_plate_number():
             return False
             return False
-
+        # 检查抓捕契灵剩余数量
         if not check_ball_number():
         if not check_ball_number():
             return False
             return False
 
 
-        def switch_soul(bondling_class: BondlingClass):
-            # 按照结契的来切换御魂
-            group_team: str = None
-            match bondling_class:
-                case BondlingClass.AZURE_BASAN:
-                    group_team = bondling_switch_soul.azure_basan_switch
-                case BondlingClass.SNOWBALL:
-                    group_team = bondling_switch_soul.snowball_switch
-                case BondlingClass.LITTLE_KURO:
-                    group_team = bondling_switch_soul.little_kuro_switch
-                case BondlingClass.TOMB_GUARD:
-                    group_team = bondling_switch_soul.tomb_guard_switch
-            group_team = switch_parser(group_team)
-            if group_team == [-1, -1]:
-                logger.info(f'{bondling_class.name} switch soul is not set, skip')
-                return False
-            self.enter_shikigami_records()
-            self.run_switch_soul(tuple(group_team))
-            # 返回的时候可能会多点一次导致 返回到探查界面
-            self.exit_shikigami_records()
-
-        bondling_class = self.get_bondling_class()
-        first_switch_soul = True
-        if bondling_switch_soul.auto_switch_soul:
-            first_switch_soul = False
-            switch_soul(bondling_class)
-
         # 开始执行循环
         # 开始执行循环
         success = True
         success = True
+        logger.hr(f'开始执行战斗循环', 2)
         while 1:
         while 1:
             self.screenshot()
             self.screenshot()
 
 
+            if self.appear(self.I_CHECK_BONDLING_FAIRYLAND):
+                return True
+
             # 如果不在结契界面,就等待
             # 如果不在结契界面,就等待
             if not self.in_catch_ui():
             if not self.in_catch_ui():
                 continue
                 continue
 
 
             # 检查是否有盘子
             # 检查是否有盘子
-            if not check_plate_number(target_plate):
+            if not check_plate_number():
                 logger.warning(f'No plate number, exit')
                 logger.warning(f'No plate number, exit')
                 return False
                 return False
             # 检查是否有挑战次数
             # 检查是否有挑战次数
@@ -528,8 +471,7 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
             match cong.bondling_config.user_status:
             match cong.bondling_config.user_status:
                 case UserStatus.ALONE:
                 case UserStatus.ALONE:
                     self.run_alone()
                     self.run_alone()
-                    if self.run_battle(battle_config, limit_count=self.limit_count):
-                        return success
+                    self.run_battle(battle_config, limit_count=self.limit_count)
                 case _:
                 case _:
                     if self.run_leader():
                     if self.run_leader():
                         return success
                         return success
@@ -543,46 +485,6 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
                 return True
                 return True
         return False
         return False
 
 
-    @cached_property
-    def balls_target(self) -> list[RuleImage]:
-        """
-        获取所有的球的图片
-        :return:
-        """
-        result = [self.I_BF_LOCAL_1_AZURE_BASAN,
-                  self.I_BF_LOCAL_2_SNOWBALL,
-                  self.I_BF_LOCAL_3_LITTLE_KURO,
-                  self.I_BF_LOCAL_5_TOMB_GUARD]
-        return result
-
-    @cached_property
-    def balls_roi(self) -> list[tuple]:
-        """
-        获取球的五个位置是识别区域
-        :return:
-        """
-        result = [self.I_BF_LOCAL_1_AZURE_BASAN.roi_back,
-                  self.I_BF_LOCAL_2_SNOWBALL.roi_back,
-                  self.I_BF_LOCAL_3_LITTLE_KURO.roi_back,
-                  self.I_BF_LOCAL_4_NONE.roi_back,
-                  self.I_BF_LOCAL_5_TOMB_GUARD.roi_back]
-        return result
-
-    def roi_appear_ball(self, roi: tuple, image: np.ndarray) -> tuple | None:
-        """
-        判断某个固定的区域是否出现了球
-        :param roi:
-        :param image:
-        :return: 如果出现了,那就返回可以点击的区域,如果没有出现,那就返回None
-        """
-        for ball in self.balls_target:
-            ball.roi_back = list(roi)
-            if ball.match(image, threshold=0.8):
-                logger.info(f'Find ball {ball.name}')
-                logger.info(f'Ball roi {ball.roi_front}')
-                return ball.roi_front
-        return None
-
     def ball_click(self, index: int) -> bool:
     def ball_click(self, index: int) -> bool:
         """
         """
         点击球, 进去结契战斗的界面
         点击球, 进去结契战斗的界面
@@ -604,10 +506,10 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
 
 
         click_target = get_click_target(index)
         click_target = get_click_target(index)
         click_count = 0
         click_count = 0
-        logger.info(f'Click ball {index}')
+        logger.info(f'Click ball index: {index}')
         while 1:
         while 1:
             self.screenshot()
             self.screenshot()
-            if self.appear(self.I_CLICK_CAPTION):
+            if self.appear(self.I_BALL_HELP):
                 return True
                 return True
             if click_count >= 3:
             if click_count >= 3:
                 return False
                 return False
@@ -731,7 +633,7 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
         click_count = 0
         click_count = 0
         while 1:
         while 1:
             self.screenshot()
             self.screenshot()
-            if not self.appear(self.I_CLICK_CAPTION, threshold=0.7):
+            if not self.appear(self.I_BALL_FIRE, threshold=0.7):
                 break
                 break
             if self.appear_then_click(self.I_BALL_FIRE, interval=1):
             if self.appear_then_click(self.I_BALL_FIRE, interval=1):
                 click_count += 1
                 click_count += 1
@@ -751,8 +653,6 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
         :return: 如果成功进入战斗(反正就是不在房间 )返回 True
         :return: 如果成功进入战斗(反正就是不在房间 )返回 True
                  如果失败了,(退出房间)返回 False
                  如果失败了,(退出房间)返回 False
         """
         """
-        self.timer_emoji = Timer(15)
-        self.timer_emoji.start()
         wait_second = wait_time.second + wait_time.minute * 60
         wait_second = wait_time.second + wait_time.minute * 60
         self.timer_wait = Timer(wait_second)
         self.timer_wait = Timer(wait_second)
         self.timer_wait.start()
         self.timer_wait.start()
@@ -774,25 +674,9 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
 
 
             if self.appear(self.I_EXIT):
             if self.appear(self.I_EXIT):
                 success = True
                 success = True
-                logger.info("契灵:进入战斗页面!")
+                logger.info("契灵:已经在战斗场景中")
                 break
                 break
 
 
-            # # 判断是否进入战斗
-            # if self.is_in_room(is_screenshot=False):
-            #     logger.info("契灵:进入组队房间!")
-            #     if self.timer_emoji.reached():
-            #         self.timer_emoji.reset()
-            #         self.appear_then_click(self.I_GI_EMOJI_1)
-            #         self.appear_then_click(self.I_GI_EMOJI_2)
-            # else:
-            #     if self.appear(self.I_EXIT):
-            #         logger.info("契灵:进入战斗页面!")
-            #         break
-            #     if self.appear(self.I_CHECK_BONDLING_FAIRYLAND):
-            #         logger.info("契灵:探查页面!")
-            #         success = False
-            #         break
-
         # 调出循环只有这些可能性:
         # 调出循环只有这些可能性:
         # 1. 进入战斗(ui是战斗)
         # 1. 进入战斗(ui是战斗)
         # 2. 队长跑路(自己还是在房间里面)
         # 2. 队长跑路(自己还是在房间里面)
@@ -864,27 +748,28 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
         """
         """
         if not self.appear(self.I_I_ACCEPT):
         if not self.appear(self.I_I_ACCEPT):
             return False
             return False
+        if self.appear(self.I_I_ACCEPT_JY):
+            logger.info('appear accept_jy')
+            return False
         logger.info('Click accept')
         logger.info('Click accept')
 
 
         accept_timer = Timer(5)
         accept_timer = Timer(5)
         accept_timer.start()
         accept_timer.start()
-        logger.info("识别到队长邀请,准备点击接受")
+        logger.info("识别到队长邀请,准备点击接受....")
         while 1:
         while 1:
             self.screenshot()
             self.screenshot()
 
 
-            # 等待超时
-            logger.info(str(accept_timer.current()))
             if accept_timer.reached():
             if accept_timer.reached():
-                logger.warning('accept_timer timeout')
+                logger.info(f"队员点击接受超时:{accept_timer.current()}, 退出")
                 break
                 break
 
 
             if self.is_in_room():
             if self.is_in_room():
-                logger.info("进入到组队房间!is_in_room")
+                logger.info("契灵:已经在组队房间中")
                 return True
                 return True
             # 被秒开
             # 被秒开
             # https://github.com/runhey/OnmyojiAutoScript/issues/230
             # https://github.com/runhey/OnmyojiAutoScript/issues/230
             if self.appear(GeneralBattleAssets.I_EXIT):
             if self.appear(GeneralBattleAssets.I_EXIT):
-                logger.info("进入到组队房间!")
+                logger.info("已经在战斗场景中")
                 return False
                 return False
             if self.appear_then_click(self.I_I_NO_DEFAULT, interval=1):
             if self.appear_then_click(self.I_I_NO_DEFAULT, interval=1):
                 continue
                 continue
@@ -909,15 +794,15 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
 if __name__ == '__main__':
 if __name__ == '__main__':
     from module.config.config import Config
     from module.config.config import Config
     from module.device.device import Device
     from module.device.device import Device
-    import cv2
 
 
-    config = Config('oas1')
+    config = Config('SWITCH')
     device = Device(config)
     device = Device(config)
-    task = ScriptTask(config, device)
+    t = ScriptTask(config, device)
+    t.run()
     # image = task.screenshot()
     # image = task.screenshot()
 
 
     # con = config.bondling_fairyland
     # con = config.bondling_fairyland
     # task.lock_team()
     # task.lock_team()
-    task.run()
-    # task.run_stone(True,BondlingClass.TOMB_GUARD)
+    # t.switch_ball()
+    # t.run_stone(True,BondlingClass.TOMB_GUARD)
     # task.run_invite(config=config.bondling_fairyland.invite_config, is_over=False, is_first=True)
     # task.run_invite(config=config.bondling_fairyland.invite_config, is_over=False, is_first=True)

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

@@ -93,6 +93,8 @@ class GeneralInviteAssets:
 	I_GI_IN_ROOM = RuleImage(roi_front=(92,17,213,64), roi_back=(92,17,213,64), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralInvite/gi/gi_gi_in_room.png")
 	I_GI_IN_ROOM = RuleImage(roi_front=(92,17,213,64), roi_back=(92,17,213,64), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralInvite/gi/gi_gi_in_room.png")
 	# description 
 	# description 
 	I_BACK_YELLOW_SEA = RuleImage(roi_front=(31,16,42,42), roi_back=(31,16,42,42), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralInvite/gi/gi_back_yellow_sea.png")
 	I_BACK_YELLOW_SEA = RuleImage(roi_front=(31,16,42,42), roi_back=(31,16,42,42), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralInvite/gi/gi_back_yellow_sea.png")
+	# 识别到寄养邀请 
+	I_I_ACCEPT_JY = RuleImage(roi_front=(248,258,46,25), roi_back=(231,205,75,326), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralInvite/gi/gi_i_accept_jy.png")
 
 
 
 
 	# Image Rule Assets
 	# Image Rule Assets

+ 9 - 0
tasks/Component/GeneralInvite/gi/image.json

@@ -367,5 +367,14 @@
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "description"
     "description": "description"
+  },
+  {
+    "itemName": "i_accept_jy",
+    "imageName": "gi_i_accept_jy.png",
+    "roiFront": "248,258,46,25",
+    "roiBack": "231,205,75,326",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "识别到寄养邀请"
   }
   }
 ]
 ]

+ 4 - 2
tasks/Component/ReplaceShikigami/assets.py

@@ -75,10 +75,12 @@ class ReplaceShikigamiAssets:
 	I_RS_SSR_SELECTED = RuleImage(roi_front=(29,622,66,59), roi_back=(29,622,66,59), threshold=0.8, method="Template matching", file="./tasks/Component/ReplaceShikigami/rs/rs_rs_ssr_selected.png")
 	I_RS_SSR_SELECTED = RuleImage(roi_front=(29,622,66,59), roi_back=(29,622,66,59), threshold=0.8, method="Template matching", file="./tasks/Component/ReplaceShikigami/rs/rs_rs_ssr_selected.png")
 	# description 
 	# description 
 	I_RS_SP_SELECTED = RuleImage(roi_front=(31,622,62,59), roi_back=(31,622,62,59), threshold=0.8, method="Template matching", file="./tasks/Component/ReplaceShikigami/rs/rs_rs_sp_selected.png")
 	I_RS_SP_SELECTED = RuleImage(roi_front=(31,622,62,59), roi_back=(31,622,62,59), threshold=0.8, method="Template matching", file="./tasks/Component/ReplaceShikigami/rs/rs_rs_sp_selected.png")
-	# description 
-	I_RS_RECORDS_SHIKI = RuleImage(roi_front=(1148,548,49,43), roi_back=(1148,548,49,43), threshold=0.8, method="Template matching", file="./tasks/Component/ReplaceShikigami/rs/rs_rs_records_shiki.png")
+	# 式神录按钮 
+	I_RS_RECORDS_SHIKI = RuleImage(roi_front=(1148,548,49,43), roi_back=(1145,548,55,90), threshold=0.8, method="Template matching", file="./tasks/Component/ReplaceShikigami/rs/rs_rs_records_shiki.png")
 	# 检测到已经满级了 
 	# 检测到已经满级了 
 	I_RS_LEVEL_MAX = RuleImage(roi_front=(487,248,23,21), roi_back=(52,238,1118,37), threshold=0.8, method="Template matching", file="./tasks/Component/ReplaceShikigami/rs/rs_rs_level_max.png")
 	I_RS_LEVEL_MAX = RuleImage(roi_front=(487,248,23,21), roi_back=(52,238,1118,37), threshold=0.8, method="Template matching", file="./tasks/Component/ReplaceShikigami/rs/rs_rs_level_max.png")
+	# 智能放入 
+	I_RS_SMART_EXCHANGE = RuleImage(roi_front=(1150,507,40,44), roi_back=(1128,488,86,162), threshold=0.8, method="Template matching", file="./tasks/Component/ReplaceShikigami/rs/rs_rs_smart_exchange.png")
 
 
 
 
 	# Image Rule Assets
 	# Image Rule Assets

+ 11 - 2
tasks/Component/ReplaceShikigami/rs/image.json

@@ -120,10 +120,10 @@
     "itemName": "rs_records_shiki",
     "itemName": "rs_records_shiki",
     "imageName": "rs_rs_records_shiki.png",
     "imageName": "rs_rs_records_shiki.png",
     "roiFront": "1148,548,49,43",
     "roiFront": "1148,548,49,43",
-    "roiBack": "1148,548,49,43",
+    "roiBack": "1145,548,55,90",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
-    "description": "description"
+    "description": "式神录按钮"
   },
   },
   {
   {
     "itemName": "rs_level_max",
     "itemName": "rs_level_max",
@@ -133,5 +133,14 @@
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "检测到已经满级了"
     "description": "检测到已经满级了"
+  },
+  {
+    "itemName": "rs_smart_exchange",
+    "imageName": "rs_rs_smart_exchange.png",
+    "roiFront": "1150,507,40,44",
+    "roiBack": "1128,488,86,162",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "智能放入"
   }
   }
 ]
 ]

BIN
tasks/Component/ReplaceShikigami/rs/rs_rs_smart_exchange.png


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

@@ -15,5 +15,7 @@ class RightActivityAssets:
 	I_RA_OPEN = RuleImage(roi_front=(1257,78,22,58), roi_back=(1257,78,22,58), threshold=0.8, method="Template matching", file="./tasks/Component/RightActivity/ra/ra_ra_open.png")
 	I_RA_OPEN = RuleImage(roi_front=(1257,78,22,58), roi_back=(1257,78,22,58), threshold=0.8, method="Template matching", file="./tasks/Component/RightActivity/ra/ra_ra_open.png")
 	# description 
 	# description 
 	I_RA_CLOSE = RuleImage(roi_front=(1256,123,23,44), roi_back=(1256,123,23,44), threshold=0.8, method="Template matching", file="./tasks/Component/RightActivity/ra/ra_ra_close.png")
 	I_RA_CLOSE = RuleImage(roi_front=(1256,123,23,44), roi_back=(1256,123,23,44), threshold=0.8, method="Template matching", file="./tasks/Component/RightActivity/ra/ra_ra_close.png")
+	# description 
+	I_TOGGLE_BUTTON = RuleImage(roi_front=(1193,463,27,25), roi_back=(1169,146,73,403), threshold=0.8, method="Template matching", file="./tasks/Component/RightActivity/ra/as_toggle_button.png")
 
 
 
 

BIN
tasks/Component/RightActivity/ra/as_toggle_button.png


+ 9 - 0
tasks/Component/RightActivity/ra/image.json

@@ -16,5 +16,14 @@
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "description"
     "description": "description"
+  },
+  {
+    "itemName": "toggle_button",
+    "imageName": "as_toggle_button.png",
+    "roiFront": "1193,463,27,25",
+    "roiBack": "1169,146,73,403",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
   }
   }
 ]
 ]

+ 2 - 1
tasks/Component/RightActivity/right_activity.py

@@ -15,7 +15,8 @@ class RightActivity(GameUi, RightActivityAssets):
         self.ui_get_current_page()
         self.ui_get_current_page()
         self.ui_goto(page_main)
         self.ui_goto(page_main)
 
 
-        self.ui_click_until_disappear(target, interval=3.5)
+        self.ui_click(self.I_TOGGLE_BUTTON, target, interval=2)
+        self.ui_click_until_disappear(target, interval=3)
 
 
     def right_open(self):
     def right_open(self):
         self.ui_click(self.I_RA_CLOSE, self.I_RA_OPEN, interval=2)
         self.ui_click(self.I_RA_CLOSE, self.I_RA_OPEN, interval=2)

+ 2 - 1
tasks/Component/SwitchSoul/switch_soul.py

@@ -136,7 +136,8 @@ class SwitchSoul(BaseTask, SwitchSoulAssets):
                 continue
                 continue
             if not self.appear_then_click(target_team, interval=3):
             if not self.appear_then_click(target_team, interval=3):
                 logger.warning(f'Click team {team} failed in group {group}')
                 logger.warning(f'Click team {team} failed in group {group}')
-
+        # 兜底若还出现确认按钮则点击
+        self.ui_click_until_disappear(self.I_SOU_SWITCH_SURE)
         logger.info(f'Switch soul_one group {group} team {team}')
         logger.info(f'Switch soul_one group {group} team {team}')
 
 
     def switch_souls(self, target: tuple or list[tuple]) -> None:
     def switch_souls(self, target: tuple or list[tuple]) -> None:

BIN
tasks/DemonRetreat/DemonRetreat/DemonRetreat_hunt.png


+ 1 - 1
tasks/DemonRetreat/DemonRetreat/image.json

@@ -11,7 +11,7 @@
   {
   {
     "itemName": "hunt",
     "itemName": "hunt",
     "imageName": "DemonRetreat_hunt.png",
     "imageName": "DemonRetreat_hunt.png",
-    "roiFront": "661,164,187,165",
+    "roiFront": "698,228,122,78",
     "roiBack": "661,164,187,165",
     "roiBack": "661,164,187,165",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,

+ 1 - 1
tasks/DemonRetreat/assets.py

@@ -14,7 +14,7 @@ class DemonRetreatAssets:
 	# 神社 
 	# 神社 
 	I_SHRINE = RuleImage(roi_front=(870,624,65,61), roi_back=(870,624,65,61), threshold=0.8, method="Template matching", file="./tasks/DemonRetreat/DemonRetreat/DemonRetreat_shrine.png")
 	I_SHRINE = RuleImage(roi_front=(870,624,65,61), roi_back=(870,624,65,61), threshold=0.8, method="Template matching", file="./tasks/DemonRetreat/DemonRetreat/DemonRetreat_shrine.png")
 	# 首领退治 
 	# 首领退治 
-	I_HUNT = RuleImage(roi_front=(661,164,187,165), roi_back=(661,164,187,165), threshold=0.8, method="Template matching", file="./tasks/DemonRetreat/DemonRetreat/DemonRetreat_hunt.png")
+	I_HUNT = RuleImage(roi_front=(698,228,122,78), roi_back=(661,164,187,165), threshold=0.8, method="Template matching", file="./tasks/DemonRetreat/DemonRetreat/DemonRetreat_hunt.png")
 	# 检查是否成功进入首领退治 
 	# 检查是否成功进入首领退治 
 	I_HUNT_CHECK = RuleImage(roi_front=(570,12,143,46), roi_back=(570,12,143,46), threshold=0.8, method="Template matching", file="./tasks/DemonRetreat/DemonRetreat/DemonRetreat_hunt_check.png")
 	I_HUNT_CHECK = RuleImage(roi_front=(570,12,143,46), roi_back=(570,12,143,46), threshold=0.8, method="Template matching", file="./tasks/DemonRetreat/DemonRetreat/DemonRetreat_hunt_check.png")
 	# description 
 	# description 

+ 1 - 1
tasks/Dokan/assets.py

@@ -115,7 +115,7 @@ class DokanAssets:
 	# 场景检测:阴阳竂 
 	# 场景检测:阴阳竂 
 	I_SCENE_RYOU = RuleImage(roi_front=(1161,674,75,31), roi_back=(1161,674,75,31), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/scene_ryou.png")
 	I_SCENE_RYOU = RuleImage(roi_front=(1161,674,75,31), roi_back=(1161,674,75,31), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/scene_ryou.png")
 	# 场景检测:神社 
 	# 场景检测:神社 
-	I_SCENE_SHENSHE = RuleImage(roi_front=(477,165,63,65), roi_back=(477,165,63,65), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/scene_shenshe.png")
+	I_SCENE_SHENSHE = RuleImage(roi_front=(477,165,63,65), roi_back=(477,165,65,80), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/scene_shenshe.png")
 	# 道馆 地图界面 建立道馆按钮 
 	# 道馆 地图界面 建立道馆按钮 
 	I_RYOU_DOKAN_CREATE_DOKAN = RuleImage(roi_front=(230,580,130,120), roi_back=(230,580,130,120), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_create_dokan.png")
 	I_RYOU_DOKAN_CREATE_DOKAN = RuleImage(roi_front=(230,580,130,120), roi_back=(230,580,130,120), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_create_dokan.png")
 	# 道馆 地图界面 点击建立道馆按钮后弹窗中的 确认按钮 
 	# 道馆 地图界面 点击建立道馆按钮后弹窗中的 确认按钮 

+ 1 - 1
tasks/Dokan/res/image.json

@@ -363,7 +363,7 @@
     "itemName": "scene_shenshe",
     "itemName": "scene_shenshe",
     "imageName": "scene_shenshe.png",
     "imageName": "scene_shenshe.png",
     "roiFront": "477,165,63,65",
     "roiFront": "477,165,63,65",
-    "roiBack": "477,165,63,65",
+    "roiBack": "477,165,65,80",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "场景检测:神社"
     "description": "场景检测:神社"

+ 4 - 2
tasks/FrogBoss/script_task.py

@@ -93,6 +93,7 @@ class ScriptTask(RightActivity, FrogBossAssets, GeneralBattleAssets):
     def do_bet(self):
     def do_bet(self):
         logger.hr('do bet', level=2)
         logger.hr('do bet', level=2)
         self.screenshot()
         self.screenshot()
+        flag_glod_30 = 0
         count_left = self.O_LEFT_COUNT.ocr(self.device.image)
         count_left = self.O_LEFT_COUNT.ocr(self.device.image)
         count_right = self.O_RIGHT_COUNT.ocr(self.device.image)
         count_right = self.O_RIGHT_COUNT.ocr(self.device.image)
         match self.config.model.frog_boss.frog_boss_config.strategy_frog:
         match self.config.model.frog_boss.frog_boss_config.strategy_frog:
@@ -125,9 +126,10 @@ class ScriptTask(RightActivity, FrogBossAssets, GeneralBattleAssets):
             self.screenshot()
             self.screenshot()
             if self.appear(self.I_BETTED):
             if self.appear(self.I_BETTED):
                 break
                 break
-            if self.appear_then_click(self.I_GOLD_30, interval=2):
+            if self.appear_then_click(self.I_BET_SURE, interval=2) and flag_glod_30 == 1:
                 continue
                 continue
-            if self.appear_then_click(self.I_BET_SURE, interval=2):
+            if self.appear_then_click(self.I_GOLD_30, interval=2):
+                flag_glod_30 = 1
                 continue
                 continue
             if self.appear_then_click(self.I_UI_CONFIRM, interval=2):
             if self.appear_then_click(self.I_UI_CONFIRM, interval=2):
                 continue
                 continue

+ 1 - 1
tasks/GameUi/assets.py

@@ -38,7 +38,7 @@ class GameUiAssets:
 
 
 	# Image Rule Assets
 	# Image Rule Assets
 	# description 
 	# description 
-	I_CHECK_MAIN = RuleImage(roi_front=(801,109,38,37), roi_back=(49,98,1033,61), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_check_main.png")
+	I_CHECK_MAIN = RuleImage(roi_front=(807,108,76,45), roi_back=(49,98,1033,61), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_check_main.png")
 	# 庭院卷轴关闭标识 
 	# 庭院卷轴关闭标识 
 	I_MAIN_SCROLL_CLOSE = RuleImage(roi_front=(1181,634,28,39), roi_back=(1162,595,77,112), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_main_scroll_close.png")
 	I_MAIN_SCROLL_CLOSE = RuleImage(roi_front=(1181,634,28,39), roi_back=(1162,595,77,112), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_main_scroll_close.png")
 	# description 
 	# description 

BIN
tasks/GameUi/page/page_check_main.png


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

@@ -2,7 +2,7 @@
   {
   {
     "itemName": "check_main",
     "itemName": "check_main",
     "imageName": "page_check_main.png",
     "imageName": "page_check_main.png",
-    "roiFront": "801,109,38,37",
+    "roiFront": "807,108,76,45",
     "roiBack": "49,98,1033,61",
     "roiBack": "49,98,1033,61",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,

+ 9 - 7
tasks/Hyakkiyakou/assets.py

@@ -149,13 +149,13 @@ class HyakkiyakouAssets:
 
 
 	# Image Rule Assets
 	# Image Rule Assets
 	# description 
 	# description 
-	I_FRIEND_SAME_1 = RuleImage(roi_front=(375,122,106,62), roi_back=(375,122,106,62), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_friend_same_1.png")
+	I_FRIEND_SAME_1 = RuleImage(roi_front=(349,124,83,50), roi_back=(349,124,83,50), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_friend_same_1.png")
 	# description 
 	# description 
-	I_FRIEND_REMOTE_1 = RuleImage(roi_front=(498,125,106,56), roi_back=(498,125,106,56), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_friend_remote_1.png")
+	I_FRIEND_REMOTE_1 = RuleImage(roi_front=(444,127,81,46), roi_back=(444,127,81,46), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_friend_remote_1.png")
 	# description 
 	# description 
-	I_FRIEND_SAME_2 = RuleImage(roi_front=(377,126,100,60), roi_back=(377,126,100,60), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_friend_same_2.png")
+	I_FRIEND_SAME_2 = RuleImage(roi_front=(355,125,80,47), roi_back=(355,125,80,47), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_friend_same_2.png")
 	# description 
 	# description 
-	I_FRIEND_REMOTE_2 = RuleImage(roi_front=(504,127,100,56), roi_back=(504,127,100,56), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_friend_remote_2.png")
+	I_FRIEND_REMOTE_2 = RuleImage(roi_front=(440,122,89,56), roi_back=(440,122,89,56), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_friend_remote_2.png")
 	# 回归活动使用 
 	# 回归活动使用 
 	I_FRIEND_SAME_1_RECALL = RuleImage(roi_front=(167,123,106,62), roi_back=(154,105,132,94), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_friend_same_1.png")
 	I_FRIEND_SAME_1_RECALL = RuleImage(roi_front=(167,123,106,62), roi_back=(154,105,132,94), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_friend_same_1.png")
 	# 回归活动使用 
 	# 回归活动使用 
@@ -164,10 +164,12 @@ class HyakkiyakouAssets:
 	I_FRIEND_SAME_2_RECALL = RuleImage(roi_front=(168,126,100,60), roi_back=(152,112,133,80), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_friend_same_2.png")
 	I_FRIEND_SAME_2_RECALL = RuleImage(roi_front=(168,126,100,60), roi_back=(152,112,133,80), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_friend_same_2.png")
 	# 回归活动使用 
 	# 回归活动使用 
 	I_FRIEND_REMOTE_2_RECALL = RuleImage(roi_front=(296,122,100,56), roi_back=(278,115,131,81), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_friend_remote_2.png")
 	I_FRIEND_REMOTE_2_RECALL = RuleImage(roi_front=(296,122,100,56), roi_back=(278,115,131,81), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_friend_remote_2.png")
+	# 寮 
+	I_FRIEND_RYOU_1 = RuleImage(roi_front=(537,126,80,45), roi_back=(537,126,80,45), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_friend_ryou_1.png")
 	# description 
 	# description 
-	I_FRIEND_RYOU_1 = RuleImage(roi_front=(328,128,80,45), roi_back=(328,128,80,45), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_friend_ryou_1.png")
-	# description 
-	I_FRIEND_RYOU_2 = RuleImage(roi_front=(328,128,80,45), roi_back=(328,128,80,45), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_friend_ryou_2.png")
+	I_FRIEND_RYOU_2 = RuleImage(roi_front=(536,127,80,45), roi_back=(536,127,80,45), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_friend_ryou_2.png")
+	# 判断是否进入邀请页面 
+	I_CHECK_INVITATION = RuleImage(roi_front=(629,140,272,57), roi_back=(308,113,826,100), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_check_invitation.png")
 
 
 
 
 	# Ocr Rule Assets
 	# Ocr Rule Assets

BIN
tasks/Hyakkiyakou/hya/hya_friend_remote_1.png


BIN
tasks/Hyakkiyakou/hya/hya_friend_remote_2.png


BIN
tasks/Hyakkiyakou/hya/hya_friend_ryou_1.png


BIN
tasks/Hyakkiyakou/hya/hya_friend_ryou_2.png


BIN
tasks/Hyakkiyakou/hya/hya_friend_same_1.png


BIN
tasks/Hyakkiyakou/hya/hya_friend_same_2.png


+ 22 - 13
tasks/Hyakkiyakou/hya/image5.json

@@ -2,8 +2,8 @@
   {
   {
     "itemName": "friend_same_1",
     "itemName": "friend_same_1",
     "imageName": "hya_friend_same_1.png",
     "imageName": "hya_friend_same_1.png",
-    "roiFront": "375,122,106,62",
-    "roiBack": "375,122,106,62",
+    "roiFront": "349,124,83,50",
+    "roiBack": "349,124,83,50",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "description"
     "description": "description"
@@ -11,8 +11,8 @@
   {
   {
     "itemName": "friend_remote_1",
     "itemName": "friend_remote_1",
     "imageName": "hya_friend_remote_1.png",
     "imageName": "hya_friend_remote_1.png",
-    "roiFront": "498,125,106,56",
-    "roiBack": "498,125,106,56",
+    "roiFront": "444,127,81,46",
+    "roiBack": "444,127,81,46",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "description"
     "description": "description"
@@ -20,8 +20,8 @@
   {
   {
     "itemName": "friend_same_2",
     "itemName": "friend_same_2",
     "imageName": "hya_friend_same_2.png",
     "imageName": "hya_friend_same_2.png",
-    "roiFront": "377,126,100,60",
-    "roiBack": "377,126,100,60",
+    "roiFront": "355,125,80,47",
+    "roiBack": "355,125,80,47",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "description"
     "description": "description"
@@ -29,8 +29,8 @@
   {
   {
     "itemName": "friend_remote_2",
     "itemName": "friend_remote_2",
     "imageName": "hya_friend_remote_2.png",
     "imageName": "hya_friend_remote_2.png",
-    "roiFront": "504,127,100,56",
-    "roiBack": "504,127,100,56",
+    "roiFront": "440,122,89,56",
+    "roiBack": "440,122,89,56",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "description"
     "description": "description"
@@ -74,19 +74,28 @@
   {
   {
     "itemName": "friend_ryou_1",
     "itemName": "friend_ryou_1",
     "imageName": "hya_friend_ryou_1.png",
     "imageName": "hya_friend_ryou_1.png",
-    "roiFront": "328,128,80,45",
-    "roiBack": "328,128,80,45",
+    "roiFront": "537,126,80,45",
+    "roiBack": "537,126,80,45",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
-    "description": "description"
+    "description": "寮"
   },
   },
   {
   {
     "itemName": "friend_ryou_2",
     "itemName": "friend_ryou_2",
     "imageName": "hya_friend_ryou_2.png",
     "imageName": "hya_friend_ryou_2.png",
-    "roiFront": "328,128,80,45",
-    "roiBack": "328,128,80,45",
+    "roiFront": "536,127,80,45",
+    "roiBack": "536,127,80,45",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "description"
     "description": "description"
+  },
+  {
+    "itemName": "check_invitation",
+    "imageName": "hya_check_invitation.png",
+    "roiFront": "629,140,272,57",
+    "roiBack": "308,113,826,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "判断是否进入邀请页面"
   }
   }
 ]
 ]

+ 1 - 1
tasks/Hyakkiyakou/script_task.py

@@ -155,7 +155,7 @@ class ScriptTask(GameUi, HyaSlave):
         if not self.appear(self.I_HACCESS):
         if not self.appear(self.I_HACCESS):
             logger.warning('Page Error')
             logger.warning('Page Error')
         if self._config.hyakkiyakou_config.hya_invite_friend:
         if self._config.hyakkiyakou_config.hya_invite_friend:
-            self.invite_friend(True)
+            self.invite_friend()
         # start
         # start
         self.ui_click(self.I_HACCESS, self.I_HSTART, interval=2)
         self.ui_click(self.I_HACCESS, self.I_HSTART, interval=2)
         self.wait_until_appear(self.I_HTITLE)
         self.wait_until_appear(self.I_HTITLE)

+ 41 - 27
tasks/Hyakkiyakou/slave/hya_slave.py

@@ -214,34 +214,48 @@ class HyaSlave(HyaDevice, HyaColor, HyakkiyakouAssets):
     # main process
     # main process
     # ------------------------------------------------------------------------------------------------------------------
     # ------------------------------------------------------------------------------------------------------------------
 
 
-    def invite_friend(self, same: bool = True):
+    def invite_friend(self):
         logger.hr('Invite friend', 2)
         logger.hr('Invite friend', 2)
-        hya_recall_activity = False
-        while 1:
-            self.screenshot()
-            # 是否有召回活动(星重聚阴阳师)
-            if self.appear(self.I_ENSURE_RECALL):
-                hya_recall_activity = True
-            if hya_recall_activity:
-                if self.appear(self.I_FRIEND_SAME_1_RECALL) or self.appear(self.I_FRIEND_SAME_2_RECALL) or self.appear(self.I_FRIEND_RYOU_1):
-                    break
-            else:
-                if self.appear(self.I_FRIEND_SAME_1) or self.appear(self.I_FRIEND_SAME_2):
-                    break
-            if self.appear_then_click(self.I_HINVITE, interval=4):
-                continue
-        if not self._invite_friend(same=True, hya_recall_activity=hya_recall_activity):
-            if not self._invite_friend(same=False, hya_recall_activity=hya_recall_activity):
-                raise RequestHumanTakeover('Invite friend failed')
-
-    def _invite_friend(self, same: bool = True, hya_recall_activity: bool = False) -> bool:
-        if not same:
-            logger.info('Invite different server friend')
-            # 是否有召回活动
-            if hya_recall_activity:
-                self.ui_click(self.I_FRIEND_REMOTE_1_RECALL, self.I_FRIEND_REMOTE_2_RECALL)
-            else:
-                self.ui_click(self.I_FRIEND_REMOTE_1, self.I_FRIEND_REMOTE_2)
+        self.ui_click(self.I_HINVITE, self.I_CHECK_INVITATION, interval=4)
+        logger.info('Entry check invitation')
+
+        # 是否有召回活动(星重聚阴阳师)
+        if self.appear(self.I_ENSURE_RECALL):
+            hya_recall_activity = True
+            # 应该动态改roi而不是新开一个图
+            friend_buttons1 = [self.I_FRIEND_SAME_1_RECALL, self.I_FRIEND_REMOTE_1_RECALL, ]
+            friend_buttons2 = [self.I_FRIEND_SAME_2_RECALL, self.I_FRIEND_REMOTE_2_RECALL, ]
+        else:
+            hya_recall_activity = False
+            friend_buttons1 = [self.I_FRIEND_SAME_1, self.I_FRIEND_REMOTE_1, self.I_FRIEND_RYOU_1]
+            friend_buttons2 = [self.I_FRIEND_SAME_2, self.I_FRIEND_REMOTE_2, self.I_FRIEND_RYOU_2]
+        # 依次邀请,
+        self.friend_state = 0  # 不需要每一次都从0开始,可以固定一下
+        while self.friend_state < 3:
+            match self.friend_state:
+                case 0:
+                    logger.info('Invite same server friend')
+                    if not self._invite_friend(button1=friend_buttons1[0], button2=friend_buttons2[0], hya_recall_activity=hya_recall_activity):
+                        self.friend_state += 1
+                    else:
+                        return True
+                case 1:
+                    logger.info('Invite remote friend')
+                    if not self._invite_friend(button1=friend_buttons1[1], button2=friend_buttons2[1], hya_recall_activity=hya_recall_activity):
+                        self.friend_state += 1
+                    else:
+                        return True
+                case 2:
+                    logger.info('Invite guild friend')
+                    if not self._invite_friend(button1=friend_buttons1[2], button2=friend_buttons2[2], hya_recall_activity=hya_recall_activity):
+                        self.friend_state += 1
+                    else:
+                        return True
+                case _:
+                    raise RequestHumanTakeover('Invite friend failed')
+
+    def _invite_friend(self, button1: RuleImage, button2: RuleImage, hya_recall_activity: bool = False ) -> bool:
+        self.ui_click(button1, button2)
         invite_timer = Timer(8)
         invite_timer = Timer(8)
         invite_timer.start()
         invite_timer.start()
         while 1:
         while 1:

+ 1 - 0
tasks/KekkaiActivation/config.py

@@ -20,6 +20,7 @@ class ActivationConfig(BaseModel):
     card_rule: MultiLine = Field(default='auto', description='card_rule_help')
     card_rule: MultiLine = Field(default='auto', description='card_rule_help')
     exchange_before: bool = Field(default=True, description='exchange_before_help')
     exchange_before: bool = Field(default=True, description='exchange_before_help')
     exchange_max: bool = Field(default=True, description='exchange_max_help')
     exchange_max: bool = Field(default=True, description='exchange_max_help')
+    exchange_smart: bool = Field(default=False, description='是否启用智能放入')
     shikigami_class: ShikigamiClass = Field(default=ShikigamiClass.N, description='shikigami_class_help')
     shikigami_class: ShikigamiClass = Field(default=ShikigamiClass.N, description='shikigami_class_help')
 
 
 
 

+ 9 - 5
tasks/KekkaiActivation/script_task.py

@@ -30,7 +30,7 @@ class ScriptTask(KU, KekkaiActivationAssets):
         # 进入寮结界
         # 进入寮结界
         self.goto_realm()
         self.goto_realm()
         if con.exchange_before:
         if con.exchange_before:
-            self.check_max_lv(con.shikigami_class)
+            self.check_max_lv(con)
         self.harvest_card()
         self.harvest_card()
 
 
         self.run_activation(con)
         self.run_activation(con)
@@ -45,7 +45,7 @@ class ScriptTask(KU, KekkaiActivationAssets):
                 continue
                 continue
 
 
         if con.exchange_max:
         if con.exchange_max:
-            self.check_max_lv(con.shikigami_class)
+            self.check_max_lv(con)
         self.back_guild()
         self.back_guild()
 
 
         raise TaskEnd('KekkaiActivation')
         raise TaskEnd('KekkaiActivation')
@@ -340,24 +340,28 @@ class ScriptTask(KU, KekkaiActivationAssets):
         self.appear_then_click(target, interval=0.5)
         self.appear_then_click(target, interval=0.5)
         return current_card
         return current_card
 
 
-    def check_max_lv(self, shikigami_class: ShikigamiClass = ShikigamiClass.N):
+    def check_max_lv(self, con: ActivationConfig):
         """
         """
         在结界界面,进入式神育成,检查是否有满级的,如果有就换下一个
         在结界界面,进入式神育成,检查是否有满级的,如果有就换下一个
         退出的时候还是结界界面
         退出的时候还是结界界面
         :return:
         :return:
         """
         """
         self.realm_goto_grown()
         self.realm_goto_grown()
+        # 直接进行智能放入
+        if con.exchange_smart:
+            logger.info('Smart exchange')
+            self.ui_click_until_disappear(self.I_RS_SMART_EXCHANGE)
         if self.appear(self.I_RS_LEVEL_MAX):
         if self.appear(self.I_RS_LEVEL_MAX):
             # 存在满级的式神
             # 存在满级的式神
             logger.info('Exist max level shikigami and replace it')
             logger.info('Exist max level shikigami and replace it')
             self.unset_shikigami_max_lv()
             self.unset_shikigami_max_lv()
-            self.switch_shikigami_class(shikigami_class)
+            self.switch_shikigami_class(con.shikigami_class)
             self.set_shikigami(shikigami_order=7, stop_image=self.I_RS_NO_ADD)
             self.set_shikigami(shikigami_order=7, stop_image=self.I_RS_NO_ADD)
         else:
         else:
             logger.info('No max level shikigami')
             logger.info('No max level shikigami')
         if self.detect_no_shikigami():
         if self.detect_no_shikigami():
             logger.warning('There are no any shikigami grow room')
             logger.warning('There are no any shikigami grow room')
-            self.switch_shikigami_class(shikigami_class)
+            self.switch_shikigami_class(con.shikigami_class)
             self.set_shikigami(shikigami_order=7, stop_image=self.I_RS_NO_ADD)
             self.set_shikigami(shikigami_order=7, stop_image=self.I_RS_NO_ADD)
 
 
         # 回到结界界面
         # 回到结界界面

+ 2 - 1
tasks/Restart/config_scheduler.py

@@ -5,11 +5,12 @@ from enum import Enum
 from datetime import datetime, time
 from datetime import datetime, time
 from pydantic import BaseModel, ValidationError, validator, Field
 from pydantic import BaseModel, ValidationError, validator, Field
 from tasks.Component.config_scheduler import Scheduler
 from tasks.Component.config_scheduler import Scheduler
+from tasks.Component.config_base import Time
 
 
 from module.logger import logger
 from module.logger import logger
 
 
 class RestartScheduler(Scheduler):
 class RestartScheduler(Scheduler):
     enable: bool = Field(default=True, description='enable_help')
     enable: bool = Field(default=True, description='enable_help')
     priority: int = Field(default=0, description='priority_help')
     priority: int = Field(default=0, description='priority_help')
-    server_update: time = Field(default=time(hour=9, minute=5, second=0), description='server_update_help')
+    server_update: Time = Field(default=Time(hour=9, minute=5, second=0), description='server_update_help')
 
 

+ 1 - 1
tasks/RichMan/assets.py

@@ -14,7 +14,7 @@ class RichManAssets:
 	# 神社 
 	# 神社 
 	I_GUILD_SHRINE = RuleImage(roi_front=(869,623,64,62), roi_back=(869,623,64,62), threshold=0.8, method="Template matching", file="./tasks/RichMan/guild/guild_guild_shrine.png")
 	I_GUILD_SHRINE = RuleImage(roi_front=(869,623,64,62), roi_back=(869,623,64,62), threshold=0.8, method="Template matching", file="./tasks/RichMan/guild/guild_guild_shrine.png")
 	# 功勋商店 
 	# 功勋商店 
-	I_GUILD_STORE = RuleImage(roi_front=(651,420,212,161), roi_back=(651,420,212,161), threshold=0.8, method="Template matching", file="./tasks/RichMan/guild/guild_guild_store.png")
+	I_GUILD_STORE = RuleImage(roi_front=(651,420,212,161), roi_back=(651,420,212,180), threshold=0.8, method="Template matching", file="./tasks/RichMan/guild/guild_guild_store.png")
 	# description 
 	# description 
 	I_GUILD_CLOSE_RED = RuleImage(roi_front=(1029,120,53,57), roi_back=(1029,120,53,57), threshold=0.8, method="Template matching", file="./tasks/RichMan/guild/guild_guild_close_red.png")
 	I_GUILD_CLOSE_RED = RuleImage(roi_front=(1029,120,53,57), roi_back=(1029,120,53,57), threshold=0.8, method="Template matching", file="./tasks/RichMan/guild/guild_guild_close_red.png")
 	# 蓝票 
 	# 蓝票 

+ 1 - 1
tasks/RichMan/guild/image.json

@@ -12,7 +12,7 @@
     "itemName": "guild_store",
     "itemName": "guild_store",
     "imageName": "guild_guild_store.png",
     "imageName": "guild_guild_store.png",
     "roiFront": "651,420,212,161",
     "roiFront": "651,420,212,161",
-    "roiBack": "651,420,212,161",
+    "roiBack": "651,420,212,180",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "功勋商店"
     "description": "功勋商店"

+ 1 - 1
tasks/SoulsTidy/assets.py

@@ -43,7 +43,7 @@ class SoulsTidyAssets:
 	# 神赐 
 	# 神赐 
 	I_ST_GOD_PRESENT = RuleImage(roi_front=(578,234,131,73), roi_back=(542,117,204,219), threshold=0.8, method="Template matching", file="./tasks/SoulsTidy/simple/simple_st_god_present.png")
 	I_ST_GOD_PRESENT = RuleImage(roi_front=(578,234,131,73), roi_back=(542,117,204,219), threshold=0.8, method="Template matching", file="./tasks/SoulsTidy/simple/simple_st_god_present.png")
 	# 已弃置被选中 
 	# 已弃置被选中 
-	I_ST_ABANDONED_SELECTED = RuleImage(roi_front=(47,118,84,33), roi_back=(45,119,85,34), threshold=0.8, method="Template matching", file="./tasks/SoulsTidy/simple/simple_st_abandoned_selected.png")
+	I_ST_ABANDONED_SELECTED = RuleImage(roi_front=(32,112,107,52), roi_back=(15,89,139,87), threshold=0.8, method="Template matching", file="./tasks/SoulsTidy/simple/simple_st_abandoned_selected.png")
 	# 第一个御魂是+0的 
 	# 第一个御魂是+0的 
 	I_ST_LEVEL_0 = RuleImage(roi_front=(85,235,45,30), roi_back=(85,235,45,30), threshold=0.9, method="Template matching", file="./tasks/SoulsTidy/simple/simple_st_level_0.png")
 	I_ST_LEVEL_0 = RuleImage(roi_front=(85,235,45,30), roi_back=(85,235,45,30), threshold=0.9, method="Template matching", file="./tasks/SoulsTidy/simple/simple_st_level_0.png")
 	# 御魂奉纳后获得的金币 
 	# 御魂奉纳后获得的金币 

+ 9 - 4
tasks/SoulsTidy/script_task.py

@@ -99,11 +99,15 @@ class ScriptTask(GameUi, SoulsTidyAssets):
             if self.appear_then_click(self.I_ST_BONGNA, interval=1, threshold=0.6):
             if self.appear_then_click(self.I_ST_BONGNA, interval=1, threshold=0.6):
                 continue
                 continue
         if self.config.souls_tidy.simple_tidy.enable_maneki:
         if self.config.souls_tidy.simple_tidy.enable_maneki:
-            logger.hr('Enter bongna')
-            # 进入已弃置界面
             """
             """
-            现在默认进入就是已弃置界面,所以不需要点击
             """
             """
+            logger.hr('Enter bongna')
+            # 确保已弃置界面
+            while 1:
+                self.screenshot()
+                if self.appear(self.I_ST_ABANDONED_SELECTED):
+                    break
+                self.click(self.I_ST_ABANDONED_SELECTED, interval=1.5)
             # 确保是按照等级来排序的
             # 确保是按照等级来排序的
             while 1:
             while 1:
                 self.screenshot()
                 self.screenshot()
@@ -177,9 +181,10 @@ if __name__ == '__main__':
     from module.config.config import Config
     from module.config.config import Config
     from module.device.device import Device
     from module.device.device import Device
 
 
-    c = Config('oas3')
+    c = Config('oas1')
     d = Device(c)
     d = Device(c)
     t = ScriptTask(c, d)
     t = ScriptTask(c, d)
 
 
     #t.greed_maneki()
     #t.greed_maneki()
     t.run()
     t.run()
+

+ 2 - 2
tasks/SoulsTidy/simple/image.json

@@ -110,8 +110,8 @@
   {
   {
     "itemName": "st_abandoned_selected",
     "itemName": "st_abandoned_selected",
     "imageName": "simple_st_abandoned_selected.png",
     "imageName": "simple_st_abandoned_selected.png",
-    "roiFront": "47,118,84,33",
-    "roiBack": "45,119,85,34",
+    "roiFront": "32,112,107,52",
+    "roiBack": "15,89,139,87",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "已弃置被选中"
     "description": "已弃置被选中"

BIN
tasks/SoulsTidy/simple/simple_st_abandoned_selected.png


+ 12 - 12
tasks/WantedQuests/assets.py

@@ -37,21 +37,21 @@ class WantedQuestsAssets:
 	# 备用识别2 
 	# 备用识别2 
 	O_WQ_NUM_UNKNOWN_2 = RuleOcr(roi=(34,406,65,24), area=(34,406,65,24), mode="Digit", method="Default", keyword="", name="wq_num_unknown_2")
 	O_WQ_NUM_UNKNOWN_2 = RuleOcr(roi=(34,406,65,24), area=(34,406,65,24), mode="Digit", method="Default", keyword="", name="wq_num_unknown_2")
 	# Ocr-description 
 	# Ocr-description 
-	O_WQ_TYPE_1 = RuleOcr(roi=(544,238,55,36), area=(544,238,55,36), mode="Single", method="Default", keyword="", name="wq_type_1")
+	O_WQ_TYPE_1 = RuleOcr(roi=(544,248,55,36), area=(544,248,55,36), mode="Single", method="Default", keyword="", name="wq_type_1")
 	# Ocr-description 
 	# Ocr-description 
-	O_WQ_TYPE_2 = RuleOcr(roi=(544,311,55,30), area=(544,311,55,30), mode="Single", method="Default", keyword="", name="wq_type_2")
+	O_WQ_TYPE_2 = RuleOcr(roi=(544,321,55,30), area=(544,321,55,30), mode="Single", method="Default", keyword="", name="wq_type_2")
 	# Ocr-description 
 	# Ocr-description 
-	O_WQ_TYPE_3 = RuleOcr(roi=(544,382,54,30), area=(544,382,54,30), mode="Single", method="Default", keyword="", name="wq_type_3")
+	O_WQ_TYPE_3 = RuleOcr(roi=(544,392,54,30), area=(544,392,54,30), mode="Single", method="Default", keyword="", name="wq_type_3")
 	# Ocr-description 
 	# Ocr-description 
-	O_WQ_TYPE_4 = RuleOcr(roi=(545,452,52,32), area=(545,452,52,32), mode="Single", method="Default", keyword="", name="wq_type_4")
+	O_WQ_TYPE_4 = RuleOcr(roi=(545,462,52,32), area=(545,462,52,32), mode="Single", method="Default", keyword="", name="wq_type_4")
 	# Ocr-description 
 	# Ocr-description 
-	O_WQ_INFO_1 = RuleOcr(roi=(609,236,309,45), area=(609,236,309,45), mode="Single", method="Default", keyword="", name="wq_info_1")
+	O_WQ_INFO_1 = RuleOcr(roi=(609,246,309,45), area=(609,246,309,45), mode="Single", method="Default", keyword="", name="wq_info_1")
 	# Ocr-description 
 	# Ocr-description 
-	O_WQ_INFO_2 = RuleOcr(roi=(612,308,298,41), area=(612,308,298,41), mode="Single", method="Default", keyword="", name="wq_info_2")
+	O_WQ_INFO_2 = RuleOcr(roi=(612,318,298,41), area=(612,318,298,41), mode="Single", method="Default", keyword="", name="wq_info_2")
 	# Ocr-description 
 	# Ocr-description 
-	O_WQ_INFO_3 = RuleOcr(roi=(612,376,305,44), area=(612,376,305,44), mode="Single", method="Default", keyword="", name="wq_info_3")
+	O_WQ_INFO_3 = RuleOcr(roi=(612,386,305,44), area=(612,386,305,44), mode="Single", method="Default", keyword="", name="wq_info_3")
 	# Ocr-description 
 	# Ocr-description 
-	O_WQ_INFO_4 = RuleOcr(roi=(613,446,315,44), area=(613,446,315,44), mode="Single", method="Default", keyword="", name="wq_info_4")
+	O_WQ_INFO_4 = RuleOcr(roi=(613,456,315,44), area=(613,456,315,44), mode="Single", method="Default", keyword="", name="wq_info_4")
 	# 怪物名称,如酒吞,阎魔等 
 	# 怪物名称,如酒吞,阎魔等 
 	O_WQ_MONSTER_TYPE = RuleOcr(roi=(165,215,45,175), area=(165,215,45,175), mode="Full", method="Default", keyword="", name="wq_monster_type")
 	O_WQ_MONSTER_TYPE = RuleOcr(roi=(165,215,45,175), area=(165,215,45,175), mode="Full", method="Default", keyword="", name="wq_monster_type")
 	#  
 	#  
@@ -153,13 +153,13 @@ class WantedQuestsAssets:
 	# 小号不追踪 
 	# 小号不追踪 
 	I_TRACE_FALSE = RuleImage(roi_front=(170,186,31,32), roi_back=(170,186,31,32), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_trace_false.png")
 	I_TRACE_FALSE = RuleImage(roi_front=(170,186,31,32), roi_back=(170,186,31,32), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_trace_false.png")
 	# description 
 	# description 
-	I_GOTO_1 = RuleImage(roi_front=(978,234,87,45), roi_back=(978,234,87,45), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_goto_1.png")
+	I_GOTO_1 = RuleImage(roi_front=(978,234,87,45), roi_back=(978,234,87,60), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_goto_1.png")
 	# description 
 	# description 
-	I_GOTO_2 = RuleImage(roi_front=(979,305,88,43), roi_back=(979,305,88,43), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_goto_2.png")
+	I_GOTO_2 = RuleImage(roi_front=(979,305,88,43), roi_back=(979,305,88,58), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_goto_2.png")
 	# description 
 	# description 
-	I_GOTO_3 = RuleImage(roi_front=(979,373,88,47), roi_back=(979,373,88,47), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_goto_3.png")
+	I_GOTO_3 = RuleImage(roi_front=(979,373,88,47), roi_back=(979,373,88,62), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_goto_3.png")
 	# description 
 	# description 
-	I_GOTO_4 = RuleImage(roi_front=(979,447,87,42), roi_back=(979,447,87,42), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_goto_4.png")
+	I_GOTO_4 = RuleImage(roi_front=(979,447,87,42), roi_back=(979,447,87,57), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_goto_4.png")
 	# 判断是否还有任务 
 	# 判断是否还有任务 
 	I_WQ_CHECK_TASK = RuleImage(roi_front=(110,154,21,125), roi_back=(73,122,69,459), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_wq_check_task.png")
 	I_WQ_CHECK_TASK = RuleImage(roi_front=(110,154,21,125), roi_back=(73,122,69,459), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_wq_check_task.png")
 	# 庭院悬赏任务界面 单个任务点开后 左上角是否追踪 
 	# 庭院悬赏任务界面 单个任务点开后 左上角是否追踪 

+ 16 - 16
tasks/WantedQuests/ocr.json

@@ -73,8 +73,8 @@
   },
   },
   {
   {
     "itemName": "wq_type_1",
     "itemName": "wq_type_1",
-    "roiFront": "544,238,55,36",
-    "roiBack": "544,238,55,36",
+    "roiFront": "544,248,55,36",
+    "roiBack": "544,248,55,36",
     "mode": "Single",
     "mode": "Single",
     "method": "Default",
     "method": "Default",
     "keyword": "",
     "keyword": "",
@@ -82,8 +82,8 @@
   },
   },
   {
   {
     "itemName": "wq_type_2",
     "itemName": "wq_type_2",
-    "roiFront": "544,311,55,30",
-    "roiBack": "544,311,55,30",
+    "roiFront": "544,321,55,30",
+    "roiBack": "544,321,55,30",
     "mode": "Single",
     "mode": "Single",
     "method": "Default",
     "method": "Default",
     "keyword": "",
     "keyword": "",
@@ -91,8 +91,8 @@
   },
   },
   {
   {
     "itemName": "wq_type_3",
     "itemName": "wq_type_3",
-    "roiFront": "544,382,54,30",
-    "roiBack": "544,382,54,30",
+    "roiFront": "544,392,54,30",
+    "roiBack": "544,392,54,30",
     "mode": "Single",
     "mode": "Single",
     "method": "Default",
     "method": "Default",
     "keyword": "",
     "keyword": "",
@@ -100,8 +100,8 @@
   },
   },
   {
   {
     "itemName": "wq_type_4",
     "itemName": "wq_type_4",
-    "roiFront": "545,452,52,32",
-    "roiBack": "545,452,52,32",
+    "roiFront": "545,462,52,32",
+    "roiBack": "545,462,52,32",
     "mode": "Single",
     "mode": "Single",
     "method": "Default",
     "method": "Default",
     "keyword": "",
     "keyword": "",
@@ -109,8 +109,8 @@
   },
   },
   {
   {
     "itemName": "wq_info_1",
     "itemName": "wq_info_1",
-    "roiFront": "609,236,309,45",
-    "roiBack": "609,236,309,45",
+    "roiFront": "609,246,309,45",
+    "roiBack": "609,246,309,45",
     "mode": "Single",
     "mode": "Single",
     "method": "Default",
     "method": "Default",
     "keyword": "",
     "keyword": "",
@@ -118,8 +118,8 @@
   },
   },
   {
   {
     "itemName": "wq_info_2",
     "itemName": "wq_info_2",
-    "roiFront": "612,308,298,41",
-    "roiBack": "612,308,298,41",
+    "roiFront": "612,318,298,41",
+    "roiBack": "612,318,298,41",
     "mode": "Single",
     "mode": "Single",
     "method": "Default",
     "method": "Default",
     "keyword": "",
     "keyword": "",
@@ -127,8 +127,8 @@
   },
   },
   {
   {
     "itemName": "wq_info_3",
     "itemName": "wq_info_3",
-    "roiFront": "612,376,305,44",
-    "roiBack": "612,376,305,44",
+    "roiFront": "612,386,305,44",
+    "roiBack": "612,386,305,44",
     "mode": "Single",
     "mode": "Single",
     "method": "Default",
     "method": "Default",
     "keyword": "",
     "keyword": "",
@@ -136,8 +136,8 @@
   },
   },
   {
   {
     "itemName": "wq_info_4",
     "itemName": "wq_info_4",
-    "roiFront": "613,446,315,44",
-    "roiBack": "613,446,315,44",
+    "roiFront": "613,456,315,44",
+    "roiBack": "613,456,315,44",
     "mode": "Single",
     "mode": "Single",
     "method": "Default",
     "method": "Default",
     "keyword": "",
     "keyword": "",

+ 4 - 4
tasks/WantedQuests/wq/image.json

@@ -66,7 +66,7 @@
     "itemName": "goto_1",
     "itemName": "goto_1",
     "imageName": "wq_goto_1.png",
     "imageName": "wq_goto_1.png",
     "roiFront": "978,234,87,45",
     "roiFront": "978,234,87,45",
-    "roiBack": "978,234,87,45",
+    "roiBack": "978,234,87,60",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "description"
     "description": "description"
@@ -75,7 +75,7 @@
     "itemName": "goto_2",
     "itemName": "goto_2",
     "imageName": "wq_goto_2.png",
     "imageName": "wq_goto_2.png",
     "roiFront": "979,305,88,43",
     "roiFront": "979,305,88,43",
-    "roiBack": "979,305,88,43",
+    "roiBack": "979,305,88,58",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "description"
     "description": "description"
@@ -84,7 +84,7 @@
     "itemName": "goto_3",
     "itemName": "goto_3",
     "imageName": "wq_goto_3.png",
     "imageName": "wq_goto_3.png",
     "roiFront": "979,373,88,47",
     "roiFront": "979,373,88,47",
-    "roiBack": "979,373,88,47",
+    "roiBack": "979,373,88,62",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "description"
     "description": "description"
@@ -93,7 +93,7 @@
     "itemName": "goto_4",
     "itemName": "goto_4",
     "imageName": "wq_goto_4.png",
     "imageName": "wq_goto_4.png",
     "roiFront": "979,447,87,42",
     "roiFront": "979,447,87,42",
-    "roiBack": "979,447,87,42",
+    "roiBack": "979,447,87,57",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "description"
     "description": "description"