Browse Source

Merge pull request #619 from runhey/dev

Dev
huangrunheng 1 year ago
parent
commit
db0bf4a387
100 changed files with 2948 additions and 517 deletions
  1. 1 0
      .gitignore
  2. 35 0
      config/findjade/find_jade.json
  3. 3 3
      dev_tools/assets_test.py
  4. 0 1
      dev_tools/generate_requirements.py
  5. 11 20
      module/config/config.py
  6. 1 0
      module/config/config_menu.py
  7. 36 37
      module/config/config_model.py
  8. 4 0
      module/notify/notify.py
  9. 14 1
      module/server/home_router.py
  10. 28 0
      module/server/i18n.py
  11. 2 2
      requirements-in.txt
  12. 5 3
      requirements.txt
  13. 6 6
      script.py
  14. BIN
      tasks/AbyssShadows/__pycache__/assets.cpython-310.pyc
  15. BIN
      tasks/AbyssShadows/__pycache__/config.cpython-310.pyc
  16. BIN
      tasks/AbyssShadows/__pycache__/script_task.cpython-310.pyc
  17. BIN
      tasks/ActivityShikigami/as/as_ap.png
  18. BIN
      tasks/ActivityShikigami/as/as_ap_activity.png
  19. BIN
      tasks/ActivityShikigami/as/as_battle.png
  20. BIN
      tasks/ActivityShikigami/as/as_drum.png
  21. BIN
      tasks/ActivityShikigami/as/as_fire.png
  22. BIN
      tasks/ActivityShikigami/as/as_shi.png
  23. BIN
      tasks/ActivityShikigami/as/as_switch.png
  24. 12 12
      tasks/ActivityShikigami/as/image.json
  25. 4 4
      tasks/ActivityShikigami/as/ocr.json
  26. 9 9
      tasks/ActivityShikigami/assets.py
  27. 3 4
      tasks/ActivityShikigami/config.py
  28. 0 10
      tasks/ActivityShikigami/script_task.py
  29. 10 2
      tasks/BondlingFairyland/assets.py
  30. BIN
      tasks/BondlingFairyland/ball/create_team.png
  31. BIN
      tasks/BondlingFairyland/ball/gi_flag_1_on.png
  32. 37 1
      tasks/BondlingFairyland/ball/image.json
  33. BIN
      tasks/BondlingFairyland/ball/room_team.png
  34. 2 2
      tasks/BondlingFairyland/battle.py
  35. 1 1
      tasks/BondlingFairyland/capture/image.json
  36. 12 1
      tasks/BondlingFairyland/config.py
  37. 650 0
      tasks/BondlingFairyland/general_invite.py
  38. 345 21
      tasks/BondlingFairyland/script_task.py
  39. 13 0
      tasks/Component/Costume/assets.py
  40. 1 0
      tasks/Component/Costume/config.py
  41. 5 0
      tasks/Component/Costume/costume_base.py
  42. 47 0
      tasks/Component/Costume/main10/image.json
  43. BIN
      tasks/Component/Costume/main10/main10_check_main_10.png
  44. BIN
      tasks/Component/Costume/main10/main10_main_goto_exploration_10.png
  45. BIN
      tasks/Component/Costume/main10/main10_main_goto_summon_10.png
  46. BIN
      tasks/Component/Costume/main10/main10_main_goto_town_10.png
  47. BIN
      tasks/Component/Costume/main10/main10_pet_house_10.png
  48. 21 11
      tasks/Component/GeneralBattle/assets.py
  49. 114 108
      tasks/Component/GeneralBattle/gb/click.json
  50. BIN
      tasks/Component/GeneralBattle/gb/gb_green_marker.png
  51. BIN
      tasks/Component/GeneralBattle/gb/gb_green_marker_bottom.png
  52. BIN
      tasks/Component/GeneralBattle/gb/gb_green_marker_left_top.png
  53. 27 0
      tasks/Component/GeneralBattle/gb/image.json
  54. 9 0
      tasks/Component/GeneralBattle/gb/ocr.json
  55. 101 35
      tasks/Component/GeneralBattle/general_battle.py
  56. 0 0
      tasks/Component/GeneralInvite/gi/gi_gi_in_room.png
  57. 4 4
      tasks/Component/SwitchAccount/login_account.py
  58. 7 7
      tasks/Component/SwitchAccount/switch_account.py
  59. 10 6
      tasks/Component/SwitchAccount/switch_account_config.py
  60. 53 75
      tasks/Component/config_base.py
  61. 14 36
      tasks/Component/config_scheduler.py
  62. 11 0
      tasks/DailyTrifles/assets.py
  63. 2 1
      tasks/DailyTrifles/config.py
  64. BIN
      tasks/DailyTrifles/love/friendship_up.png
  65. 9 0
      tasks/DailyTrifles/love/image.json
  66. 81 13
      tasks/DailyTrifles/script_task.py
  67. 18 0
      tasks/DailyTrifles/store/image.json
  68. 11 0
      tasks/DailyTrifles/store/ocr.json
  69. BIN
      tasks/DailyTrifles/store/store_cost_type_jade.png
  70. BIN
      tasks/DailyTrifles/store/store_sushi.png
  71. 1 1
      tasks/DemonEncounter/config.py
  72. 95 20
      tasks/Dokan/assets.py
  73. 140 4
      tasks/Dokan/config.py
  74. 146 0
      tasks/Dokan/dokan_scene.py
  75. 431 0
      tasks/Dokan/ex_green_mark.py
  76. 34 4
      tasks/Dokan/res/click.json
  77. 296 45
      tasks/Dokan/res/image.json
  78. 1 1
      tasks/Dokan/res/list.json
  79. 15 6
      tasks/Dokan/res/ocr.json
  80. BIN
      tasks/Dokan/res/res_dokan_boss_waiting.png
  81. BIN
      tasks/Dokan/res/res_ryou_dokan_abandoned_toppa.png
  82. BIN
      tasks/Dokan/res/res_ryou_dokan_abandoned_toppa_abandoned.png
  83. BIN
      tasks/Dokan/res/res_ryou_dokan_abandoned_toppa_continue.png
  84. BIN
      tasks/Dokan/res/res_ryou_dokan_abandoned_toppa_ensure.png
  85. BIN
      tasks/Dokan/res/res_ryou_dokan_abandoned_toppa_title.png
  86. BIN
      tasks/Dokan/res/res_ryou_dokan_activated.png
  87. BIN
      tasks/Dokan/res/res_ryou_dokan_battle_master_first.png
  88. BIN
      tasks/Dokan/res/res_ryou_dokan_battle_master_second.png
  89. BIN
      tasks/Dokan/res/res_ryou_dokan_center_challenge.png
  90. BIN
      tasks/Dokan/res/res_ryou_dokan_center_guanzhu_xiuxi.png
  91. BIN
      tasks/Dokan/res/res_ryou_dokan_center_point_people_number.png
  92. BIN
      tasks/Dokan/res/res_ryou_dokan_center_top.png
  93. BIN
      tasks/Dokan/res/res_ryou_dokan_challenge_ensure.png
  94. BIN
      tasks/Dokan/res/res_ryou_dokan_create_dokan.png
  95. BIN
      tasks/Dokan/res/res_ryou_dokan_create_dokan_ensure.png
  96. BIN
      tasks/Dokan/res/res_ryou_dokan_dokan_info_close.png
  97. BIN
      tasks/Dokan/res/res_ryou_dokan_dokan_quit.png
  98. BIN
      tasks/Dokan/res/res_ryou_dokan_failed_vote_battle_again.png
  99. BIN
      tasks/Dokan/res/res_ryou_dokan_failed_vote_keep_bounty.png
  100. BIN
      tasks/Dokan/res/res_ryou_dokan_finding_dokan.png

+ 1 - 0
.gitignore

@@ -26,6 +26,7 @@ test/
 !module/gui/FluentUI/fluentuiplugin.dll
 build-fluentui-Desktop_*/
 module/config/argument/setting.json
+module/config/i18n/*.json
 !fluentui/*
 *.exe
 !dev_tools/*

+ 35 - 0
config/findjade/find_jade.json

@@ -0,0 +1,35 @@
+{
+  "find_jade_accounts_info": [
+    {
+      "character": "小号1",
+      "svr": "万事屋",
+      "account": "150****4444",
+      "accountAlias": "150★***4444#150*★**4444#150**★*4444#150***★4444",
+      "appleOrAndroid": true,
+      "last_complete_time": "2024-11-12 18:02:28.342305"
+    },
+    {
+      "character": "小号2",
+      "svr": "祈世之舞",
+      "account": "150****4444",
+      "accountAlias": "150★***4444#150*★**4444#150**★*4444#150***★4444",
+      "appleOrAndroid": true,
+      "last_complete_time": "2024-11-12 18:03:08.517909"
+    }],
+  "invite_info_list": [
+    {
+      "name": "大号1",
+      "default_invite_type": "JadeAndFood",
+      "invite_history": [
+        {
+          "cooperation_type": 2,
+          "time": "2024-11-05 18:08:53.597534"
+        }]
+    },
+    {
+      "name": "大号2",
+      "default_invite_type": "JadeAndFood",
+      "invite_history": []
+    }],
+  "updateHandle": "<bound method ScriptTask.save_jade_json of <script_task.ScriptTask object at 0x000001C5E7229D50>>"
+}

+ 3 - 3
dev_tools/assets_test.py

@@ -34,10 +34,10 @@ def detect_ocr(file: str, target: RuleOcr):
 
 
 # 图片文件路径 可以是相对路径
-IMAGE_FILE = r"D:\Project\OnmyojiAutoScript\log\error\1731668941132\2024-11-15_19-09-00-887294.png"
+IMAGE_FILE = r"C:\Users\Ryland\Desktop\Weixin Screenshot_20241225220524.png"
 if __name__ == '__main__':
-    from tasks.WantedQuests.assets import WantedQuestsAssets
-    targe = WantedQuestsAssets.I_WQ_BOX
+    from tasks.KekkaiActivation.assets import KekkaiActivationAssets
+    targe = KekkaiActivationAssets.I_CARDS_KAIKO_3
     print(detect_image(IMAGE_FILE, targe))
 
     # ocr demo

+ 0 - 1
dev_tools/generate_requirements.py

@@ -3,7 +3,6 @@
 # github https://github.com/runhey
 import argparse
 import subprocess
-import time
 
 from module.logger import logger
 

+ 11 - 20
module/config/config.py

@@ -26,9 +26,6 @@ from module.exception import RequestHumanTakeover, ScriptError
 from module.logger import logger
 
 
-
-
-
 class Function:
     def __init__(self, key: str, data: dict):
         """
@@ -125,6 +122,13 @@ class Config(ConfigState, ConfigManual, ConfigWatcher, ConfigMenu):
     def lock_config(self) -> Lock:
         return Lock()
 
+    @cached_property
+    def notifier(self):
+        notifier = Notifier(self.model.script.error.notify_config, enable=self.model.script.error.notify_enable)
+        notifier.config_name = self.config_name.upper()
+        logger.info(f'Notifier: {notifier.config_name}')
+        return notifier
+
     def gui_args(self, task: str) -> str:
         """
         获取给gui显示的参数
@@ -251,8 +255,7 @@ class Config(ConfigState, ConfigManual, ConfigWatcher, ConfigMenu):
         data = {"running": running, "pending": pending, "waiting": waiting}
         return data
 
-
-    def task_call(self, task: str=None, force_call=True):
+    def task_call(self, task: str = None, force_call=True):
         """
         回调任务,这会是在任务结束后调用
         :param task: 调用的任务的大写名称
@@ -277,7 +280,7 @@ class Config(ConfigState, ConfigManual, ConfigWatcher, ConfigMenu):
             return False
 
     def task_delay(self, task: str, start_time: datetime = None,
-                   success: bool=None, server: bool=True, target: datetime=None) -> None:
+                   success: bool = None, server: bool = True, target: datetime = None) -> None:
         """
         设置下次运行时间  当然这个也是可以重写的
         :param target: 可以自定义的下次运行时间
@@ -341,7 +344,7 @@ class Config(ConfigState, ConfigManual, ConfigWatcher, ConfigMenu):
         run = min(run).replace(microsecond=0)
         next_run = run
 
-        if server and hasattr(scheduler, 'server_update'):
+        if server and hasattr(scheduler, 'server_update') and target is None:
             # 加入随机延迟时间
             float_seconds = (scheduler.float_time.hour * 3600 +
                              scheduler.float_time.minute * 60 +
@@ -378,20 +381,8 @@ class Config(ConfigState, ConfigManual, ConfigWatcher, ConfigMenu):
         logger.attr(f'{task}.scheduler.next_run', next_run)
 
 
-    @cached_property
-    def notifier(self):
-        notifier = Notifier(self.model.script.error.notify_config, enable=self.model.script.error.notify_enable)
-        notifier.config_name = self.config_name.upper()
-        logger.info(f'Notifier: {notifier.config_name}')
-        return notifier
-
 if __name__ == '__main__':
     config = Config(config_name='oas1')
-    config.update_scheduler()
-    print(config.waiting_task)
+    config.notifier.push(title="0000", content="dddddddd")
 
     # print(config.get_next())
-
-
-
-

+ 1 - 0
module/config/config_menu.py

@@ -32,6 +32,7 @@ class ConfigMenu:
             "Exploration",
             "Hyakkiyakou",
             "HeroTest",
+            "FindJade"
         ]
         # 阴阳寮
         self.menu["Guild"] = ['KekkaiUtilize', 'KekkaiActivation', 'RealmRaid', 'RyouToppa', 'Dokan', 'CollectiveMissions',

+ 36 - 37
module/config/config_model.py

@@ -62,6 +62,7 @@ from tasks.GoryouRealm.config import GoryouRealm
 from tasks.Hyakkiyakou.config import Hyakkiyakou
 from tasks.HeroTest.config import HeroTest
 
+from tasks.FindJade.config import FindJade
 # ----------------------------------------------------------------------------------------------------------------------
 
 # 每周任务---------------------------------------------------------------------------------------------------------------
@@ -119,6 +120,7 @@ class ConfigModel(ConfigBase):
     goryou_realm: GoryouRealm = Field(default_factory=GoryouRealm)
     hyakkiyakou: Hyakkiyakou = Field(default_factory=Hyakkiyakou)
     hero_test: HeroTest = Field(default_factory=HeroTest)
+    find_jade: FindJade = Field(default_factory=FindJade)
 
     # 这些是每周任务
     true_orochi: TrueOrochi = Field(default_factory=TrueOrochi)
@@ -134,10 +136,6 @@ class ConfigModel(ConfigBase):
     dokan: Dokan = Field(default_factory=Dokan)
     abyss_shadows: AbyssShadows = Field(default_factory=AbyssShadows)
 
-    # @validator('script')
-    # def script_validator(cls, v):
-    #     if v is None:
-    #         return Script()
 
     def __init__(self, config_name: str=None) -> None:
         """
@@ -225,7 +223,7 @@ class ConfigModel(ConfigBase):
 
         :return:
         """
-        self.write_json(self.config_name, self.dict())
+        self.write_json(self.config_name, self.model_dump())
 
     @staticmethod
     def type(key: str) -> str:
@@ -243,16 +241,6 @@ class ConfigModel(ConfigBase):
             classname = re.findall(r"'([^']*)'", field_type)[0]
             return classname
 
-    # @root_validator
-    # def on_on_property_change(cls, values):
-    #     """
-    #     当属性改变时保存
-    #     :param values:
-    #     :return:
-    #     """
-    #     logger.info(f'property change auto save')
-    #     cls.save()
-
     @staticmethod
     def deep_get(obj, keys: str, default=None):
         """
@@ -298,21 +286,20 @@ class ConfigModel(ConfigBase):
             logger.warning(f'{task} is no inexistence')
             return {}
 
-        def properties_groups(sch) -> dict:
-            properties = {}
-            for key, value in sch["properties"].items():
-                properties[key] = re.search(r"/([^/]+)$", value['$ref']).group(1)
-            return properties
-
         def extract_groups(sch):
             # 从schema 中提取未解析的group的数据
-            properties = properties_groups(sch)
+            # properties = properties_groups(sch)
+            results = {}
+            properties = {}
+            for key, value in sch["properties"].items():
+                if 'items' in value:
+                    properties[key] = re.search(r"/([^/]+)$", value['items']['$ref']).group(1)
+                else:
+                    properties[key] = re.search(r"/([^/]+)$", value['$ref']).group(1)
 
-            result = {}
             for key, value in properties.items():
-                result[key] = sch["definitions"][value]
-
-            return result
+                results[key] = sch["$defs"][value]
+            return results
 
         def merge_value(groups, jsons, definitions) -> list[dict]:
             # 将 groups的参数,同导出的json一起合并, 用于前端显示
@@ -326,20 +313,26 @@ class ConfigModel(ConfigBase):
                 item["default"] = value["default"]
                 item["value"] = jsons[key] if key in jsons else value["default"]
                 item["type"] = value["type"] if "type" in value else "enum"
-                if 'allOf' in value:
-                    # list
-                    enum_key = re.search(r"/([^/]+)$", value['allOf'][0]['$ref']).group(1)
+                if '$ref' in value:  # list
+                    enum_key = re.search(r"/([^/]+)$", value['$ref']).group(1)
                     item["enumEnum"] = definitions[enum_key]["enum"]
-                # TODO: 最大值最小值
+                # if 'allOf' in value:
+                #     enum_key = re.search(r"/([^/]+)$", value['allOf'][0]['$ref']).group(1)
+                #     item["enumEnum"] = definitions[enum_key]["enum"]
                 result.append(item)
             return result
 
-        schema = task.schema()
+        schema = task.model_json_schema()
         groups = extract_groups(schema)
+        groups_value = groups.copy()
 
         result: dict[str, list] = {}
-        for key, value in task.dict().items():
-            result[key] = merge_value(groups[key], value, schema["definitions"])
+        for key, value in task.model_dump().items():
+            if key not in groups:
+                for group_name in groups.keys():
+                    if group_name in key:
+                        groups_value[key] = groups[group_name]
+            result[key] = merge_value(groups_value[key], value, schema["$defs"])
 
         return result
 
@@ -373,9 +366,15 @@ class ConfigModel(ConfigBase):
 
         task_object = getattr(self, task, None)
         group_object = getattr(task_object, group, None)
+        if group_object is None:  # deal list
+            matchs = re.findall(r'\d+', group)
+            index = int(matchs[-1]) - 1 if matchs else None
+            task_object_list = list(dict(task_object))
+            for k, v in dict(task_object).items():
+                if k not in group:
+                    continue
+                group_object = v[index] if group_object is None else None
         argument_object = getattr(group_object, argument, None)
-        # print(group_object)
-        # print(argument_object)
 
         if argument_object is None:
             logger.error(f'Set arg {task}.{group}.{argument}.{value} failed')
@@ -426,6 +425,7 @@ class ConfigModel(ConfigBase):
         data = self.read_json(self.config_name)
         super().__init__(**data)
 
+
 if __name__ == "__main__":
     try:
         c = ConfigModel("oas1")
@@ -433,5 +433,4 @@ if __name__ == "__main__":
         print(e)
         c = ConfigModel()
 
-    # c.save()
-    print(c.script_task('Orochi'))
+    c.script_set_arg('Duel', 'test_list_2', 'switch_all_soul', 'false')

+ 4 - 0
module/notify/notify.py

@@ -9,6 +9,7 @@ from onepush.core import Provider
 from onepush.exceptions import OnePushException
 from onepush.providers.custom import Custom
 from requests import Response
+from smtplib import SMTPResponseException
 
 from module.logger import logger
 onepush.core.log = logger
@@ -91,6 +92,9 @@ class Notifier:
                             logger.warning(
                                 f"Return message:{return_data['wording']}")
                             return False
+        except SMTPResponseException:
+            logger.warning("Appear SMTPResponseException")
+            pass
         except OnePushException:
             logger.exception("Push notify failed")
             return False

+ 14 - 1
module/server/home_router.py

@@ -1,11 +1,15 @@
 # This Python file uses the following encoding: utf-8
 # @author runhey
 # github https://github.com/runhey
-from fastapi import APIRouter
+import json
+from fastapi import APIRouter, Body
+from pathlib import Path
 
+from module.config.utils import write_file
 from module.logger import logger
 from module.server.main_manager import MainManager
 from module.server.updater import Updater
+from module.server.i18n import I18n
 
 home_app = APIRouter(
     prefix="/home",
@@ -61,6 +65,7 @@ async def update_info():
         logger.error(e)
         return None
 
+
 @home_app.get('/execute_update')
 async def execute_update():
     # 下拉仓库 -> 关闭所有脚本进程 -> 最后重启oasx
@@ -71,3 +76,11 @@ async def execute_update():
         logger.error(e)
     return '手动更新将会立即结束运行中的脚本服务, 最后你还需重启oasx'
 
+
+@home_app.put('/chinese_translate')
+async def chinese_translate(data: dict = Body(...)):
+    try:
+        I18n.save_zh_cn(data)
+    except Exception as e:
+        logger.error(e)
+    return True

+ 28 - 0
module/server/i18n.py

@@ -0,0 +1,28 @@
+import json
+from pathlib import Path
+
+
+class I18n:
+    file_zh_cn = Path.cwd() / 'module' / 'config' / 'i18n' / 'zh-CN.json'
+
+    @classmethod
+    def trans_zh_cn(cls, text) -> str:
+        cn_zh_data = cls.load_zh_cn()
+        return cn_zh_data[text] if text in cn_zh_data else text
+
+    @classmethod
+    def save_zh_cn(cls, data) -> None:
+        I18n.file_zh_cn.parent.mkdir(parents=True, exist_ok=True)
+        with open(str(I18n.file_zh_cn), 'w', encoding='utf-8') as f:
+            s = json.dumps(data, indent=2, ensure_ascii=False, sort_keys=False, default=str)
+            f.write(s)
+
+    @classmethod
+    def load_zh_cn(cls) -> dict:
+        if not I18n.file_zh_cn.exists():
+            return {}
+        with open(str(I18n.file_zh_cn), 'r', encoding='utf-8') as f:
+            return json.load(f)
+
+if __name__ == '__main__':
+    print(I18n.load_zh_cn())

+ 2 - 2
requirements-in.txt

@@ -11,11 +11,11 @@ anytree==2.8.0
 pywin32==306
 zerorpc==0.6.3
 wrapt==1.15.0
-pydantic==1.10.7
+pydantic==2.10.0
 inflection==0.5.1
 tqdm==4.65.0
 ppocr-onnx==0.0.3.9
-onepush==1.2.0
+onepush==1.3.0
 paho-mqtt==1.6.1
 fastapi==0.104.1
 uvicorn==0.23.2

+ 5 - 3
requirements.txt

@@ -7,6 +7,7 @@
 
 
 adbutils==0.11.0          # via -r requirements-in.txt, uiautomator2
+annotated-types==0.7.0    # via pydantic
 anyio==3.7.1              # via fastapi, starlette
 anytree==2.8.0            # via -r requirements-in.txt
 apkutils2==1.0.0          # via adbutils
@@ -41,7 +42,7 @@ mpmath==1.3.0             # via sympy
 msgpack==1.0.7            # via zerorpc
 numpy==1.24.3             # via -r requirements-in.txt, onnxruntime, opencv-python, ppocr-onnx, shapely
 oashya==0.0.7             # via -r requirements-in.txt
-onepush==1.2.0            # via -r requirements-in.txt
+onepush==1.3.0            # via -r requirements-in.txt
 onnxruntime==1.16.3       # via ppocr-onnx
 opencv-python==4.7.0.72   # via -r requirements-in.txt, ppocr-onnx
 packaging==20.9           # via deprecation, onnxruntime, uiautomator2
@@ -53,7 +54,8 @@ protobuf==4.25.1          # via onnxruntime
 py==1.11.0                # via retry
 pyclipper==1.3.0.post5    # via ppocr-onnx
 pycparser==2.21           # via cffi
-pydantic==1.10.7          # via -r requirements-in.txt, fastapi
+pydantic==2.10.0          # via -r requirements-in.txt, fastapi
+pydantic-core==2.27.0     # via pydantic
 pyelftools==0.30          # via apkutils2
 pygments==2.17.2          # via rich
 pyparsing==3.1.1          # via packaging
@@ -70,7 +72,7 @@ sniffio==1.3.0            # via anyio
 starlette==0.27.0         # via fastapi
 sympy==1.12               # via onnxruntime
 tqdm==4.65.0              # via -r requirements-in.txt
-typing-extensions==4.9.0  # via fastapi, pydantic, uvicorn
+typing-extensions==4.12.2  # via fastapi, pydantic, pydantic-core, uvicorn
 uiautomator2==2.16.17     # via -r requirements-in.txt
 uiautomator2cache==0.3.0.1  # via -r requirements-in.txt
 urllib3==2.1.0            # via requests

+ 6 - 6
script.py

@@ -31,6 +31,7 @@ from module.base.utils import load_module
 from module.base.decorator import del_cached_property
 from module.logger import logger
 from module.exception import *
+from module.server.i18n import I18n
 
 class Script:
     def __init__(self, config_name: str ='oas') -> None:
@@ -361,7 +362,7 @@ class Script:
             self.save_error_log()
             logger.warning(f'Game stuck, {self.device.package} will be restarted in 10 seconds')
             logger.warning('If you are playing by hand, please stop Alas')
-            self.config.notifier.push(title=command, content=f"<{self.config_name}> GameStuckError or GameTooManyClickError")
+            self.config.notifier.push(title=f'{I18n.trans_zh_cn(command)}{command}', content=f"<{self.config_name}> GameStuckError or GameTooManyClickError")
             self.config.task_call('Restart')
             self.device.sleep(10)
             return False
@@ -378,23 +379,22 @@ class Script:
             # 这个还不重要 留着坑填
             logger.critical('Game page unknown')
             self.save_error_log()
-            self.config.notifier.push(title=command, content=f"<{self.config_name}> GamePageUnknownError")
-            exit(1)
+            self.config.notifier.push(title=f'{I18n.trans_zh_cn(command)}{command}', content=f"<{self.config_name}> GamePageUnknownError")
             return False
         except ScriptError as e:
             logger.critical(e)
             logger.critical('This is likely to be a mistake of developers, but sometimes just random issues')
-            self.config.notifier.push(title=command, content=f"<{self.config_name}> ScriptError")
+            self.config.notifier.push(title=f'{I18n.trans_zh_cn(command)}{command}', content=f"<{self.config_name}> ScriptError")
             exit(1)
         except RequestHumanTakeover as e:
             logger.critical(e)
             logger.critical('Request human takeover')
-            self.config.notifier.push(title=command, content=f"<{self.config_name}> RequestHumanTakeover")
+            self.config.notifier.push(title=f'{I18n.trans_zh_cn(command)}{command}', content=f"<{self.config_name}> RequestHumanTakeover")
             exit(1)
         except Exception as e:
             logger.exception(e)
             self.save_error_log()
-            self.config.notifier.push(title=command, content=f"<{self.config_name}> Exception occured")
+            self.config.notifier.push(title=f'{I18n.trans_zh_cn(command)}{command}', content=f"<{self.config_name}> Exception occured")
             exit(1)
 
     def loop(self):

BIN
tasks/AbyssShadows/__pycache__/assets.cpython-310.pyc


BIN
tasks/AbyssShadows/__pycache__/config.cpython-310.pyc


BIN
tasks/AbyssShadows/__pycache__/script_task.cpython-310.pyc


BIN
tasks/ActivityShikigami/as/as_ap.png


BIN
tasks/ActivityShikigami/as/as_ap_activity.png


BIN
tasks/ActivityShikigami/as/as_battle.png


BIN
tasks/ActivityShikigami/as/as_drum.png


BIN
tasks/ActivityShikigami/as/as_fire.png


BIN
tasks/ActivityShikigami/as/as_shi.png


BIN
tasks/ActivityShikigami/as/as_switch.png


+ 12 - 12
tasks/ActivityShikigami/as/image.json

@@ -2,7 +2,7 @@
   {
     "itemName": "shi",
     "imageName": "as_shi.png",
-    "roiFront": "519,223,33,34",
+    "roiFront": "517,368,33,34",
     "roiBack": "64,115,1110,427",
     "method": "Template matching",
     "threshold": 0.7,
@@ -20,8 +20,8 @@
   {
     "itemName": "battle",
     "imageName": "as_battle.png",
-    "roiFront": "668,377,35,145",
-    "roiBack": "613,296,138,315",
+    "roiFront": "566,299,35,145",
+    "roiBack": "519,230,138,315",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "进入爬塔"
@@ -29,8 +29,8 @@
   {
     "itemName": "drum",
     "imageName": "as_drum.png",
-    "roiFront": "885,310,29,145",
-    "roiBack": "860,244,87,232",
+    "roiFront": "327,627,145,28",
+    "roiBack": "256,462,301,232",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "归鹿之途"
@@ -56,7 +56,7 @@
   {
     "itemName": "fire",
     "imageName": "as_fire.png",
-    "roiFront": "1133,566,84,78",
+    "roiFront": "1129,587,84,78",
     "roiBack": "1099,522,150,174",
     "method": "Template matching",
     "threshold": 0.8,
@@ -65,8 +65,8 @@
   {
     "itemName": "ap",
     "imageName": "as_ap.png",
-    "roiFront": "1130,526,23,24",
-    "roiBack": "1092,497,103,71",
+    "roiFront": "1123,671,23,24",
+    "roiBack": "1088,638,103,71",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "体力按钮"
@@ -74,8 +74,8 @@
   {
     "itemName": "ap_activity",
     "imageName": "as_ap_activity.png",
-    "roiFront": "1129,529,21,21",
-    "roiBack": "1101,509,84,54",
+    "roiFront": "1120,677,21,21",
+    "roiBack": "1095,656,84,54",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "活动体力"
@@ -83,8 +83,8 @@
   {
     "itemName": "switch",
     "imageName": "as_switch.png",
-    "roiFront": "1217,527,23,23",
-    "roiBack": "1199,507,69,56",
+    "roiFront": "1204,679,23,23",
+    "roiBack": "1191,653,69,56",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "切换按键"

+ 4 - 4
tasks/ActivityShikigami/as/ocr.json

@@ -1,8 +1,8 @@
 [
   {
     "itemName": "remain_ap",
-    "roiFront": "1139,680,97,25",
-    "roiBack": "1139,680,97,25",
+    "roiFront": "1152,556,97,25",
+    "roiBack": "1152,556,97,25",
     "mode": "DigitCounter",
     "method": "Default",
     "keyword": "",
@@ -10,8 +10,8 @@
   },
   {
     "itemName": "remain_ap_activity",
-    "roiFront": "717,25,95,30",
-    "roiBack": "717,25,95,30",
+    "roiFront": "713,25,95,30",
+    "roiBack": "713,25,95,30",
     "mode": "DigitCounter",
     "method": "Default",
     "keyword": "",

+ 9 - 9
tasks/ActivityShikigami/assets.py

@@ -45,25 +45,25 @@ class ActivityShikigamiAssets:
 
 	# Image Rule Assets
 	# 进入活动 
-	I_SHI = RuleImage(roi_front=(519,223,33,34), roi_back=(64,115,1110,427), threshold=0.7, method="Template matching", file="./tasks/ActivityShikigami/as/as_shi.png")
+	I_SHI = RuleImage(roi_front=(517,368,33,34), roi_back=(64,115,1110,427), threshold=0.7, method="Template matching", file="./tasks/ActivityShikigami/as/as_shi.png")
 	# 左上角返回 
 	I_BACK_GREEN = RuleImage(roi_front=(23,27,44,44), roi_back=(23,27,44,44), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_back_green.png")
 	# 进入爬塔 
-	I_BATTLE = RuleImage(roi_front=(668,377,35,145), roi_back=(613,296,138,315), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_battle.png")
+	I_BATTLE = RuleImage(roi_front=(566,299,35,145), roi_back=(519,230,138,315), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_battle.png")
 	# 归鹿之途 
-	I_DRUM = RuleImage(roi_front=(885,310,29,145), roi_back=(860,244,87,232), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_drum.png")
+	I_DRUM = RuleImage(roi_front=(327,627,145,28), roi_back=(256,462,301,232), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_drum.png")
 	# 上锁图标 
 	I_LOCK = RuleImage(roi_front=(827,655,25,32), roi_back=(749,592,139,116), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_lock.png")
 	# 还未上锁图片 
 	I_UNLOCK = RuleImage(roi_front=(823,654,28,28), roi_back=(776,610,112,87), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_unlock.png")
 	# 点击战斗 
-	I_FIRE = RuleImage(roi_front=(1133,566,84,78), roi_back=(1099,522,150,174), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_fire.png")
+	I_FIRE = RuleImage(roi_front=(1129,587,84,78), roi_back=(1099,522,150,174), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_fire.png")
 	# 体力按钮 
-	I_AP = RuleImage(roi_front=(1130,526,23,24), roi_back=(1092,497,103,71), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_ap.png")
+	I_AP = RuleImage(roi_front=(1123,671,23,24), roi_back=(1088,638,103,71), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_ap.png")
 	# 活动体力 
-	I_AP_ACTIVITY = RuleImage(roi_front=(1129,529,21,21), roi_back=(1101,509,84,54), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_ap_activity.png")
+	I_AP_ACTIVITY = RuleImage(roi_front=(1120,677,21,21), roi_back=(1095,656,84,54), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_ap_activity.png")
 	# 切换按键 
-	I_SWITCH = RuleImage(roi_front=(1217,527,23,23), roi_back=(1199,507,69,56), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_switch.png")
+	I_SWITCH = RuleImage(roi_front=(1204,679,23,23), roi_back=(1191,653,69,56), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_switch.png")
 	# 购买活动的体力 
 	I_BUY_JADE = RuleImage(roi_front=(1004,192,38,42), roi_back=(836,619,38,42), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_buy_jade.png")
 	# 增加到最大 
@@ -74,9 +74,9 @@ class ActivityShikigamiAssets:
 
 	# Ocr Rule Assets
 	# 体力的数量检测 
-	O_REMAIN_AP = RuleOcr(roi=(1139,680,97,25), area=(1139,680,97,25), mode="DigitCounter", method="Default", keyword="", name="remain_ap")
+	O_REMAIN_AP = RuleOcr(roi=(1152,556,97,25), area=(1152,556,97,25), mode="DigitCounter", method="Default", keyword="", name="remain_ap")
 	# 活动体力的剩余检测 
-	O_REMAIN_AP_ACTIVITY = RuleOcr(roi=(717,25,95,30), area=(717,25,95,30), mode="DigitCounter", method="Default", keyword="", name="remain_ap_activity")
+	O_REMAIN_AP_ACTIVITY = RuleOcr(roi=(713,25,95,30), area=(713,25,95,30), mode="DigitCounter", method="Default", keyword="", name="remain_ap_activity")
 	# 还有多少次购买体力的机会 
 	O_REMAIN_BUY = RuleOcr(roi=(808,531,39,42), area=(808,531,39,42), mode="DigitCounter", method="Default", keyword="", name="remain_buy")
 

+ 3 - 4
tasks/ActivityShikigami/config.py

@@ -18,15 +18,14 @@ class ShikigamiType(str, Enum):
     FOOD_TYPE_3 = 'shikigami_type_3'
     FOOD_TYPE_4 = 'shikigami_type_4'
 
-class ShikigamiConfig(BaseModel):
+# class ShikigamiConfig(BaseModel):
     # limit_time: TimeDelta = Field(default=TimeDelta(hours=0, minutes=30, seconds=0), description='limit_time_help')
     # limit_count: int = Field(default=10, description='limit_count_help')
-    food_type: ShikigamiType = Field(default=ShikigamiType.FOOD_TYPE_1, description='food_type_help')
-
+    # food_type: ShikigamiType = Field(default=ShikigamiType.FOOD_TYPE_1, description='food_type_help')
 
 class ActivityShikigami(ConfigBase):
     scheduler: Scheduler = Field(default_factory=Scheduler)
-    shikigami: ShikigamiConfig = Field(default_factory=ShikigamiConfig)
+    # shikigami: ShikigamiConfig = Field(default_factory=ShikigamiConfig)
     general_climb: GeneralClimb = Field(default_factory=GeneralClimb)
     general_battle: GeneralBattleConfig = Field(default_factory=GeneralBattleConfig)
     switch_soul_config: SwitchSoulConfig = Field(default_factory=SwitchSoulConfig)

+ 0 - 10
tasks/ActivityShikigami/script_task.py

@@ -138,16 +138,6 @@ class ScriptTask(GameUi, BaseActivity, SwitchSoul, ActivityShikigamiAssets):
             self.screenshot()
             if self.appear(self.I_FIRE):
                 break
-            # 2024-12-04 --------------start
-            from tasks.ActivityShikigami.config import ShikigamiType
-            map_click = {
-                ShikigamiType.FOOD_TYPE_1: self.C_CLICK1,
-                ShikigamiType.FOOD_TYPE_2: self.C_CLICK2,
-                ShikigamiType.FOOD_TYPE_3: self.C_CLICK3,
-                ShikigamiType.FOOD_TYPE_4: self.C_CLICK4,
-            }
-            self.click(map_click[self.config.model.activity_shikigami.shikigami.food_type], interval=4)
-            # 2024-12-04 --------------end
             if self.appear_then_click(self.I_SHI, interval=1):
                 continue
             if self.appear_then_click(self.I_DRUM, interval=1):

+ 10 - 2
tasks/BondlingFairyland/assets.py

@@ -39,7 +39,7 @@ class BondlingFairylandAssets:
 
 
 	# Image Rule Assets
-	# description 
+	# 挑战 
 	I_BALL_FIRE = RuleImage(roi_front=(1140,575,100,100), roi_back=(1140,575,100,100), threshold=0.8, method="Template matching", file="./tasks/BondlingFairyland/ball/ball_ball_fire.png")
 	# description 
 	I_BALL_UNLOCK = RuleImage(roi_front=(714,637,31,33), roi_back=(714,637,31,33), threshold=0.8, method="Template matching", file="./tasks/BondlingFairyland/ball/ball_ball_unlock.png")
@@ -49,6 +49,14 @@ class BondlingFairylandAssets:
 	I_BALL_RECORDS = RuleImage(roi_front=(856,566,38,39), roi_back=(856,566,38,39), threshold=0.8, method="Template matching", file="./tasks/BondlingFairyland/ball/ball_ball_records.png")
 	# 求援 
 	I_BALL_HELP = RuleImage(roi_front=(963,571,100,100), roi_back=(963,571,100,100), threshold=0.8, method="Template matching", file="./tasks/BondlingFairyland/ball/ball_ball_help.png")
+	# 契灵创建队伍 
+	I_CREATE_TEAM = RuleImage(roi_front=(569,491,141,50), roi_back=(569,491,141,50), threshold=0.8, method="Template matching", file="./tasks/BondlingFairyland/ball/create_team.png")
+	# 点击邀请 
+	I_INVITE_ENSURE = RuleImage(roi_front=(500,541,132,60), roi_back=(478,523,378,92), threshold=0.8, method="Template matching", file="./tasks/BondlingFairyland/ball/gi_invite_ensure.png")
+	# 判断是否点中好友了 
+	I_SELECTED = RuleImage(roi_front=(895,373,33,32), roi_back=(380,157,568,350), threshold=0.8, method="Template matching", file="./tasks/BondlingFairyland/ball/gi_selected.png")
+	# 用来判断当前的列表是哪儿的 
+	I_FLAG_1_ON = RuleImage(roi_front=(373,127,22,21), roi_back=(3373,127,22,21), threshold=0.8, method="Template matching", file="./tasks/BondlingFairyland/ball/gi_flag_1_on.png")
 
 
 	# Image Rule Assets
@@ -112,7 +120,7 @@ class BondlingFairylandAssets:
 	I_C_FIRST_DISABLE = RuleImage(roi_front=(713,469,38,34), roi_back=(713,469,38,34), threshold=0.8, method="Template matching", file="./tasks/BondlingFairyland/capture/capture_c_first_disable.png")
 	# description 
 	I_CAPTION_ENSURE = RuleImage(roi_front=(690,532,129,56), roi_back=(690,532,129,56), threshold=0.8, method="Template matching", file="./tasks/BondlingFairyland/capture/capture_caption_ensure.png")
-	# description 
+	# 结契设置 
 	I_CLICK_CAPTION = RuleImage(roi_front=(177,625,59,51), roi_back=(177,625,59,51), threshold=0.8, method="Template matching", file="./tasks/BondlingFairyland/capture/capture_click_caption.png")
 
 

BIN
tasks/BondlingFairyland/ball/create_team.png


BIN
tasks/BondlingFairyland/ball/gi_flag_1_on.png


+ 37 - 1
tasks/BondlingFairyland/ball/image.json

@@ -6,7 +6,7 @@
     "roiBack": "1140,575,100,100",
     "method": "Template matching",
     "threshold": 0.8,
-    "description": "description"
+    "description": "挑战"
   },
   {
     "itemName": "ball_unlock",
@@ -43,5 +43,41 @@
     "method": "Template matching",
     "threshold": 0.8,
     "description": "求援"
+  },
+  {
+    "itemName": "create_team",
+    "imageName": "create_team.png",
+    "roiFront": "569,491,141,50",
+    "roiBack": "569,491,141,50",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "契灵创建队伍"
+  },
+  {
+    "itemName": "invite_ensure",
+    "imageName": "gi_invite_ensure.png",
+    "roiFront": "500,541,132,60",
+    "roiBack": "478,523,378,92",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "点击邀请"
+  },
+  {
+    "itemName": "selected",
+    "imageName": "gi_selected.png",
+    "roiFront": "895,373,33,32",
+    "roiBack": "380,157,568,350",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "判断是否点中好友了"
+  },
+  {
+    "itemName": "flag_1_on",
+    "imageName": "gi_flag_1_on.png",
+    "roiFront": "373,127,22,21",
+    "roiBack": "3373,127,22,21",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "用来判断当前的列表是哪儿的"
   }
 ]

BIN
tasks/BondlingFairyland/ball/room_team.png


+ 2 - 2
tasks/BondlingFairyland/battle.py

@@ -14,13 +14,13 @@ from module.logger import logger
 
 class BondlingBattle(GeneralBattle, BondlingFairylandAssets):
 
-    def run_battle(self, battle_config: BattleConfig) -> bool:
+    def run_battle(self, battle_config: BattleConfig, limit_count: int = None) -> bool:
         """
         :return: 如果结契成功返回True,否则返回False
         """
         logger.hr("General battle start", 2)
         self.current_count += 1
-        logger.info(f"Current count: {self.current_count}")
+        logger.info(f"Current count: {self.current_count} / " + str(limit_count))
 
         if self.check_load():
             # 首先要判断进入战斗的界面

+ 1 - 1
tasks/BondlingFairyland/capture/image.json

@@ -105,6 +105,6 @@
     "roiBack": "177,625,59,51",
     "method": "Template matching",
     "threshold": 0.8,
-    "description": "description"
+    "description": "结契设置"
   }
 ]

+ 12 - 1
tasks/BondlingFairyland/config.py

@@ -9,6 +9,8 @@ from tasks.Component.SwitchSoul.switch_soul_config import SwitchSoulConfig
 from tasks.Component.config_scheduler import Scheduler
 from tasks.Component.config_base import ConfigBase, DateTime, TimeDelta, Time
 from tasks.BondlingFairyland.config_battle import BattleConfig
+from tasks.Component.GeneralInvite.config_invite import InviteConfig
+from tasks.Component.GeneralBattle.config_general_battle import GeneralBattleConfig
 
 class BondlingMode(str, Enum):
     MODE1 = 'mode_1'
@@ -28,8 +30,14 @@ class BondlingClass(str, Enum):
 # 低级契灵盘 Low Bondling Discs
 # 中级契灵盘 Medium Bondling Discs
 # 高级契灵盘 High Bondling Discs
-
+class UserStatus(str, Enum):
+    LEADER = 'leader'
+    MEMBER = 'member'
+    ALONE = 'alone'
+    # WILD = 'wild'  # 还不打算实现
 class BondlingConfig(ConfigBase):
+    # 身份
+    user_status: UserStatus = Field(default=UserStatus.ALONE, description='user_status_help')
     bondling_mode: BondlingMode = Field(default=BondlingMode.MODE1, description='bondling_mode_help')
     limit_time: Time = Field(default=Time(minute=30), description='limit_time_help')
     limit_count: int = Field(default=30, description='limit_count_help')
@@ -51,7 +59,10 @@ class BondlingFairyland(ConfigBase):
     scheduler: Scheduler = Field(default_factory=Scheduler)
     bondling_config: BondlingConfig = Field(default_factory=BondlingConfig)
     bondling_switch_soul: BondlingSwitchSoul = Field(default_factory=BondlingSwitchSoul)
+    invite_config: InviteConfig = Field(default_factory=InviteConfig)
     battle_config: BattleConfig = Field(default_factory=BattleConfig)
+    # battle_config: GeneralBattleConfig = Field(default_factory=GeneralBattleConfig)
+
     switch_soul_config: SwitchSoulConfig = Field(default_factory=SwitchSoulConfig)
 
 

+ 650 - 0
tasks/BondlingFairyland/general_invite.py

@@ -0,0 +1,650 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+from time import sleep
+import numpy as np
+
+from enum import Enum
+from cached_property import cached_property
+from datetime import timedelta, time
+
+from module.base.timer import Timer
+from tasks.base_task import BaseTask
+from tasks.Component.GeneralInvite.assets import GeneralInviteAssets
+from tasks.Component.GeneralInvite.config_invite import InviteConfig, InviteNumber, FindMode
+from tasks.Component.GeneralBattle.assets import GeneralBattleAssets
+from tasks.BondlingFairyland.assets import BondlingFairylandAssets
+
+from module.logger import logger
+
+
+class FriendList(str, Enum):
+    RECENT_FRIEND = 'recent_friend'
+    GUILD_FRIEND = 'guild_friend'
+    FRIEND = 'friend'
+    OTHER_FRIEND = 'other_friend'
+
+
+class RoomType(str, Enum):
+    # 房间只可以两个人的: 探索
+    NORMAL_2 = 'normal_2'
+    # 房间可以两三个人的: 觉醒、御魂、日轮、石距(石距是单次没有锁定阵容)
+    NORMAL_3 = 'normal_3'
+    # 永生之海不一样
+    ETERNITY_SEA = 'eternity_sea'
+    # 经验妖怪和金币妖怪
+    NORMAL_5 = 'normal_5'
+
+
+class GeneralInvite(BaseTask, BondlingFairylandAssets, GeneralInviteAssets):
+    timer_invite = None
+    timer_wait = None
+    timer_emoji = None  # 等待期间如果没有操作的话,可能会导致长时间无响应报错
+
+    """
+
+    """
+
+    def run_invite(self, config: InviteConfig, is_first: bool = False) -> bool:
+        """
+        队长!!身份。。。在组队界面邀请好友( 如果开启is_first) 等待队员进入开启挑战
+        请注意,返回的时候成功时是进入战斗了!!!
+        如果是失败,那就是没有队友进入,然后会退出房间的界面
+        :param config:
+        :param is_first: 如果是第一次开房间的那就要邀请队员,其他情况等待队员进入
+        :return:
+        """
+        logger.hr('Invite friend', 2)
+        if not self.ensure_enter():
+            logger.warning('Not enter invite page')
+            return False
+        if is_first:
+            _ = self.room_type
+            self.timer_invite = Timer(20)
+            self.timer_invite.start()
+            self.ensure_room_type(config.invite_number)
+            self.invite_friends(config)
+        else:
+            self.timer_invite = Timer(30)
+            self.timer_invite.start()
+            self.timer_emoji = Timer(20)
+            self.timer_emoji.start()
+        wait_second = config.wait_time.second + config.wait_time.minute * 60
+        self.timer_wait = Timer(wait_second)
+        self.timer_wait.start()
+        while 1:
+            self.screenshot()
+            if self.timer_wait.reached():
+                logger.warning('Wait timeout')
+                return False
+            if self.appear(self.I_MATCHING):
+                logger.warning('Timeout, now is no room')
+                return False
+
+            if not self.is_in_room():
+                continue
+
+            if self.timer_emoji and 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)
+
+            fire = False  # 是否开启挑战
+            # 如果这个房间最多只容纳两个人(意思是只可以邀请一个人),且已经邀请一个人了,那就开启挑战
+            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')
+                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:
+                self.click_fire()
+                return True
+
+            if self.timer_invite and self.timer_invite.reached():
+                if is_first:
+                    logger.info('Invitation is triggered every 20s')
+                    self.timer_invite.reset()
+                else:
+                    logger.info('Wait for 30s and invite again')
+                    self.timer_invite = None
+                self.invite_friends(config)
+
+    def ensure_enter(self) -> bool:
+        """
+        确认是否进入了组队界面
+        :return:
+        """
+        logger.info('Ensure enter invite page')
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_ADD_2):
+                return True
+            if self.appear(self.I_ADD_5_4):
+                return True
+            if self.appear(self.I_LOCK_SEA):
+                return True
+            if self.appear(self.I_UNLOCK_SEA):
+                return True
+            # 修复三人组队卡住bug,#78
+            # 增加左上角协战房间判断,存在就说明在组队界面
+            if self.appear(self.I_GI_IN_ROOM):
+                return True
+            if self.appear(self.I_MATCHING):
+                return False
+
+    # 判断是否在房间里面
+    def is_in_room(self, is_screenshot: bool = True) -> bool:
+        """
+        判断是否在房间里面
+        :return:
+        """
+        if is_screenshot:
+            self.screenshot()
+        if self.appear(self.I_GI_EMOJI_1):
+            return True
+        if self.appear(self.I_GI_EMOJI_2):
+            return True
+        # if self.appear(self.I_MATCHING):
+        #     return False
+        return False
+
+    def exit_room(self) -> bool:
+        """
+        退出房间
+        :return:
+        """
+        if not self.is_in_room():
+            return False
+        logger.info('Exit room')
+        while 1:
+            self.screenshot()
+            if not self.is_in_room() and \
+                    not self.appear_then_click(self.I_GI_SURE, interval=0.8) and \
+                    not self.appear(self.I_BACK_YELLOW):
+                break
+            if self.appear_then_click(self.I_GI_SURE, interval=0.5):
+                continue
+            if not self.appear(self.I_GI_SURE) and self.appear_then_click(self.I_BACK_YELLOW, interval=0.8):
+                self.wait_until_appear(self.I_GI_SURE, wait_time=0.8)
+                continue
+        return True
+
+    def click_fire(self):
+        while 1:
+            self.screenshot()
+            if not self.is_in_room(False):
+                break
+            if self.appear_then_click(self.I_FIRE, interval=1, threshold=0.7):
+                continue
+
+    @cached_property
+    def room_type(self) -> RoomType:
+        """
+        只需要在队长进入的时候判断一次就可以了,任务后面之间使用
+
+        :return:
+        """
+        self.screenshot()
+        room_type = self.check_room_type(image=self.device.image)
+        logger.info(f'Room type: {room_type}')
+        return room_type
+
+    def check_room_type(self, image: np.array = None, pre_type: RoomType = None) -> RoomType:
+        """
+        检查房间类型
+        :param image:
+        :param pre_type: 可以先指定这个类型,如果不指定,就自动检查
+        :return:
+        """
+
+        def check_3(img) -> bool:
+            appear = False
+            if self.I_ADD_1.match(img) and self.I_ADD_2.match(img):
+                appear = True
+            return appear
+
+        def check_2(img) -> bool:
+            appear = False
+            if self.I_ADD_1.match(img) and not self.I_ADD_2.match(img):
+                appear = True
+            return appear
+
+        def check_5(img) -> bool:
+            appear = False
+            if self.I_ADD_5_1.match(img) and self.I_ADD_5_2.match(img) \
+                    and self.I_ADD_5_3.match(img) and self.I_ADD_5_4.match(img):
+                appear = True
+            return appear
+
+        def check_eternity_sea(img) -> bool:
+            appear = False
+            if self.I_LOCK_SEA.match(img) or self.I_UNLOCK_SEA.match(img):
+                appear = True
+            return appear
+
+        room_type = None
+        if pre_type is not None:
+            match pre_type:
+                case RoomType.NORMAL_2:
+                    room_type = RoomType.NORMAL_2 if check_2(image) else None
+                case RoomType.NORMAL_3:
+                    room_type = RoomType.NORMAL_3 if check_3(image) else None
+                case RoomType.NORMAL_5:
+                    room_type = RoomType.NORMAL_5 if check_5(image) else None
+                case RoomType.ETERNITY_SEA:
+                    room_type = RoomType.ETERNITY_SEA if check_eternity_sea(image) else None
+        if room_type:
+            return room_type
+        if room_type is None and check_2(image):
+            room_type = RoomType.NORMAL_2
+            return room_type
+        if room_type is None and check_3(image):
+            room_type = RoomType.NORMAL_3
+            return room_type
+        if room_type is None and check_5(image):
+            room_type = RoomType.NORMAL_5
+            return room_type
+        if room_type is None and check_eternity_sea(image):
+            room_type = RoomType.ETERNITY_SEA
+            return room_type
+        return room_type
+
+    def ensure_room_type(self, friend_number: int = None) -> bool:
+        """
+        确认设定的邀请人数是否会超出房间的最大
+        :param friend_number: 这个输入的是用户选项中的invite_number
+        :return:  如果超出了,就返回False
+        """
+        if isinstance(friend_number, InviteNumber):
+            if friend_number == InviteNumber.ONE:
+                friend_number = 1
+            elif friend_number == InviteNumber.TWO:
+                friend_number = 2
+
+        if friend_number == 2:
+            if self.room_type == RoomType.NORMAL_2:
+                # 整个房间就可以两个人,还邀请两个 这个是报错的
+                logger.error('Room can only be one people, but invite two people')
+                return False
+            elif self.room_type == RoomType.ETERNITY_SEA:
+                # 永生之海,只能邀请一个人
+                logger.error('Room can only be one people, but invite two people')
+                return False
+            return True
+        return True
+
+    @cached_property
+    def friend_class(self) -> list[str]:
+        return ['好友', '最近', '跨区', '寮友', '蔡友', '路区', '察友', '区']
+
+    def detect_select(self, name: str = None) -> bool:
+        """
+        在当前的页面检测是否有好友, 如果有就选中这个好友
+        :return:
+        """
+        if not name:
+            return False
+
+        self.screenshot()
+        self.O_FRIEND_NAME_1.keyword = name
+        self.O_FRIEND_NAME_2.keyword = name
+        appear_1 = self.ocr_appear_click(self.O_FRIEND_NAME_1, interval=2)
+        appear_2 = self.ocr_appear_click(self.O_FRIEND_NAME_2, interval=2)
+        if not appear_1 and not appear_2:
+            logger.info('Current page no friend')
+            return False
+
+        while appear_1 or appear_2:
+            self.screenshot()
+            if self.appear(self.I_SELECTED):
+                break
+            appear_1 = self.ocr_appear_click(self.O_FRIEND_NAME_1, interval=2)
+            appear_2 = self.ocr_appear_click(self.O_FRIEND_NAME_2, interval=2)
+
+        return True
+
+    def invite_friend(self, name: str = None, find_mode: FindMode = FindMode.AUTO_FIND) -> bool:
+        """
+        邀请好友
+        :param find_mode: 寻找的方式
+        :param name:
+        :return:
+        """
+        logger.info('Click add to invite friend')
+        # 点击+号
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_LOAD_FRIEND):
+                break
+            if self.appear(self.I_INVITE_ENSURE):
+                break
+            if self.appear_then_click(self.I_ADD_2, interval=1):
+                continue
+            if self.appear_then_click(self.I_ADD_1, interval=1):
+                continue
+            if self.appear_then_click(self.I_ADD_5_4, interval=1):
+                continue
+
+        friend_class = []
+        class_ocr = [self.O_F_LIST_1, self.O_F_LIST_2, self.O_F_LIST_3, self.O_F_LIST_4]
+        class_index = 0
+        list_1 = self.O_F_LIST_1.ocr(self.device.image)
+        list_2 = self.O_F_LIST_2.ocr(self.device.image)
+        list_3 = self.O_F_LIST_3.ocr(self.device.image)
+        list_4 = self.O_F_LIST_4.ocr(self.device.image)
+        list_1 = list_1.replace(' ', '').replace('、', '')
+        list_2 = list_2.replace(' ', '').replace('、', '')
+        list_3 = list_3.replace(' ', '').replace('、', '')
+        if list_1 is not None and list_1 != '' and list_1 in self.friend_class:
+            friend_class.append(list_1)
+        if list_2 is not None and list_2 != '' and list_2 in self.friend_class:
+            friend_class.append(list_2)
+        if list_3 is not None and list_3 != '' and list_3 in self.friend_class:
+            friend_class.append(list_3)
+        if list_4 is not None and list_4 != '' and list_4 in self.friend_class:
+            friend_class.append(list_4)
+        for i in range(len(friend_class)):
+            if friend_class[i] == '蔡友':
+                friend_class[i] = '寮友'
+            elif friend_class[i] == '路区':
+                friend_class[i] = '跨区'
+            elif friend_class[i] == '察友':
+                friend_class[i] = '寮友'
+            elif friend_class[i] == '区':
+                friend_class[i] = '跨区'
+        logger.info(f'Friend class: {friend_class}')
+
+        is_select: bool = False  # 是否选中了好友
+        if find_mode == FindMode.RECENT_FRIEND:
+            logger.info('Find recent friend')
+            # 获取’最近‘在friend_class中的index
+            if '最近' not in friend_class:
+                logger.warning('No recent friend')
+                return False
+            recent_index = friend_class.index('最近')
+            while recent_index == 1:
+                self.screenshot()
+                if self.appear(self.I_FLAG_2_ON):
+                    break
+                if self.appear_then_click(self.I_FLAG_2_OFF, interval=1):
+                    continue
+
+            logger.info(f'Now find friend in ”最近“')
+            sleep(1)
+            if not is_select:
+                if self.detect_select(name):
+                    is_select = True
+            sleep(1)
+            if not is_select:
+                if self.detect_select(name):
+                    is_select = True
+
+        for index in range(len(friend_class)):
+            # 如果不是自动寻找,就跳过
+            if find_mode != FindMode.AUTO_FIND:
+                continue
+            # 如果已经选中了好友,就不需要再选中了
+            if is_select:
+                continue
+            # 首先切换到不同的好友列表
+            while index == 0:
+                self.screenshot()
+                if self.appear(self.I_FLAG_1_ON):
+                    break
+                if self.appear_then_click(self.I_FLAG_1_OFF, interval=1):
+                    continue
+            while index == 1:
+                self.screenshot()
+                if self.appear(self.I_FLAG_2_ON):
+                    break
+                if self.appear_then_click(self.I_FLAG_2_OFF, interval=1):
+                    continue
+            while index == 2:
+                self.screenshot()
+                if self.appear(self.I_FLAG_3_ON):
+                    break
+                if self.appear_then_click(self.I_FLAG_3_OFF, interval=1):
+                    continue
+            while index == 3:
+                self.screenshot()
+                if self.appear(self.I_FLAG_4_ON):
+                    break
+                if self.appear_then_click(self.I_FLAG_4_OFF, interval=1):
+                    continue
+
+            # 选中好友, 在这里游戏获取在线的好友并不是很快,根据不同的设备会有不同的时间,而且没有什么元素提供我们来判断
+            # 所以这里就直接等待一段时间
+            logger.info(f'Now find friend in {friend_class[index]}')
+            sleep(1)
+            if not is_select:
+                if self.detect_select(name):
+                    is_select = True
+            sleep(1)
+            if not is_select:
+                if self.detect_select(name):
+                    is_select = True
+
+        # 点击确定
+        logger.info('Click invite ensure')
+        if not self.appear(self.I_INVITE_ENSURE):
+            logger.warning('No appear invite ensure while invite friend')
+        while 1:
+            self.screenshot()
+            if not self.appear(self.I_INVITE_ENSURE):
+                break
+            if self.appear_then_click(self.I_INVITE_ENSURE):
+                continue
+        # 哪怕没有找到好友也有点击 确认 以退出好友列表
+        if not is_select:
+            logger.warning('No find friend')
+            # 这个时候任务运行失败
+            logger.info('Task failed')
+            return False
+
+        return True
+
+    def invite_friends(self, config: InviteConfig) -> bool:
+        """
+        看情况邀请两个好友
+        :return:
+        """
+        success = self.invite_friend(config.friend_1, config.find_mode)
+        if not success:
+            logger.warning('Invite friend 1 failed')
+        # 如果是邀请第二个人
+        if config.invite_number == InviteNumber.TWO:
+            success = self.invite_friend(config.friend_2, config.find_mode)
+            if not success:
+                logger.warning('Invite friend 2 failed')
+        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:
+        """
+        队长战斗后 邀请队友
+        :param default_invite:
+        :return:
+        """
+        if not self.appear(self.I_GI_SURE):
+            return False
+
+        if default_invite:
+            # 有可能是挑战失败的
+            if self.appear(self.I_I_DEFAULT) or self.appear(self.I_I_NO_DEFAULT):
+                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
+        # 点击确认
+        while 1:
+            self.screenshot()
+            if not self.appear(self.I_GI_SURE):
+                break
+            if self.appear_then_click(self.I_GI_SURE, interval=1):
+                continue
+
+        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
+        """
+        self.timer_emoji = Timer(15)
+        self.timer_emoji.start()
+        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):
+                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:
+                break
+
+
+        # 调出循环只有这些可能性:
+        # 1. 进入战斗(ui是战斗)
+        # 2. 队长跑路(自己还是在房间里面)
+        # 3. 等待时间到没有开始(还是在房间里面)
+        # 4. 房间的时间到了被迫提出房间(这个时候来到了探索界面)
+        if not success:
+            logger.info('Leave room')
+            self.exit_room()
+
+        return success
+
+
+
+
+if __name__ == '__main__':
+    from module.config.config import Config
+    from module.device.device import Device
+    import cv2
+
+    c = Config('oas1')
+    d = Device(c)
+    t = GeneralInvite(c, d)
+
+    # t.run_invite(c.orochi.invite_config, is_first=True)
+    t.screenshot()
+    print(t.appear(t.I_FIRE, threshold=0.8))
+
+

+ 345 - 21
tasks/BondlingFairyland/script_task.py

@@ -2,16 +2,20 @@
 # @author runhey
 # github https://github.com/runhey
 
+from tasks.Component.GeneralRoom.general_room import GeneralRoom
+
 import numpy as np
 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)
+                                            BondlingSwitchSoul, BondlingConfig, UserStatus)
 from tasks.BondlingFairyland.assets import BondlingFairylandAssets
 from tasks.BondlingFairyland.battle import BondlingBattle
 from tasks.BondlingFairyland.config_battle import BattleConfig
@@ -22,16 +26,16 @@ from tasks.GameUi.page import page_main, page_bondling_fairyland, page_shikigami
 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
 
 
 class BondlingNumberMax(Exception):
     pass
 
 
-
-class ScriptTask(GameUi, BondlingBattle, SwitchSoul, BondlingFairylandAssets):
-
+class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul, BondlingFairylandAssets):
     ball_pos_list = [None, None, None, None, None]  # 用于记录每一个位置的球是否出现
     first_catch = True  # 用于记录是否是第一次捕捉
 
@@ -44,7 +48,7 @@ class ScriptTask(GameUi, BondlingBattle, SwitchSoul, BondlingFairylandAssets):
             self.ui_get_current_page()
             self.ui_goto(page_shikigami_records)
             self.run_switch_soul(cong.switch_soul_config.switch_group_team)
-          # 御魂切换方式二
+        # 御魂切换方式二
         if cong.switch_soul_config.enable_switch_by_name:
             self.ui_get_current_page()
             self.ui_goto(page_shikigami_records)
@@ -53,6 +57,100 @@ class ScriptTask(GameUi, BondlingBattle, SwitchSoul, BondlingFairylandAssets):
         self.ui_get_current_page()
         self.ui_goto(page_bondling_fairyland)
 
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_CHECK_BONDLING_FAIRYLAND, interval=1):
+                break
+            if self.appear(self.I_BALL_HELP, interval=1):
+                self.ui_get_current_page()
+                self.ui_goto(page_bondling_fairyland)
+                continue
+
+        limit_count = cong.bondling_config.limit_count
+        self.current_count = 0
+        self.limit_count: int = limit_count
+
+        match cong.bondling_config.user_status:
+            case UserStatus.LEADER:
+                self.switch_ball()
+            case UserStatus.MEMBER:
+                self.run_member()
+            case UserStatus.ALONE:
+                self.switch_ball()
+            case _:
+                logger.error('Unknown user status')
+
+    def run_member(self):
+        logger.info('Start run member')
+        self.ui_get_current_page()
+        # 开始等待队长拉人
+        wait_time = self.config.bondling_fairyland.invite_config.wait_time
+        wait_timer = Timer(wait_time.minute * 60)
+        wait_timer.start()
+        success = True
+
+        # 进入战斗流程
+        self.device.stuck_record_add('BATTLE_STATUS_S')
+
+        while 1:
+
+            self.screenshot()
+
+            # 等待超时
+            logger.info("开始等待队长拉人:" + str(wait_timer.current()))
+            if wait_timer.reached():
+                logger.warning('wait_timer timeout')
+                break
+
+            # if self.current_count >= self.limit_count:
+            #     logger.info('Orochi count limit out')
+            #     break
+            if datetime.now() - self.start_time >= self.limit_time:
+                logger.info('Orochi time limit out')
+                break
+
+            if self.check_then_accept():
+                continue
+
+            if self.is_in_room():
+                logger.info("契灵:进入组队房间!")
+                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)
+                    wait_timer.reset()
+                    # 进入战斗流程
+                    self.device.stuck_record_add('BATTLE_STATUS_S')
+                else:
+                    break
+            # 队长秒开的时候,检测是否进入到战斗中
+            elif self.check_take_over_battle(False, config=self.config.bondling_fairyland.battle_config):
+                wait_timer.reset()
+                # 进入战斗流程
+                self.device.stuck_record_add('BATTLE_STATUS_S')
+                continue
+
+        while 1:
+            # 有一种情况是本来要退出的,但是队长邀请了进入的战斗的加载界面
+            if self.appear(self.I_GI_HOME) or self.appear(self.I_GI_EXPLORE) or self.appear(self.I_CHECK_BONDLING_FAIRYLAND):
+                break
+            # 如果可能在房间就退出
+            if self.exit_room():
+                pass
+            # 如果还在战斗中,就退出战斗
+            if self.exit_battle():
+                pass
+
+        self.ui_get_current_page()
+        self.ui_goto(page_main)
+
+        if success:
+            self.set_next_run(task='BondlingFairyland', finish=True, success=True)
+        else:
+            self.set_next_run(task='BondlingFairyland', finish=True, success=False)
+        raise TaskEnd
+
+    def switch_ball(self):
+        cong = self.config.bondling_fairyland
+
         bondling_config = cong.bondling_config
         bondling_switch_soul = cong.bondling_switch_soul
         battle_config = cong.battle_config
@@ -88,6 +186,7 @@ class ScriptTask(GameUi, BondlingBattle, SwitchSoul, BondlingFairylandAssets):
                     continue
 
                 try:
+                    # 执行捕捉
                     if self.run_catch(bondling_config, bondling_switch_soul, battle_config):
                         current_ball -= 1
                         logger.info(f'Catch successful and current ball number: {current_ball} ')
@@ -120,7 +219,6 @@ class ScriptTask(GameUi, BondlingBattle, SwitchSoul, BondlingFairylandAssets):
             self.set_next_run(task='BondlingFairyland', finish=True, success=False)
         raise TaskEnd
 
-
     def run_stone(self, bondling_stone_enable: bool, bondling_stone_class: BondlingClass):
         """
         使用结契石 进行召唤 契灵
@@ -171,8 +269,6 @@ class ScriptTask(GameUi, BondlingBattle, SwitchSoul, BondlingFairylandAssets):
                             continue
                     break
 
-
-
                 if self.appear_then_click(self.I_STONE_ENTER, interval=1):
                     click_count += 1
                     continue
@@ -217,7 +313,6 @@ class ScriptTask(GameUi, BondlingBattle, SwitchSoul, BondlingFairylandAssets):
         (4) 捕获成功,返回True (退出页面是捕获的页面)
         """
 
-
         self.lock_team()
         if self.first_catch:
             self.first_catch = False
@@ -234,6 +329,7 @@ class ScriptTask(GameUi, BondlingBattle, SwitchSoul, BondlingFairylandAssets):
                 logger.warning(f'No plate number, exit')
                 return False
             return True
+
         if not check_plate_number(target_plate):
             return False
 
@@ -247,7 +343,7 @@ class ScriptTask(GameUi, BondlingBattle, SwitchSoul, BondlingFairylandAssets):
                 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')
+                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))
@@ -260,8 +356,8 @@ class ScriptTask(GameUi, BondlingBattle, SwitchSoul, BondlingFairylandAssets):
             first_switch_soul = False
             switch_soul(bondling_class)
 
-
         # 开始执行循环
+        success =True
         while 1:
             self.screenshot()
 
@@ -281,13 +377,29 @@ class ScriptTask(GameUi, BondlingBattle, SwitchSoul, BondlingFairylandAssets):
             if datetime.now() - self.start_time >= self.limit_time:
                 logger.warning(f'No time, exit')
                 return False
-            # ok 就进行挑战
-            self.click_fire()
-            if self.run_battle(battle_config):
-                return True
-
-
 
+            # 引用配置
+            cong = self.config.bondling_fairyland
+            match cong.bondling_config.user_status:
+                case UserStatus.LEADER:
+                    if self.run_leader():
+                        return success
+                case UserStatus.ALONE:
+                    self.run_alone()
+                    if self.run_battle(battle_config, limit_count=self.limit_count):
+                        return success
+                case _:
+                    logger.error('Unknown user status')
+
+
+    def is_room_dead(self) -> bool:
+        # 如果在探索界面或者是出现在组队界面,那就是可能房间死了
+        sleep(0.5)
+        if self.appear(self.I_MATCHING) or self.appear(self.I_CHECK_EXPLORATION):
+            sleep(0.5)
+            if self.appear(self.I_MATCHING) or self.appear(self.I_CHECK_EXPLORATION):
+                return True
+        return False
 
     @cached_property
     def balls_target(self) -> list[RuleImage]:
@@ -389,7 +501,6 @@ class ScriptTask(GameUi, BondlingBattle, SwitchSoul, BondlingFairylandAssets):
             if self.click(click_target, interval=1):
                 click_count += 1
 
-
     def capture_setting(self, mode: BondlingMode) -> None:
         """
         第一次进入任务的时候触发这一项方法:为了确保用户的选择默认是正确的
@@ -499,9 +610,9 @@ class ScriptTask(GameUi, BondlingBattle, SwitchSoul, BondlingFairylandAssets):
         limit_time = self.config.bondling_fairyland.bondling_config.limit_time
         return timedelta(hours=limit_time.hour, minutes=limit_time.minute, seconds=limit_time.second)
 
-    def click_fire(self):
+    def run_alone(self):
         """
-        点击 挑战, 主要是结契时的挑战
+        单人 挑战, 主要是结契时的挑战
         """
         click_count = 0
         while 1:
@@ -519,6 +630,180 @@ class ScriptTask(GameUi, BondlingBattle, SwitchSoul, BondlingFairylandAssets):
             if self.appear_then_click(self.I_UI_CONFIRM, interval=1):
                 continue
 
+    def run_leader(self):
+
+        """
+        点击 求援, 组队模式
+        """
+        click_count = 0
+        # target = None
+        # appear1 = self.I_CREATE_ENSURE.match(self.device.image)
+        while 1:
+            self.screenshot()
+            if click_count >= 6:
+                logger.error('Click fire failed')
+                logger.error('You might need to check your bondling number. It most possibly arrived to the max 500')
+                raise BondlingNumberMax
+            if self.appear(self.I_CREATE_TEAM):
+                break
+            # 某些活动的时候出现 “选择共鸣的阴阳师”
+            if self.appear_then_click(self.I_UI_CONFIRM, interval=1):
+                continue
+            # 盘子满了继续
+            if self.check_and_invite(True):
+                continue
+            # 求援
+            if self.appear_then_click(self.I_BALL_HELP, interval=1):
+                click_count += 1
+                continue
+
+        while 1:
+            self.screenshot()
+            if self.ensure_private():
+                break
+        while 1:
+            self.screenshot()
+
+            if self.appear(self.I_GI_IN_ROOM):
+                break
+            if self.appear_then_click(self.I_CREATE_TEAM, interval=1):
+                continue
+
+        # 邀请队友
+        success = True
+        is_first = True
+        # 这个时候我已经进入房间了哦
+        while 1:
+            self.screenshot()
+
+            # 无论胜利与否, 都会出现是否邀请一次队友
+            # 区别在于,失败的话不会出现那个勾选默认邀请的框
+            self.check_and_invite(True)
+
+            if self.current_count >= self.limit_count:
+                if self.appear(self.I_GI_IN_ROOM):
+                    logger.info('bondling_fairyland count limit out')
+                    break
+
+            if datetime.now() - self.start_time >= self.limit_time:
+                if self.appear(self.I_GI_IN_ROOM):
+                    logger.info('bondling_fairyland time limit out')
+                    break
+
+            if self.appear(self.I_GI_IN_ROOM):
+                # 点击挑战
+                if not is_first:
+                    if self.run_invite(config=self.config.bondling_fairyland.invite_config):
+                        self.run_battle(self.config.bondling_fairyland.battle_config, limit_count=self.limit_count)
+                    else:
+                        # 邀请失败,退出任务
+                        logger.warning('Invite failed and exit this bondling_fairyland task')
+                        success = False
+                        break
+
+                # 第一次会邀请队友
+                if is_first:
+                    if not self.run_invite(config=self.config.bondling_fairyland.invite_config, is_first=True):
+                        logger.warning('Invite failed and exit this bondling_fairyland task')
+                        success = False
+                        break
+                    else:
+                        is_first = False
+                        self.run_battle(self.config.bondling_fairyland.battle_config, limit_count=self.limit_count)
+                        continue
+            if self.appear(self.I_CHECK_BONDLING_FAIRYLAND):
+                return True
+        # 当结束或者是失败退出循环的时候只有两个UI的可能,在房间或者是在组队界面
+        # 如果在房间就退出
+        if self.exit_room():
+            pass
+        # 如果在组队界面就退出
+        if self.exit_team():
+            pass
+
+        self.ui_get_current_page()
+        self.ui_goto(page_main)
+
+        if success:
+            self.set_next_run(task='BondlingFairyland', finish=True, success=True)
+        else:
+            self.set_next_run(task='BondlingFairyland', finish=True, success=False)
+        raise TaskEnd
+
+    def wait_battle(self, wait_time: time) -> bool:
+        """
+        在房间等待,(要求保证在房间里面) 队长开启战斗
+        如果队长跑路了,或者的等待了很久还没开始
+        :return: 如果成功进入战斗(反正就是不在房间 )返回 True
+                 如果失败了,(退出房间)返回 False
+        """
+        self.timer_emoji = Timer(15)
+        self.timer_emoji.start()
+        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) or self.appear(self.I_CHECK_BONDLING_FAIRYLAND):
+                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_EXIT):
+                success = True
+                logger.info("契灵:进入战斗页面!")
+                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是战斗)
+        # 2. 队长跑路(自己还是在房间里面)
+        # 3. 等待时间到没有开始(还是在房间里面)
+        # 4. 房间的时间到了被迫提出房间(这个时候来到了探索界面)
+        if not success:
+            logger.info('Leave room')
+            self.exit_room()
+
+        return success
+
+    def exit_team(self) -> bool:
+        """
+        在组队界面 退出组队的界面, 返回到庭院或者是你一开始进入的入口
+        :return:
+        """
+        if self.appear(self.I_CHECK_TEAM):
+            logger.info('Exit team ui')
+            while 1:
+                self.screenshot()
+                if not self.appear(self.I_CHECK_TEAM):
+                    return True
+                if self.appear_then_click(self.I_GR_BACK_YELLOW, interval=0.5):
+                    continue
+
     def in_catch_ui(self, screenshot=False) -> bool:
         """
         判断是否在结契的总界面
@@ -558,6 +843,44 @@ class ScriptTask(GameUi, BondlingBattle, SwitchSoul, BondlingFairylandAssets):
                 continue
         return False
 
+    def check_then_accept(self) -> bool:
+        """
+        队员接受邀请
+        :return:
+        """
+        if not self.appear(self.I_I_ACCEPT):
+            return False
+        logger.info('Click accept')
+
+        accept_timer = Timer(5)
+        accept_timer.start()
+        logger.info("识别到队长邀请,准备点击接受")
+        while 1:
+            self.screenshot()
+
+            # 等待超时
+            logger.info(str(accept_timer.current()))
+            if accept_timer.reached():
+                logger.warning('accept_timer timeout')
+                break
+
+            if self.is_in_room():
+                return True
+            # 被秒开
+            # https://github.com/runhey/OnmyojiAutoScript/issues/230
+            if self.appear(GeneralBattleAssets.I_EXIT):
+                logger.info("进入到组队房间!")
+                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
+
     @cached_property
     def general_battle_config(self):
         gbc = GeneralBattleConfig()
@@ -567,6 +890,7 @@ class ScriptTask(GameUi, BondlingBattle, SwitchSoul, BondlingFairylandAssets):
         gbc.random_click_swipt_enable = False
         return gbc
 
+
 if __name__ == '__main__':
     from module.config.config import Config
     from module.device.device import Device

+ 13 - 0
tasks/Component/Costume/assets.py

@@ -23,6 +23,19 @@ class CostumeAssets:
 	I_PET_HOUSE_1 = RuleImage(roi_front=(1250,439,25,26), roi_back=(1198,362,81,147), threshold=0.8, method="Template matching", file="./tasks/Component/Costume/main1/main1_pet_house_1.png")
 
 
+	# Image Rule Assets
+	# description 
+	I_CHECK_MAIN_10 = RuleImage(roi_front=(725,125,134,42), roi_back=(149,109,1099,100), threshold=0.8, method="Template matching", file="./tasks/Component/Costume/main10/main10_check_main_10.png")
+	# description 
+	I_MAIN_GOTO_EXPLORATION_10 = RuleImage(roi_front=(444,170,31,30), roi_back=(193,143,904,66), threshold=0.6, method="Template matching", file="./tasks/Component/Costume/main10/main10_main_goto_exploration_10.png")
+	#  
+	I_MAIN_GOTO_SUMMON_10 = RuleImage(roi_front=(899,139,35,29), roi_back=(515,115,623,68), threshold=0.6, method="Template matching", file="./tasks/Component/Costume/main10/main10_main_goto_summon_10.png")
+	# description 
+	I_MAIN_GOTO_TOWN_10 = RuleImage(roi_front=(712,328,41,42), roi_back=(270,307,999,78), threshold=0.7, method="Template matching", file="./tasks/Component/Costume/main10/main10_main_goto_town_10.png")
+	# description 
+	I_PET_HOUSE_10 = RuleImage(roi_front=(954,425,40,35), roi_back=(737,401,440,69), threshold=0.8, method="Template matching", file="./tasks/Component/Costume/main10/main10_pet_house_10.png")
+
+
 	# Image Rule Assets
 	# description 
 	I_CHECK_MAIN_2 = RuleImage(roi_front=(1090,146,48,55), roi_back=(880,108,271,100), threshold=0.8, method="Template matching", file="./tasks/Component/Costume/main2/main2_check_main_2.png")

+ 1 - 0
tasks/Component/Costume/config.py

@@ -16,6 +16,7 @@ class MainType(str, Enum):
     COSTUME_MAIN_7 = 'costume_main_7'  # 盛夏幽庭
     COSTUME_MAIN_8 = 'costume_main_8'  # 远海航船
     COSTUME_MAIN_9 = 'costume_main_9'  # 结缘神社
+    COSTUME_MAIN_10 = 'costume_main_10'  # 望月幽庭
 
 # 结界皮肤
 class RealmType(str, Enum):

+ 5 - 0
tasks/Component/Costume/costume_base.py

@@ -58,6 +58,11 @@ main_costume_model = {
                               'I_MAIN_GOTO_SUMMON': 'I_MAIN_GOTO_SUMMON_9',
                               'I_MAIN_GOTO_TOWN': 'I_MAIN_GOTO_TOWN_9',
                               'I_PET_HOUSE': 'I_PET_HOUSE_9', },
+    MainType.COSTUME_MAIN_10: {'I_CHECK_MAIN': 'I_CHECK_MAIN_10',
+                               'I_MAIN_GOTO_EXPLORATION': 'I_MAIN_GOTO_EXPLORATION_10',
+                               'I_MAIN_GOTO_SUMMON': 'I_MAIN_GOTO_SUMMON_10',
+                               'I_MAIN_GOTO_TOWN': 'I_MAIN_GOTO_TOWN_10',
+                               'I_PET_HOUSE': 'I_PET_HOUSE_10', },
 }
 
 # 结界皮肤

+ 47 - 0
tasks/Component/Costume/main10/image.json

@@ -0,0 +1,47 @@
+[
+  {
+    "itemName": "check_main_10",
+    "imageName": "main10_check_main_10.png",
+    "roiFront": "725,125,134,42",
+    "roiBack": "149,109,1099,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "main_goto_exploration_10",
+    "imageName": "main10_main_goto_exploration_10.png",
+    "roiFront": "444,170,31,30",
+    "roiBack": "193,143,904,66",
+    "method": "Template matching",
+    "threshold": 0.6,
+    "description": "description"
+  },
+  {
+    "itemName": "main_goto_summon_10",
+    "imageName": "main10_main_goto_summon_10.png",
+    "roiFront": "899,139,35,29",
+    "roiBack": "515,115,623,68",
+    "method": "Template matching",
+    "threshold": 0.6,
+    "description": ""
+  },
+  {
+    "itemName": "main_goto_town_10",
+    "imageName": "main10_main_goto_town_10.png",
+    "roiFront": "712,328,41,42",
+    "roiBack": "270,307,999,78",
+    "method": "Template matching",
+    "threshold": 0.7,
+    "description": "description"
+  },
+  {
+    "itemName": "pet_house_10",
+    "imageName": "main10_pet_house_10.png",
+    "roiFront": "954,425,40,35",
+    "roiBack": "737,401,440,69",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  }
+]

BIN
tasks/Component/Costume/main10/main10_check_main_10.png


BIN
tasks/Component/Costume/main10/main10_main_goto_exploration_10.png


BIN
tasks/Component/Costume/main10/main10_main_goto_summon_10.png


BIN
tasks/Component/Costume/main10/main10_main_goto_town_10.png


BIN
tasks/Component/Costume/main10/main10_pet_house_10.png


+ 21 - 11
tasks/Component/GeneralBattle/assets.py

@@ -27,27 +27,27 @@ class GeneralBattleAssets:
 
 	# Click Rule Assets
 	# 预设队伍1 
-	C_PRESET_TEAM_1 = RuleClick(roi_front=(196,234,464,114), roi_back=(196,234,464,114), name="preset_team_1")
+	C_PRESET_TEAM_1 = RuleClick(roi_front=(195,235,465,110), roi_back=(195,235,465,110), name="preset_team_1")
 	# 预设队伍2 
-	C_PRESET_TEAM_2 = RuleClick(roi_front=(197,358,465,103), roi_back=(197,358,465,103), name="preset_team_2")
+	C_PRESET_TEAM_2 = RuleClick(roi_front=(195,355,465,110), roi_back=(195,355,465,110), name="preset_team_2")
 	# 预设队伍3 
-	C_PRESET_TEAM_3 = RuleClick(roi_front=(195,480,462,100), roi_back=(195,480,462,100), name="preset_team_3")
+	C_PRESET_TEAM_3 = RuleClick(roi_front=(195,475,465,110), roi_back=(195,475,465,110), name="preset_team_3")
 	# 预设队伍4 
-	C_PRESET_TEAM_4 = RuleClick(roi_front=(193,596,464,35), roi_back=(193,596,464,35), name="preset_team_4")
+	C_PRESET_TEAM_4 = RuleClick(roi_front=(195,595,465,35), roi_back=(195,595,465,35), name="preset_team_4")
 	# 预设组1 
-	C_PRESET_GROUP_1 = RuleClick(roi_front=(28,238,134,56), roi_back=(28,238,134,56), name="preset_group_1")
+	C_PRESET_GROUP_1 = RuleClick(roi_front=(35,240,25,50), roi_back=(35,240,25,50), name="preset_group_1")
 	# 预设组2 
-	C_PRESET_GROUP_2 = RuleClick(roi_front=(31,298,132,60), roi_back=(31,298,132,60), name="preset_group_2")
+	C_PRESET_GROUP_2 = RuleClick(roi_front=(35,305,25,50), roi_back=(35,305,25,50), name="preset_group_2")
 	# 预设组3 
-	C_PRESET_GROUP_3 = RuleClick(roi_front=(31,362,135,59), roi_back=(31,362,135,59), name="preset_group_3")
+	C_PRESET_GROUP_3 = RuleClick(roi_front=(35,365,25,50), roi_back=(35,365,25,50), name="preset_group_3")
 	# 预设组4 
-	C_PRESET_GROUP_4 = RuleClick(roi_front=(29,427,133,57), roi_back=(29,427,133,57), name="preset_group_4")
+	C_PRESET_GROUP_4 = RuleClick(roi_front=(35,430,25,50), roi_back=(35,430,25,50), name="preset_group_4")
 	# 预设组5 
-	C_PRESET_GROUP_5 = RuleClick(roi_front=(31,489,133,60), roi_back=(31,489,133,60), name="preset_group_5")
+	C_PRESET_GROUP_5 = RuleClick(roi_front=(35,495,25,50), roi_back=(35,495,25,50), name="preset_group_5")
 	# 预设组6 
-	C_PRESET_GROUP_6 = RuleClick(roi_front=(31,549,132,63), roi_back=(31,549,132,63), name="preset_group_6")
+	C_PRESET_GROUP_6 = RuleClick(roi_front=(35,555,25,50), roi_back=(35,555,25,50), name="preset_group_6")
 	# 预设组7 
-	C_PRESET_GROUP_7 = RuleClick(roi_front=(29,615,137,63), roi_back=(29,615,137,63), name="preset_group_7")
+	C_PRESET_GROUP_7 = RuleClick(roi_front=(35,615,25,50), roi_back=(35,615,25,50), name="preset_group_7")
 	# 从左开始第一个绿标 
 	C_GREEN_LEFT_1 = RuleClick(roi_front=(128,433,90,150), roi_back=(128,433,90,150), name="green_left_1")
 	# 从左开始第二个绿标 
@@ -60,6 +60,8 @@ class GeneralBattleAssets:
 	C_GREEN_LEFT_5 = RuleClick(roi_front=(1059,416,85,145), roi_back=(1059,416,85,145), name="green_left_5")
 	# 绿标阴阳师 
 	C_GREEN_MAIN = RuleClick(roi_front=(590,454,88,178), roi_back=(590,454,88,178), name="green_main")
+	# 绿标点击 区域,默认为全屏,需要在代码中更新其区域 
+	C_GREEN_MARK_AREA = RuleClick(roi_front=(0,0,1280,720), roi_back=(0,0,1280,720), name="green_mark_area")
 	# 战斗的时候有一定的概率随机点击 
 	C_RANDOM_CLICK = RuleClick(roi_front=(104,79,1050,507), roi_back=(255,65,100,100), name="random_click")
 
@@ -113,6 +115,12 @@ class GeneralBattleAssets:
 	I_PRESENT_LESS_THAN_5 = RuleImage(roi_front=(222,648,418,43), roi_back=(222,648,418,43), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/gb/gb_present_less_than_5.png")
 	# 封魔的金币 
 	I_DE_GOLD = RuleImage(roi_front=(61,52,30,25), roi_back=(45,33,65,64), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/gb/gb_de_gold.png")
+	# 绿标 
+	I_GREEN_MARKER = RuleImage(roi_front=(0,0,1280,720), roi_back=(0,0,1280,720), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/gb/gb_green_marker.png")
+	# 绿标-左上角部分 
+	I_GREEN_MARKER_LEFT_TOP = RuleImage(roi_front=(0,0,1280,720), roi_back=(0,0,1280,720), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/gb/gb_green_marker_left_top.png")
+	# 绿标-下半部分 
+	I_GREEN_MARKER_BOTTOM = RuleImage(roi_front=(0,0,1280,720), roi_back=(0,0,1280,720), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/gb/gb_green_marker_bottom.png")
 
 
 	# Image Rule Assets
@@ -123,6 +131,8 @@ class GeneralBattleAssets:
 	# Ocr Rule Assets
 	# 准备 
 	O_BATTLE_PREPARE = RuleOcr(roi=(1122,546,92,51), area=(1122,546,92,51), mode="Single", method="Default", keyword="准备", name="battle_prepare")
+	# 预设,部分场景预设按钮上的文字为'预设'+数字,导致点击preset失败 
+	O_PRESET = RuleOcr(roi=(20,620,60,80), area=(20,620,60,80), mode="Single", method="Default", keyword="预", name="preset")
 
 
 	# Swipe Rule Assets

+ 114 - 108
tasks/Component/GeneralBattle/gb/click.json

@@ -1,110 +1,116 @@
 [
-    {
-        "itemName": "preset_team_1",
-        "roiFront": "196,234,464,114",
-        "roiBack": "196,234,464,114",
-        "description": "预设队伍1"
-    },
-    {
-        "itemName": "preset_team_2",
-        "roiFront": "197,358,465,103",
-        "roiBack": "197,358,465,103",
-        "description": "预设队伍2"
-    },
-    {
-        "itemName": "preset_team_3",
-        "roiFront": "195,480,462,100",
-        "roiBack": "195,480,462,100",
-        "description": "预设队伍3"
-    },
-    {
-        "itemName": "preset_team_4",
-        "roiFront": "193,596,464,35",
-        "roiBack": "193,596,464,35",
-        "description": "预设队伍4"
-    },
-    {
-        "itemName": "preset_group_1",
-        "roiFront": "28,238,134,56",
-        "roiBack": "28,238,134,56",
-        "description": "预设组1"
-    },
-    {
-        "itemName": "preset_group_2",
-        "roiFront": "31,298,132,60",
-        "roiBack": "31,298,132,60",
-        "description": "预设组2"
-    },
-    {
-        "itemName": "preset_group_3",
-        "roiFront": "31,362,135,59",
-        "roiBack": "31,362,135,59",
-        "description": "预设组3"
-    },
-    {
-        "itemName": "preset_group_4",
-        "roiFront": "29,427,133,57",
-        "roiBack": "29,427,133,57",
-        "description": "预设组4"
-    },
-    {
-        "itemName": "preset_group_5",
-        "roiFront": "31,489,133,60",
-        "roiBack": "31,489,133,60",
-        "description": "预设组5"
-    },
-    {
-        "itemName": "preset_group_6",
-        "roiFront": "31,549,132,63",
-        "roiBack": "31,549,132,63",
-        "description": "预设组6"
-    },
-    {
-        "itemName": "preset_group_7",
-        "roiFront": "29,615,137,63",
-        "roiBack": "29,615,137,63",
-        "description": "预设组7"
-    },
-    {
-        "itemName": "green_left_1",
-        "roiFront": "128,433,90,150",
-        "roiBack": "128,433,90,150",
-        "description": "从左开始第一个绿标"
-    },
-    {
-        "itemName": "green_left_2",
-        "roiFront": "371,385,81,145",
-        "roiBack": "371,385,81,145",
-        "description": "从左开始第二个绿标"
-    },
-    {
-        "itemName": "green_left_3",
-        "roiFront": "586,328,100,76",
-        "roiBack": "586,328,100,76",
-        "description": "从左开始第三个绿标"
-    },
-    {
-        "itemName": "green_left_4",
-        "roiFront": "817,379,77,133",
-        "roiBack": "817,379,77,133",
-        "description": "从左开始第四个绿标"
-    },
-    {
-        "itemName": "green_left_5",
-        "roiFront": "1059,416,85,145",
-        "roiBack": "1059,416,85,145",
-        "description": "从左开始第五个绿标"
-    },
-    {
-        "itemName": "green_main",
-        "roiFront": "590,454,88,178",
-        "roiBack": "590,454,88,178",
-        "description": "绿标阴阳师"
-    },
-    {
-        "itemName": "random_click",
-        "roiFront": "104,79,1050,507",
-        "roiBack": "255,65,100,100",
-        "description": "战斗的时候有一定的概率随机点击"
-    }
+  {
+    "itemName": "preset_team_1",
+    "roiFront": "195,235,465,110",
+    "roiBack": "195,235,465,110",
+    "description": "预设队伍1"
+  },
+  {
+    "itemName": "preset_team_2",
+    "roiFront": "195,355,465,110",
+    "roiBack": "195,355,465,110",
+    "description": "预设队伍2"
+  },
+  {
+    "itemName": "preset_team_3",
+    "roiFront": "195,475,465,110",
+    "roiBack": "195,475,465,110",
+    "description": "预设队伍3"
+  },
+  {
+    "itemName": "preset_team_4",
+    "roiFront": "195,595,465,35",
+    "roiBack": "195,595,465,35",
+    "description": "预设队伍4"
+  },
+  {
+    "itemName": "preset_group_1",
+    "roiFront": "35,240,25,50",
+    "roiBack": "35,240,25,50",
+    "description": "预设组1"
+  },
+  {
+    "itemName": "preset_group_2",
+    "roiFront": "35,305,25,50",
+    "roiBack": "35,305,25,50",
+    "description": "预设组2"
+  },
+  {
+    "itemName": "preset_group_3",
+    "roiFront": "35,365,25,50",
+    "roiBack": "35,365,25,50",
+    "description": "预设组3"
+  },
+  {
+    "itemName": "preset_group_4",
+    "roiFront": "35,430,25,50",
+    "roiBack": "35,430,25,50",
+    "description": "预设组4"
+  },
+  {
+    "itemName": "preset_group_5",
+    "roiFront": "35,495,25,50",
+    "roiBack": "35,495,25,50",
+    "description": "预设组5"
+  },
+  {
+    "itemName": "preset_group_6",
+    "roiFront": "35,555,25,50",
+    "roiBack": "35,555,25,50",
+    "description": "预设组6"
+  },
+  {
+    "itemName": "preset_group_7",
+    "roiFront": "35,615,25,50",
+    "roiBack": "35,615,25,50",
+    "description": "预设组7"
+  },
+  {
+    "itemName": "green_left_1",
+    "roiFront": "128,433,90,150",
+    "roiBack": "128,433,90,150",
+    "description": "从左开始第一个绿标"
+  },
+  {
+    "itemName": "green_left_2",
+    "roiFront": "371,385,81,145",
+    "roiBack": "371,385,81,145",
+    "description": "从左开始第二个绿标"
+  },
+  {
+    "itemName": "green_left_3",
+    "roiFront": "586,328,100,76",
+    "roiBack": "586,328,100,76",
+    "description": "从左开始第三个绿标"
+  },
+  {
+    "itemName": "green_left_4",
+    "roiFront": "817,379,77,133",
+    "roiBack": "817,379,77,133",
+    "description": "从左开始第四个绿标"
+  },
+  {
+    "itemName": "green_left_5",
+    "roiFront": "1059,416,85,145",
+    "roiBack": "1059,416,85,145",
+    "description": "从左开始第五个绿标"
+  },
+  {
+    "itemName": "green_main",
+    "roiFront": "590,454,88,178",
+    "roiBack": "590,454,88,178",
+    "description": "绿标阴阳师"
+  },
+  {
+    "itemName": "green_mark_area",
+    "roiFront": "0,0,1280,720",
+    "roiBack": "0,0,1280,720",
+    "description": "绿标点击 区域,默认为全屏,需要在代码中更新其区域"
+  },
+  {
+    "itemName": "random_click",
+    "roiFront": "104,79,1050,507",
+    "roiBack": "255,65,100,100",
+    "description": "战斗的时候有一定的概率随机点击"
+  }
 ]

BIN
tasks/Component/GeneralBattle/gb/gb_green_marker.png


BIN
tasks/Component/GeneralBattle/gb/gb_green_marker_bottom.png


BIN
tasks/Component/GeneralBattle/gb/gb_green_marker_left_top.png


+ 27 - 0
tasks/Component/GeneralBattle/gb/image.json

@@ -214,5 +214,32 @@
     "method": "Template matching",
     "threshold": 0.8,
     "description": "封魔的金币"
+  },
+  {
+    "itemName": "green_marker",
+    "imageName": "gb_green_marker.png",
+    "roiFront": "0,0,1280,720",
+    "roiBack": "0,0,1280,720",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "绿标"
+  },
+  {
+    "itemName": "green_marker_left_top",
+    "imageName": "gb_green_marker_left_top.png",
+    "roiFront": "0,0,1280,720",
+    "roiBack": "0,0,1280,720",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "绿标-左上角部分"
+  },
+  {
+    "itemName": "green_marker_bottom",
+    "imageName": "gb_green_marker_bottom.png",
+    "roiFront": "0,0,1280,720",
+    "roiBack": "0,0,1280,720",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "绿标-下半部分"
   }
 ]

+ 9 - 0
tasks/Component/GeneralBattle/gb/ocr.json

@@ -7,5 +7,14 @@
     "method": "Default",
     "keyword": "准备",
     "description": "准备"
+  },
+  {
+    "itemName": "preset",
+    "roiFront": "20,620,60,80",
+    "roiBack":  "20,620,60,80",
+    "mode": "Single",
+    "method": "Default",
+    "keyword": "预",
+    "description": "预设,部分场景预设按钮上的文字为'预设'+数字,导致点击preset失败"
   }
 ]

+ 101 - 35
tasks/Component/GeneralBattle/general_battle.py

@@ -3,7 +3,11 @@
 # github https://github.com/runhey
 import time
 import random
+from time import sleep
 
+import cv2
+
+from module.base.utils import get_color, color_similar
 from tasks.base_task import BaseTask
 from tasks.Component.GeneralBattle.config_general_battle import GreenMarkType, GeneralBattleConfig
 from tasks.Component.GeneralBattle.assets import GeneralBattleAssets
@@ -293,54 +297,80 @@ class GeneralBattle(GeneralBuff, GeneralBattleAssets):
                 break
             if self.appear_then_click(self.I_PRESET, threshold=0.8, interval=1):
                 continue
+            if self.ocr_appear(self.O_PRESET):
+                self.click(self.O_PRESET, interval=1)
+                continue
         logger.info("Click preset button")
 
+        def get_unselect_color(tmp1, tmp2, tmp3, size):
+            # 获取未选择分组的颜色,3组之中必定存在两个颜色相似
+            # area 参数格式是(x1,y1,x2,y2)
+            color_1 = get_color(self.device.image,
+                                (tmp1.roi_back[0], tmp1.roi_back[1],
+                                 tmp1.roi_back[0] + size[0], tmp1.roi_back[1] + size[1]))
+            color_2 = get_color(self.device.image,
+                                (tmp2.roi_back[0], tmp2.roi_back[1],
+                                 tmp2.roi_back[0] + size[0], tmp2.roi_back[1] + size[1]))
+            color_3 = get_color(self.device.image,
+                                (tmp3.roi_back[0], tmp3.roi_back[1],
+                                 tmp3.roi_back[0] + size[0], tmp3.roi_back[1] + size[1]))
+
+            if color_similar(color_1, color_2):
+                return color_1
+            if color_similar(color_2, color_3):
+                return color_2
+            return color_3
+
         # 选择预设组
-        x, y = None, None
-        match preset_group:
-            case 1:
-                x, y = self.C_PRESET_GROUP_1.coord()
-            case 2:
-                x, y = self.C_PRESET_GROUP_2.coord()
-            case 3:
-                x, y = self.C_PRESET_GROUP_3.coord()
-            case 4:
-                x, y = self.C_PRESET_GROUP_4.coord()
-            case 5:
-                x, y = self.C_PRESET_GROUP_5.coord()
-            case 6:
-                x, y = self.C_PRESET_GROUP_6.coord()
-            case 7:
-                x, y = self.C_PRESET_GROUP_7.coord()
-            case _:
-                x, y = self.C_PRESET_GROUP_1.coord()
-        self.device.click(x, y)
+        tmp = self.__getattribute__("C_PRESET_GROUP_" + str(preset_group))
+        if tmp is None:
+            tmp = self.C_PRESET_GROUP_1
+        color_size = [self.C_PRESET_GROUP_1.roi_back[2],
+                      self.C_PRESET_GROUP_1.roi_back[3]]
+        # unselected_color = get_unselect_color(self.C_PRESET_GROUP_1, self.C_PRESET_GROUP_2, self.C_PRESET_GROUP_3, size=color_size)
+        # 考虑到有些预设组没有预设,所以这里取一个比较固定的颜色
+        unselected_color = (224.9, 208.3, 187.4)
+        while True:
+            self.screenshot()
+            color_tmp = get_color(self.device.image,
+                                  (tmp.roi_back[0], tmp.roi_back[1], tmp.roi_back[0] + color_size[0],
+                                   tmp.roi_back[1] + color_size[1]))
+            if color_similar(color_tmp, unselected_color):
+                self.click(tmp, interval=0.2)
+                continue
+            break
+
         logger.info("Select preset group")
 
         # 选择预设的队伍
         time.sleep(0.5)
-        match preset_team:
-            case 1:
-                x, y = self.C_PRESET_TEAM_1.coord()
-            case 2:
-                x, y = self.C_PRESET_TEAM_2.coord()
-            case 3:
-                x, y = self.C_PRESET_TEAM_3.coord()
-            case 4:
-                x, y = self.C_PRESET_TEAM_4.coord()
-            case _:
-                x, y = self.C_PRESET_TEAM_1.coord()
-        self.device.click(x, y)
+        tmp = self.__getattribute__("C_PRESET_TEAM_" + str(preset_team))
+        if tmp is None:
+            tmp = self.C_PRESET_TEAM_1
+        color_size = [5, 5]
+        # unselected_color = get_unselect_color(self.C_PRESET_TEAM_1, self.C_PRESET_TEAM_2, self.C_PRESET_TEAM_3, size=color_size )
+        unselected_color = (216.8, 185.0, 146.8)
+        while True:
+            self.screenshot()
+            color_tmp = get_color(self.device.image,
+                                  (tmp.roi_back[0], tmp.roi_back[1], tmp.roi_back[0] + color_size[0],
+                                   tmp.roi_back[1] + color_size[1]))
+            if color_similar(color_tmp, unselected_color):
+                self.click(tmp, interval=0.2)
+                continue
+            break
+
+        self.click(tmp)
         logger.info("Select preset team")
 
         # 点击预设确认
         self.wait_until_appear(self.I_PRESET_ENSURE, wait_time=1)
         while 1:
             self.screenshot()
-            if self.appear_then_click(self.I_PRESET_ENSURE, threshold=0.8):
-                continue
             if not self.appear(self.I_PRESET_ENSURE):
                 break
+            if self.appear_then_click(self.I_PRESET_ENSURE, threshold=0.8, interval=0.2):
+                continue
         logger.info("Click preset ensure")
 
     def random_click_swipt(self):
@@ -488,5 +518,41 @@ if __name__ == '__main__':
     c = Config('oas1')
     d = Device(c)
     t = GeneralBattle(c, d)
-
-    t.check_buff([BuffClass.EXP_50, BuffClass.GOLD_50])
+    self = t
+    # t.check_buff([BuffClass.EXP_50, BuffClass.GOLD_50])
+
+    img = cv2.imread(r"E:\preset3.png")
+    img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
+    self.device.image = img
+
+
+    def get_unselect_color(tmp1, tmp2, tmp3, size):
+        # 获取未选择分组的颜色,3组之中必定存在两个颜色相似
+        # area 参数格式是(x1,y1,x2,y2)
+        color_1 = get_color(self.device.image,
+                            (tmp1.roi_back[0], tmp1.roi_back[1],
+                             tmp1.roi_back[0] + size[0], tmp1.roi_back[1] + size[1]))
+        color_2 = get_color(self.device.image,
+                            (tmp2.roi_back[0], tmp2.roi_back[1],
+                             tmp2.roi_back[0] + size[0], tmp2.roi_back[1] + size[1]))
+        color_3 = get_color(self.device.image,
+                            (tmp3.roi_back[0], tmp3.roi_back[1],
+                             tmp3.roi_back[0] + size[0], tmp3.roi_back[1] + size[1]))
+
+        if color_similar(color_1, color_2):
+            return color_1
+        if color_similar(color_2, color_3):
+            return color_2
+        return color_3
+
+
+    color_size = [self.C_PRESET_GROUP_1.roi_back[2],
+                  self.C_PRESET_GROUP_1.roi_back[3]]
+    unselected_color = get_unselect_color(self.C_PRESET_GROUP_1, self.C_PRESET_GROUP_2, self.C_PRESET_GROUP_3,
+                                          size=color_size)
+    print("")
+    color_size = [5, 5]
+    unselected_color = get_unselect_color(self.C_PRESET_TEAM_1, self.C_PRESET_TEAM_2, self.C_PRESET_TEAM_3,
+                                          size=color_size
+                                          )
+    print("")

+ 0 - 0
tasks/Component/GeneralInvite/gi/gi_in_room.png → tasks/Component/GeneralInvite/gi/gi_gi_in_room.png


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

@@ -167,7 +167,7 @@ class LoginAccount(BaseTask, SwitchAccountAssets):
                 self.screenshot()
                 if self.appear(self.I_SA_ACCOUNT_DROP_DOWN_CLOSED):
                     if self.ocr_appear(self.O_SA_ACCOUNT_ACCOUNT_SELECTED):
-                        break
+                        return True
                     self.ui_click_until_disappear(self.I_SA_ACCOUNT_DROP_DOWN_CLOSED,
                                                   interval=1.5)
                     continue
@@ -253,7 +253,7 @@ class LoginAccount(BaseTask, SwitchAccountAssets):
 
             # 处于选择 苹果安卓界面
             if self.appear(self.I_SA_LOGIN_FORM_APPLE):
-                btn = self.I_SA_LOGIN_FORM_ANDROID if accountInfo.appleOrAndroid else self.I_SA_LOGIN_FORM_APPLE
+                btn = self.I_SA_LOGIN_FORM_ANDROID if accountInfo.apple_or_android else self.I_SA_LOGIN_FORM_APPLE
                 self.ui_click_until_disappear(btn)
                 isAccountLogon = True
                 continue
@@ -313,12 +313,12 @@ class LoginAccount(BaseTask, SwitchAccountAssets):
             # self.ui_click_until_disappear(self.C_SA_LOGIN_FORM_ENTER_GAME_BTN, stop=self.I_CHECK_LOGIN_FORM)
             logger.info("character %s-%s account:%s %s login Success", accountInfo.character, accountInfo.svr,
                         accountInfo.account,
-                        'Android' if accountInfo.appleOrAndroid else 'Apple')
+                        'Android' if accountInfo.apple_or_android else 'Apple')
             return True
 
         logger.error("character %s-%s account:%s %s login Failed", accountInfo.character, accountInfo.svr,
                      accountInfo.account,
-                     'Android' if accountInfo.appleOrAndroid else 'Apple')
+                     'Android' if accountInfo.apple_or_android else 'Apple')
         return False
 
     def ui_click_until_disappear(self, click, interval: float = 1, stop: RuleImage | RuleGif = None):

+ 7 - 7
tasks/Component/SwitchAccount/switch_account.py

@@ -29,11 +29,11 @@ class SwitchAccount(LoginAccount, ExitGame, GameUi, SwitchAccountAssets):
         @type frm:
         """
         super().__init__(config, device)
-        self.toAccountInfo = to
-        self.fromAccountInfo = frm
+        self.to_account_info = to
+        self.from_account_info = frm
 
     def switchAccount(self):
-        logger.info("start switchAccount %s-%s", self.toAccountInfo.character, self.toAccountInfo.svr)
+        logger.info("start switchAccount %s-%s", self.to_account_info.character, self.to_account_info.svr)
         # 判断所处界面
         curPage = self.ui_get_current_page()
 
@@ -44,12 +44,12 @@ class SwitchAccount(LoginAccount, ExitGame, GameUi, SwitchAccountAssets):
             self.exitGame()
 
         # 处于登录界面
-        if not self.login(self.toAccountInfo):
+        if not self.login(self.to_account_info):
             return False
-        logger.info("%s login suc", self.toAccountInfo.character)
+        logger.info("%s login suc", self.to_account_info.character)
         # 处理位于登录界面各种奇葩弹窗
         login_handler = LoginHandler(config=self.config, device=self.device)
-        login_handler.set_specific_usr(self.toAccountInfo.svr)
+        login_handler.set_specific_usr(self.to_account_info.svr)
         login_handler.app_handle_login()
 
         return True
@@ -58,6 +58,6 @@ class SwitchAccount(LoginAccount, ExitGame, GameUi, SwitchAccountAssets):
 if __name__ == '__main__':
     config = Config('oas1')
     device=Device()
-    toAccount=AccountInfo(account="email0@163.com",accountAlias="emailO#emailo",appleOrAndroid=True,character="粘贴",svr="立秋夕烛")
+    toAccount=AccountInfo(account="email0@163.com", account_alias="emailO#emailo", apple_or_android=True, character="粘贴", svr="立秋夕烛")
     sa=SwitchAccount(config,device,toAccount)
     sa.switchAccount()

+ 10 - 6
tasks/Component/SwitchAccount/switch_account_config.py

@@ -1,6 +1,7 @@
-from datetime import datetime
 from pydantic import Field, BaseModel
 
+from tasks.Component.config_base import DateTime
+
 
 class AccountInfo(BaseModel):
     """
@@ -15,18 +16,18 @@ class AccountInfo(BaseModel):
     svr: str = Field(default="", description="svr_help")
     account: str = Field(default="", description="account_help")
     # 为防止ocr出错 暂定格式 字符串以#分割
-    accountAlias: str = Field(default="", description="")
-    appleOrAndroid: bool = Field(default=True, description="apple_or_android_help")
+    account_alias: str = Field(default="", description="account_alias_help")
+    apple_or_android: bool = Field(default=True, description="apple_or_android_help")
     # 上一次执行成功的时间 ,防止出错时重复登录浪费时间
-    last_complete_time: datetime = Field(default=datetime(1970, 1, 1, 1, 1, 1), description="last_complete_time_help")
+    last_complete_time: DateTime = Field(default=DateTime.fromisoformat("2023-01-01 00:00:00"), description="last_complete_time_help")
 
     def is_account_alias(self, ocr_account):
         tmp_account = AccountInfo.preprocessAccount(self.account)
         if ocr_account == self.account or ocr_account.startswith(tmp_account):
             return True
-        if not self.accountAlias:
+        if not self.account_alias:
             return False
-        _accountAliasList = self.accountAlias.split('#')
+        _accountAliasList = self.account_alias.split('#')
         for alias in _accountAliasList:
             if ocr_account.startswith(alias):
                 return True
@@ -43,3 +44,6 @@ class AccountInfo(BaseModel):
         @rtype:
         """
         return account.split('@')[0]
+
+    def is_valid(self):
+        return self.character!="" and self.character is not None

+ 53 - 75
tasks/Component/config_base.py

@@ -1,13 +1,15 @@
 # This Python file uses the following encoding: utf-8
 # @author runhey
 # github https://github.com/runhey
-from typing import Any
-from collections.abc import Callable, Generator
+import re
 from datetime import timedelta, time, datetime
+from typing import Any
 
-from pydantic import BaseModel, datetime_parse
-from pydantic.fields import ModelField
-
+from pydantic import BaseModel
+from pydantic import (BeforeValidator,
+                      PlainSerializer,
+                      WithJsonSchema)
+from typing_extensions import Annotated
 
 
 def format_timedelta(tdelta: timedelta):
@@ -16,76 +18,52 @@ def format_timedelta(tdelta: timedelta):
     minutes, seconds = divmod(rem, 60)
     return f"{days:02d} {hours:02d}:{minutes:02d}:{seconds:02d}"
 
-
-class MultiLine(str):
-    # @classmethod
-    # def __get_validators__(cls) -> Generator[Callable, None, None]:
-    #     yield cls.validate
-    #
-    # @classmethod
-    # def validate(cls, value: str, field: ModelField):
-    #     return cls(value)
-
-    @classmethod
-    def __modify_schema__(
-        cls, field_schema: dict[str, Any], field: ModelField | None
-    ):
-        if field:
-            field_schema['type'] = 'multi_line'
-
-class TimeDelta(timedelta):
-    def __str__(self):
-        return format_timedelta(self)
-
-    def __repr__(self):
-        return format_timedelta(self)
-
-    @classmethod
-    def __modify_schema__(
-            cls, field_schema: dict[str, Any], field: ModelField | None
-    ):
-        if field:
-            field_schema['type'] = 'time_delta'
-
-class DateTime(datetime):
-    @classmethod
-    def __modify_schema__(
-            cls, field_schema: dict[str, Any], field: ModelField | None
-    ):
-        if field:
-            field_schema['type'] = 'date_time'
-
-
-class Time(time):
-    """
-    尝试将字符串转换为time对象, 但是不生效
-    """
-    @classmethod
-    def __get_validators__(cls):
-        yield cls.validate
-
-    @classmethod
-    def validate(cls, value):
-        # print(f' Time validate: {value} type: {type(value)}')
-        if isinstance(value, str):
-            hour, minute, second = map(int, value.split(":"))
-            return cls(hour, minute, second)
-        elif isinstance(value, time):
-            return value
-        else:
-            raise ValueError("Invalid time format")
-
-    @classmethod
-    def __modify_schema__(
-            cls, field_schema: dict[str, Any], field: ModelField | None
-    ):
-        if field:
-            field_schema['type'] = 'time'
+def datadelta_validator(v: Any) -> timedelta:
+    if isinstance(v, str):
+        try:
+            pattern = r'(\d{1,2})\s+(\d{1,2}):(\d{1,2}):(\d{1,2})'
+            match = re.match(pattern, v)
+            if match:
+                days = int(match.group(1))
+                hours = int(match.group(2))
+                minutes = int(match.group(3))
+                seconds = int(match.group(4))
+                return TimeDelta(days=days, hours=hours, minutes=minutes, seconds=seconds)
+            return TimeDelta(days=1, hours=0, minutes=0, seconds=0)
+        except ValueError:
+            raise ValueError('Invalid interval value. Expected format: seconds')
+    return v
+
+def datetime_validator(v: Any) -> datetime:
+    if isinstance(v, str):
+        return datetime.fromisoformat(v)
+    return v
+
+def time_validator(v: Any) -> time:
+    if isinstance(v, str):
+        return time.fromisoformat(v)
+    return v
+
+
+MultiLine = Annotated[str,
+                      WithJsonSchema({'type': 'multi_line'}),]
+
+
+TimeDelta = Annotated[timedelta,
+                      BeforeValidator(datadelta_validator),
+                      PlainSerializer(format_timedelta, return_type=str),
+                      WithJsonSchema({'type': 'time_delta'}),]
+
+DateTime = Annotated[datetime,
+                     BeforeValidator(datetime_validator),
+                     PlainSerializer(lambda v: v.strftime('%Y-%m-%d %H:%M:%S'), return_type=str),
+                     WithJsonSchema({'type': 'date_time'}),]
+
+Time = Annotated[time,
+                 BeforeValidator(time_validator),
+                 PlainSerializer(lambda v: v.strftime('%H:%M:%S'), return_type=str),
+                 WithJsonSchema({'type': 'time'}),]
 
 # ---------------------------------------------------------------------------------------------------------------------
 class ConfigBase(BaseModel):
-    # 这个是导出json时候的配置,但是新的是导出dict,所以的无效
-    class Config:
-        json_encoders = {
-            TimeDelta: format_timedelta
-        }
+    pass

+ 14 - 36
tasks/Component/config_scheduler.py

@@ -1,16 +1,13 @@
 # This Python file uses the following encoding: utf-8
 # @author runhey
 # github https://github.com/runhey
-import re
-from enum import Enum
-from datetime import datetime, timedelta, time
-from pydantic import BaseModel, ValidationError, validator, Field
+from pydantic import Field
 
 from tasks.Component.config_base import ConfigBase, TimeDelta, DateTime, Time
 
 class Scheduler(ConfigBase):
     enable: bool = Field(default=False, description='enable_help')
-    next_run: DateTime = Field(default="2023-01-01 00:00:00", description='next_run_help')
+    next_run: DateTime = Field(default=DateTime.fromisoformat("2023-01-01 00:00:00"), description='next_run_help')
     priority: int = Field(default=5, description='priority_help')
 
     success_interval: TimeDelta = Field(default=TimeDelta(days=1), description='success_interval_help')
@@ -19,38 +16,19 @@ class Scheduler(ConfigBase):
     delay_date: int = Field(default=1, description='delay_date_help', ge=1, le=31)
     float_time: Time = Field(default=Time(hour=0, minute=0, second=0), description='float_time_help')
 
-    @validator('next_run', pre=True, always=True)
-    def parse_next_run(cls, value):
-        if isinstance(value, str):
-            try:
-                return datetime.fromisoformat(value)
-            except ValueError:
-                raise ValueError('Invalid next_run value. Expected format: YYYY-MM-DD HH:MM:SS')
-        return value
-
-    @validator('success_interval', 'failure_interval', pre=True)
-    def parse_interval(cls, value):
-        if isinstance(value, str):
-            try:
-                pattern = r'(\d{1,2})\s+(\d{1,2}):(\d{1,2}):(\d{1,2})'
-                match = re.match(pattern, value)
-                if match:
-                    days = int(match.group(1))
-                    hours = int(match.group(2))
-                    minutes = int(match.group(3))
-                    seconds = int(match.group(4))
-                    return TimeDelta(days=days, hours=hours, minutes=minutes, seconds=seconds)
-                return TimeDelta(days=1, hours=0, minutes=0, seconds=0)
-            except ValueError:
-                raise ValueError('Invalid interval value. Expected format: seconds')
-        return value
-
 
 if __name__ == "__main__":
-    s = Scheduler(success_interval='00 00:00:10')
-    if isinstance(s.success_interval, TimeDelta):
-        print(s.success_interval.seconds)
-    print(s.json())
-    print(s.dict())
+    dict_s = {
+        "enable": False,
+        "next_run": "2026-07-19T14:15:37",
+        "priority": 5,
+        "success_interval": "10 00:00:01",
+        "failure_interval": "10 00:00:01",
+        "server_update": "09:03:00",
+        "float_time": "02:00:05"
+    }
+    s = Scheduler(**dict_s)
+    print(s.model_dump())
+
 
 

+ 11 - 0
tasks/DailyTrifles/assets.py

@@ -25,6 +25,8 @@ class DailyTriflesAssets:
 	I_CLICK_BLESS = RuleImage(roi_front=(617,442,92,39), roi_back=(617,442,92,39), threshold=0.8, method="Template matching", file="./tasks/DailyTrifles/love/Screenshots_click_bless.png")
 	# 吉闻页 
 	I_LUCK_TITLE = RuleImage(roi_front=(600,52,131,67), roi_back=(600,52,131,67), threshold=0.8, method="Template matching", file="./tasks/DailyTrifles/love/Screenshots_luck_title.png")
+	# 好友羁绊提升弹窗 
+	I_FRIENDSHIP_UP = RuleImage(roi_front=(1147,80,27,28), roi_back=(1147,80,27,28), threshold=0.8, method="Template matching", file="./tasks/DailyTrifles/love/friendship_up.png")
 
 
 	# Image Rule Assets
@@ -34,5 +36,14 @@ class DailyTriflesAssets:
 	I_GIFT_RECOMMEND = RuleImage(roi_front=(1186,98,53,64), roi_back=(1172,83,83,306), threshold=0.8, method="Template matching", file="./tasks/DailyTrifles/store/store_gift_recommend.png")
 	# 免费一抽 
 	I_GIFT_SIGN = RuleImage(roi_front=(236,129,306,218), roi_back=(236,129,306,218), threshold=0.8, method="Template matching", file="./tasks/DailyTrifles/store/store_gift_sign.png")
+	# 体力 
+	I_SPECIAL_SUSHI = RuleImage(roi_front=(180,130,800,200), roi_back=(180,130,800,200), threshold=0.8, method="Template matching", file="./tasks/DailyTrifles/store/store_sushi.png")
+	# 购买时货币类型为勾玉 
+	I_STORE_COST_TYPE_JADE = RuleImage(roi_front=(600,490,50,60), roi_back=(600,490,50,60), threshold=0.8, method="Template matching", file="./tasks/DailyTrifles/store/store_cost_type_jade.png")
+
+
+	# Ocr Rule Assets
+	# 商店Special购买体力所需勾玉数量,roiBack为动态调整,故此设置为0,0,0,0 
+	O_STORE_SUSHI_PRICE = RuleOcr(roi=(0,0,0,0), area=(0,0,0,0), mode="Digit", method="Default", keyword="", name="store_sushi_price")
 
 

+ 2 - 1
tasks/DailyTrifles/config.py

@@ -14,9 +14,10 @@ class DailyTriflesConfig(BaseModel):
     friend_love: bool = Field(title='Friend Love', default=False)
     luck_msg: bool = Field(title='Luck Msg', default=False)
     store_sign: bool = Field(title='Store Sign', default=False, description='store_sign_help')
+    # 每天购买体力数量
+    buy_sushi_count: int = Field(title='Buy Sushi Count', default=-1)
 
 
 class DailyTrifles(ConfigBase):
     scheduler: Scheduler = Field(default_factory=Scheduler)
     trifles_config: DailyTriflesConfig = Field(default_factory=DailyTriflesConfig)
-

BIN
tasks/DailyTrifles/love/friendship_up.png


+ 9 - 0
tasks/DailyTrifles/love/image.json

@@ -61,5 +61,14 @@
     "method": "Template matching",
     "threshold": 0.8,
     "description": "吉闻页"
+  },
+  {
+    "itemName": "friendship_up",
+    "imageName": "friendship_up.png",
+    "roiFront": "1147,80,27,28",
+    "roiBack": "1147,80,27,28",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "好友羁绊提升弹窗"
   }
 ]

+ 81 - 13
tasks/DailyTrifles/script_task.py

@@ -1,22 +1,24 @@
 # This Python file uses the following encoding: utf-8
 # @author runhey
 # github https://github.com/runhey
+import copy
 from time import sleep
 from datetime import time, datetime, timedelta
 
+from exceptiongroup import catch
+from winerror import NOERROR
+
 from tasks.GameUi.game_ui import GameUi
 from tasks.GameUi.page import page_main, page_summon, page_guild, page_mall, page_friends
 from tasks.DailyTrifles.config import DailyTriflesConfig
 from tasks.DailyTrifles.assets import DailyTriflesAssets
 from tasks.Component.Summon.summon import Summon
 
-
 from module.logger import logger
 from module.exception import TaskEnd
 from module.base.timer import Timer
 
 
-
 class ScriptTask(GameUi, Summon, DailyTriflesAssets):
 
     def run(self):
@@ -29,8 +31,8 @@ class ScriptTask(GameUi, Summon, DailyTriflesAssets):
             self.run_friend_love()
         if con.luck_msg:
             self.run_luck_msg()
-        if con.store_sign:
-            self.run_store_sign()
+        if con.store_sign or con.buy_sushi_count > 0:
+            self.run_store()
         self.set_next_run('DailyTrifles', success=True, finish=False)
         raise TaskEnd('DailyTrifles')
 
@@ -50,6 +52,8 @@ class ScriptTask(GameUi, Summon, DailyTriflesAssets):
             self.screenshot()
             if self.appear(self.I_LUCK_TITLE):
                 break
+            if self.appear_then_click(self.I_FRIENDSHIP_UP, interval=1):
+                continue
             if self.appear_then_click(self.I_LUCK_MSG, interval=1):
                 continue
         logger.info('Start luck msg')
@@ -78,6 +82,8 @@ class ScriptTask(GameUi, Summon, DailyTriflesAssets):
             self.screenshot()
             if self.appear(self.I_L_LOVE):
                 break
+            if self.appear_then_click(self.I_FRIENDSHIP_UP, interval=1):
+                continue
             if self.appear_then_click(self.I_L_FRIENDS, interval=1):
                 continue
         logger.info('Start friend love')
@@ -97,10 +103,21 @@ class ScriptTask(GameUi, Summon, DailyTriflesAssets):
 
         self.ui_click(self.I_UI_BACK_RED, self.I_CHECK_MAIN)
 
-    def run_store_sign(self):
+    def run_store(self):
         self.ui_get_current_page()
         self.ui_goto(page_mall, confirm_wait=3)
 
+        if self.config.daily_trifles.trifles_config.store_sign:
+            self.run_store_sign()
+        if self.config.daily_trifles.trifles_config.buy_sushi_count > 0:
+            self.run_buy_sushi()
+
+        self.ui_click(self.I_UI_BACK_YELLOW, self.I_CHECK_MALL)
+        self.ui_get_current_page()
+        self.ui_goto(page_main)
+
+    def run_store_sign(self):
+
         while 1:
             self.screenshot()
             if self.appear(self.I_GIFT_RECOMMEND):
@@ -114,17 +131,69 @@ class ScriptTask(GameUi, Summon, DailyTriflesAssets):
         self.screenshot()
         if not self.appear(self.I_GIFT_SIGN):
             logger.warning('There is no gift sign')
-            self.ui_click(self.I_UI_BACK_YELLOW, self.I_CHECK_MALL)
-            self.ui_get_current_page()
-            self.ui_goto(page_main)
             return
 
         if self.ui_get_reward(self.I_GIFT_SIGN, click_interval=2.5):
             logger.info('Get reward of gift sign')
 
-        self.ui_click(self.I_UI_BACK_YELLOW, self.I_CHECK_MALL)
-        self.ui_get_current_page()
-        self.ui_goto(page_main)
+    def run_buy_sushi(self):
+
+        # 进入Special
+        while 1:
+            from tasks.RichMan.assets import RichManAssets
+            self.screenshot()
+            if self.appear(RichManAssets.I_SIDE_CHECK_SPECIAL):
+                break
+            if self.appear_then_click(RichManAssets.I_MALL_SUNDRY, interval=1):
+                continue
+            if self.appear_then_click(RichManAssets.I_SIDE_SURE_SPECIAL, interval=1):
+                continue
+
+        def detect_buy_count(base_element) -> (int, int):
+            # 返回count,price
+            MAX_PRICE = 9999
+            MAX_COUNT = 9999
+            roi = copy.deepcopy(base_element.roi_front)
+            roi[0] = roi[0] + roi[2]
+            roi[1] = roi[1] + roi[3] - 30
+            roi[2] = 60
+            roi[3] = 30
+            self.O_STORE_SUSHI_PRICE.roi = roi
+            _price = self.O_STORE_SUSHI_PRICE.detect_text(self.device.image)
+            # 保守策略,避免OCR错误购买
+            try:
+                _price = int(_price)
+            except Exception as e:
+                _price = MAX_PRICE
+
+            if _price < 60:
+                return 0, MAX_PRICE
+            _count = (_price - 60) / 20
+            return _count, _price
+
+        roi = None
+        # 购买体力
+        while 1:
+            self.screenshot()
+            # count, price = detect_buy_count(roi)
+            # if count >= self.config.model.daily_trifles.trifles_config.buy_sushi_count:
+            #     break
+            if self.appear(self.I_STORE_COST_TYPE_JADE):
+                count, price = detect_buy_count(self.I_STORE_COST_TYPE_JADE)
+                if count >= self.config.daily_trifles.trifles_config.buy_sushi_count:
+                    break
+                self.ui_click_until_disappear(self.I_STORE_COST_TYPE_JADE, interval=2)
+                logger.info(f"Buy Sushi With {price} Jade")
+                continue
+
+            if self.appear(self.I_SPECIAL_SUSHI):
+                # 此处确定当前购买体力所需勾玉数量的位置,用于后续识别
+                count, price = detect_buy_count(self.I_SPECIAL_SUSHI)
+                if count >= self.config.daily_trifles.trifles_config.buy_sushi_count:
+                    break
+                self.ui_click(self.I_SPECIAL_SUSHI, stop=self.I_STORE_COST_TYPE_JADE, interval=2)
+                continue
+        return
 
 
 if __name__ == '__main__':
@@ -135,5 +204,4 @@ if __name__ == '__main__':
     d = Device(c)
     t = ScriptTask(c, d)
 
-    t.run_store_sign()
-
+    t.run_store()

+ 18 - 0
tasks/DailyTrifles/store/image.json

@@ -25,5 +25,23 @@
     "method": "Template matching",
     "threshold": 0.8,
     "description": "免费一抽"
+  },
+  {
+    "itemName": "special_sushi",
+    "imageName": "store_sushi.png",
+    "roiFront": "180,130,800,200",
+    "roiBack": "180,130,800,200",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "体力"
+  },
+  {
+    "itemName": "store_cost_type_jade",
+    "imageName": "store_cost_type_jade.png",
+    "roiFront": "600,490,50,60",
+    "roiBack": "600,490,50,60",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "购买时货币类型为勾玉"
   }
 ]

+ 11 - 0
tasks/DailyTrifles/store/ocr.json

@@ -0,0 +1,11 @@
+[
+  {
+    "itemName": "store_sushi_price",
+    "roiFront": "0,0,0,0",
+    "roiBack": "0,0,0,0",
+    "mode": "Digit",
+    "method": "Default",
+    "keyword": "",
+    "description": "商店Special购买体力所需勾玉数量,roiBack为动态调整,故此设置为0,0,0,0"
+  }
+]

BIN
tasks/DailyTrifles/store/store_cost_type_jade.png


BIN
tasks/DailyTrifles/store/store_sushi.png


+ 1 - 1
tasks/DemonEncounter/config.py

@@ -37,7 +37,7 @@ class DemonConfig(BaseModel):
 
 
 class UtilizeScheduler(Scheduler):
-    priority = Field(default=2, description='priority_help')
+    priority: int = Field(default=2, description='priority_help')
 
 class DemonEncounter(ConfigBase):
     scheduler: UtilizeScheduler = Field(default_factory=UtilizeScheduler)

+ 95 - 20
tasks/Dokan/assets.py

@@ -12,28 +12,38 @@ class DokanAssets:
 
 	# Click Rule Assets
 	# 道馆随机点击安全区域 
-	C_DOKAN_RANDOM_CLICK_AREA = RuleClick(roi_front=(142,294,107,555), roi_back=(142,294,107,555), name="dokan_random_click_area")
+	C_DOKAN_RANDOM_CLICK_AREA = RuleClick(roi_front=(142,294,107,150), roi_back=(142,294,107,150), name="dokan_random_click_area")
 	# 道馆随机点击安全区域1:竂友突破信息 
-	C_DOKAN_RANDOM_CLICK_AREA1 = RuleClick(roi_front=(42,594,10,100), roi_back=(42,594,10,100), name="dokan_random_click_area1")
+	C_DOKAN_RANDOM_CLICK_AREA1 = RuleClick(roi_front=(42,594,10,30), roi_back=(42,594,10,30), name="dokan_random_click_area1")
 	# 道馆随机点击安全区域2:切换查看队伍模式。初步测试下来这个地方最安全,除了庭院、町中、逢魔外其他各场景都可用。 
 	C_DOKAN_RANDOM_CLICK_AREA2 = RuleClick(roi_front=(1122,360,10,40), roi_back=(1122,360,10,40), name="dokan_random_click_area2")
 	# 道馆随机点击安全区域3 
 	C_DOKAN_RANDOM_CLICK_AREA3 = RuleClick(roi_front=(333,44,107,20), roi_back=(333,44,107,20), name="dokan_random_click_area3")
+	# 道馆突破排名弹出时,点击此区域关闭 
+	C_DOKAN_TOPPA_RANK_CLOSE_AREA = RuleClick(roi_front=(1150,380,100,150), roi_back=(1150,380,100,150), name="dokan_toppa_rank_close_area")
 	# 准备战斗 
 	C_DOKAN_READY_FOR_BATTLE = RuleClick(roi_front=(42,94,1207,543), roi_back=(42,94,1207,543), name="dokan_ready_for_battle")
+	# 查找道馆时 点击此区域 隐藏道馆详情(显示防守人数,馆主等级等的卡片) 
+	C_DOKAN_CANCEL_SELECT_DOKAN = RuleClick(roi_front=(1070,610,30,90), roi_back=(1070,610,30,90), name="dokan_cancel_select_dokan")
+	# ruleanimate 用作检测选择道馆时,确定地图区域稳定无动作 
+	C_DOKAN_CANCEL_SELECT_DOKAN_CHECK_ANIMATE = RuleClick(roi_front=(600,330,80,60), roi_back=(600,330,80,60), name="dokan_cancel_select_dokan_check_animate")
+	# 查找道馆时 刷新道馆列表 
+	C_DOKAN_REFRESH = RuleClick(roi_front=(1140,630,40,30), roi_back=(1140,630,40,30), name="dokan_refresh")
+	# 道馆战斗时,左上角 退出按钮区域 
+	C_DOKAN_BATTLE_QUIT_AREA = RuleClick(roi_front=(10,36,50,14), roi_back=(10,36,50,14), name="dokan_battle_quit_area")
 
 
 	# Image Rule Assets
-	# 阴阳竂->神社 
-	I_RYOU_SHENSHE = RuleImage(roi_front=(476,173,62,24), roi_back=(476,173,62,24), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_shenshe.png")
+	# 阴阳寮->神社的按钮 
+	I_RYOU_SHENSHE = RuleImage(roi_front=(850,660,100,60), roi_back=(850,660,100,60), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_shenshe.png")
 	# 神社->道馆 
-	I_RYOU_DOKAN = RuleImage(roi_front=(476,173,62,24), roi_back=(476,173,62,24), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan.png")
-	# []选择竂 
-	I_RYOU_DOKAN_RYOU_SELECT = RuleImage(roi_front=(567,15,144,42), roi_back=(567,15,144,42), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_ryou_select.png")
-	# 可选的竂列表 
-	I_RYOU_DOKAN_RYOU_LIST = RuleImage(roi_front=(567,15,144,42), roi_back=(567,15,144,42), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_ryou_list.png")
+	I_RYOU_DOKAN = RuleImage(roi_front=(465,160,100,50), roi_back=(465,160,100,50), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan.png")
+	# 阴阳寮卡通人界面,左侧已开启的活动 列表 
+	I_RYOU_DOKAN_ACTIVATED = RuleImage(roi_front=(0,150,200,400), roi_back=(0,150,200,400), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_activated.png")
 	# 是否已经成功进入道馆,上面中间的“道馆突破”文字 
 	I_RYOU_DOKAN_CHECK = RuleImage(roi_front=(567,15,144,42), roi_back=(567,15,144,42), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_check.png")
+	# 道馆内式神录 
+	I_RYOU_DOKAN_SHIKIGAMI = RuleImage(roi_front=(960,580,140,120), roi_back=(960,580,140,120), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_shikigami.png")
 	# 优先攻击选项 
 	I_RYOU_DOKAN_ATTACK_PRIORITY = RuleImage(roi_front=(666,672,58,25), roi_back=(666,672,58,25), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_priority.png")
 	# 优先攻击: 见习 
@@ -46,30 +56,56 @@ class DokanAssets:
 	I_RYOU_DOKAN_ATTACK_PRIORITY_3 = RuleImage(roi_front=(830,175,88,41), roi_back=(830,175,88,41), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_priority_3.png")
 	# 优先攻击: 黑脸 
 	I_RYOU_DOKAN_ATTACK_PRIORITY_4 = RuleImage(roi_front=(1072,178,94,39), roi_back=(1072,178,94,39), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_priority_4.png")
+	# 正在查找道馆,还未选择 
+	I_RYOU_DOKAN_FINDING_DOKAN = RuleImage(roi_front=(980,60,100,160), roi_back=(980,60,100,160), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_finding_dokan.png")
+	# 已选择道馆 
+	I_RYOU_DOKAN_FOUND_DOKAN = RuleImage(roi_front=(440,580,360,140), roi_back=(440,580,360,140), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_found_dokan.png")
 	# 状态:集结等待中。检查右下角的挑战是不是灰色的。FIXME 黄色和灰色的挑战截图总是傻傻分不清,先改用OCR 
 	I_RYOU_DOKAN_GATHERING = RuleImage(roi_front=(653,76,46,26), roi_back=(653,76,46,26), threshold=0.85, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_gathering.png")
 	# 状态:检查右下角有没有挑战?通常是失败了,并退出来到集结界面,可重新开始点击右下角挑战进入战斗 
-	I_RYOU_DOKAN_START_CHALLENGE = RuleImage(roi_front=(1132,572,89,43), roi_back=(1132,572,89,43), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_start_challenge.png")
+	I_RYOU_DOKAN_START_CHALLENGE = RuleImage(roi_front=(1100,550,180,80), roi_back=(1100,550,180,80), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_start_challenge.png")
 	# 状态:达到失败次数,CD中。挑战次数恢复倒数 
 	I_RYOU_DOKAN_CD1 = RuleImage(roi_front=(1068,500,146,27), roi_back=(1068,500,146,27), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_cd1.png")
 	# 状态:达到失败次数,CD中。观战按钮 
 	I_RYOU_DOKAN_CD = RuleImage(roi_front=(1122,566,117,74), roi_back=(1122,566,117,74), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_cd.png")
-	# 状态:进入战斗,待开始,右下角图标。TODO 欠截图。 
+	# 状态:进入战斗,待开始,右下角图标。 
 	I_RYOU_DOKAN_IN_FIELD = RuleImage(roi_front=(1128,536,100,100), roi_back=(1128,536,100,100), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_in_field.png")
 	# 馆主战等待中 
-	I_DOKAN_BOSS_WAITING = RuleImage(roi_front=(603,148,130,32), roi_back=(603,148,130,32), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_dokan_boss_waiting.png")
+	I_DOKAN_BOSS_WAITING = RuleImage(roi_front=(460,140,370,80), roi_back=(460,140,370,80), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_dokan_boss_waiting.png")
+	# 馆主战 等待 或 进行中时 在寮境中出现的馆主图标 
+	I_RYOU_DOKAN_MASTER_BATTLE = RuleImage(roi_front=(640,0,640,360), roi_back=(640,0,640,360), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_master_battle.png")
+	# 放弃突破 
+	I_DOKAN_ABANDONED_TOPPA = RuleImage(roi_front=(0,550,180,170), roi_back=(0,550,180,170), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_abandoned_toppa.png")
+	# 放弃突破 确认按钮 
+	I_DOKAN_ABANDONED_TOPPA_ENSURE = RuleImage(roi_front=(0,0,1280,720), roi_back=(0,0,1280,720), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_abandoned_toppa_ensure.png")
+	# 放弃突破 
+	I_DOKAN_ABANDONED_TOPPA_TITLE = RuleImage(roi_front=(1020,160,260,80), roi_back=(1020,160,260,80), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_abandoned_toppa_title.png")
 	# 状态:道馆胜利 
-	I_RYOU_DOKAN_WIN = RuleImage(roi_front=(628,60,45,33), roi_back=(628,60,45,33), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_win.png")
+	I_RYOU_DOKAN_WIN = RuleImage(roi_front=(620,50,100,80), roi_back=(620,50,100,80), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_win.png")
 	# 状态:进入战斗,待开始,右下角图标。 
 	I_RYOU_DOKAN_IN_FIELD2 = RuleImage(roi_front=(1131,562,88,48), roi_back=(1131,562,88,48), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_in_field2.png")
+	# 馆主战,第一阵容 
+	I_RYOU_DOKAN_BATTLE_MASTER_FIRST = RuleImage(roi_front=(1080,180,160,70), roi_back=(1080,180,160,70), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_battle_master_first.png")
+	# 馆主战,第二阵容 # TODO 截图 
+	I_RYOU_DOKAN_BATTLE_MASTER_SECOND = RuleImage(roi_front=(1080,180,160,70), roi_back=(1080,180,160,70), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_battle_master_second.png")
 	# 状态:战斗结算,可能是打完小朋友了,也可能是失败了。 
 	I_RYOU_DOKAN_BATTLE_OVER = RuleImage(roi_front=(571,503,106,49), roi_back=(571,503,106,49), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_battle_over.png")
 	# 状态:战斗中,左上角的加油图标 
 	I_RYOU_DOKAN_FIGHTING = RuleImage(roi_front=(232,36,42,19), roi_back=(232,36,42,19), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_fighting.png")
 	# 状态:道馆已经结束 
 	I_RYOU_DOKAN_FINISHED = RuleImage(roi_front=(658,649,91,27), roi_back=(658,649,91,27), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_finished.png")
-	# 状态:道馆挑战失败,投票NO 
-	I_RYOU_DOKAN_FAILED_VOTE_NO = RuleImage(roi_front=(567,15,144,42), roi_back=(567,15,144,42), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_failed_vote_no.png")
+	# 道馆失败/成功 出现的突破排名 弹窗 
+	I_RYOU_DOKAN_TOPPA_RANK = RuleImage(roi_front=(110,80,170,70), roi_back=(110,80,170,70), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_toppa_rank.png")
+	# 状态:道馆挑战失败,投票 保留赏金 
+	I_RYOU_DOKAN_FAILED_VOTE_KEEP_BOUNTY = RuleImage(roi_front=(1020,220,260,120), roi_back=(1020,220,260,120), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_failed_vote_keep_bounty.png")
+	# 状态:道馆挑战失败,投票 再战道馆 
+	I_RYOU_DOKAN_FAILED_VOTE_BATTLE_AGAIN = RuleImage(roi_front=(1020,220,260,120), roi_back=(1020,220,260,120), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_failed_vote_battle_again.png")
+	# 状态:道馆投票 放弃突破 
+	I_RYOU_DOKAN_ABANDONED_TOPPA_ABANDONED = RuleImage(roi_front=(1020,220,260,120), roi_back=(1020,220,260,120), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_abandoned_toppa_abandoned.png")
+	# 状态:道馆投票 继续突破 
+	I_RYOU_DOKAN_ABANDONED_TOPPA_CONTINUE = RuleImage(roi_front=(1020,220,260,120), roi_back=(1020,220,260,120), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_abandoned_toppa_continue.png")
+	# 道馆战斗界面 点击退出按钮后 弹出的确认按钮 
+	I_RYOU_DOKAN_QUIT_BATTLE_ENSURE = RuleImage(roi_front=(0,0,1280,720), roi_back=(0,0,1280,720), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_quit_battle_ensure.png")
 	# 道馆退出确认 
 	I_RYOU_DOKAN_EXIT_ENSURE = RuleImage(roi_front=(678,395,125,56), roi_back=(678,395,125,56), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_exit_ensure.png")
 	# 进入加油相关:道馆战报按钮 
@@ -78,13 +114,45 @@ class DokanAssets:
 	I_RYOU_DOKAN_CHEERING_ATTACKING_SAMA = RuleImage(roi_front=(948,182,56,295), roi_back=(948,182,56,295), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_cheering_attacking_sama.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_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=(0,100,600,600), roi_back=(0,100,600,600), 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_ENSURE = RuleImage(roi_front=(0,0,1280,720), roi_back=(0,0,1280,720), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_create_dokan_ensure.png")
+	# 道馆信息 右上角关闭按钮 
+	I_RYOU_DOKAN_DOKAN_INFO_CLOSE = RuleImage(roi_front=(1150,80,100,90), roi_back=(1150,80,100,90), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_dokan_info_close.png")
+	# 寮境界面,道馆打完后 出现在底部的'今日可挑战机会'字样 
+	I_RYOU_DOKAN_TODAY_ATTACK_COUNT = RuleImage(roi_front=(500,630,250,50), roi_back=(500,630,250,50), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_today_attack_count.png")
+	# 今日道馆已挑战成功 
+	I_RYOU_DOKAN_REMAIN_ATTACK_COUNT_DONE = RuleImage(roi_front=(550,610,220,80), roi_back=(550,610,220,80), threshold=0.9, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_remain_attack_count_done.png")
+	# 今日可挑战次数:0次 
+	I_RYOU_DOKAN_REMAIN_ATTACK_COUNT_ZERO = RuleImage(roi_front=(650,610,110,80), roi_back=(650,610,110,80), threshold=0.9, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_remain_attack_count_zero.png")
+	# 今日可挑战次数:1次 
+	I_RYOU_DOKAN_REMAIN_ATTACK_COUNT_ONE = RuleImage(roi_front=(650,610,110,80), roi_back=(650,610,110,80), threshold=0.9, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_remain_attack_count_one.png")
+	# 今日可挑战次数:2次 
+	I_RYOU_DOKAN_REMAIN_ATTACK_COUNT_TWO = RuleImage(roi_front=(650,610,110,80), roi_back=(650,610,110,80), threshold=0.9, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_remain_attack_count_two.png")
+	# 查找道馆时,中间信息卡片 馆主等级-修习 
+	I_CENTER_GUANZHU_XIUXI = RuleImage(roi_front=(0,0,1280,720), roi_back=(0,0,1280,720), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_center_guanzhu_xiuxi.png")
+	# 查找道馆时,中间防守人数字样,为了定位该图下方的 防守人数数字 
+	I_CENTER_POINT_PEOPLE_NUMBER = RuleImage(roi_front=(0,0,1280,720), roi_back=(0,0,1280,720), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_center_point_people_number.png")
+	# 查找道馆时,挑战按钮 
+	I_CENTER_CHALLENGE = RuleImage(roi_front=(0,0,1280,720), roi_back=(0,0,1280,720), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_center_challenge.png")
+	# 查找道馆时,确认挑战按钮 
+	I_CHALLENGE_ENSURE = RuleImage(roi_front=(0,0,1280,720), roi_back=(0,0,1280,720), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_challenge_ensure.png")
+	# 查找道馆时,确认刷新道馆列表按钮 
+	I_REFRESH_ENSURE = RuleImage(roi_front=(0,0,1280,720), roi_back=(0,0,1280,720), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_refresh_ensure.png")
+	# 查找道馆时,右侧道馆赏金图标,为了定位该图右侧的 赏金金额 
+	I_RIGHTPAD_POINT_BOUNTY = RuleImage(roi_front=(1050,0,230,0), roi_back=(1050,0,230,50), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_rightpad_point_bounty.png")
+	# 寮境中上部的标志 
+	I_RYOU_DOKAN_CENTER_TOP = RuleImage(roi_front=(500,20,300,70), roi_back=(500,20,300,70), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_center_top.png")
+	# 左上角退出按钮- 
+	I_RYOU_DOKAN_DOKAN_QUIT = RuleImage(roi_front=(0,2,80,80), roi_back=(0,2,80,80), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_dokan_quit.png")
 
 
 	# List Rule Assets
 	# 这个是当前活跃的竂活动列表界面 
-	L_RYOU_ACTIVITY_LIST = RuleList(folder="./tasks/Dokan/res", direction="vertical", mode="ocr", roi_back=(35,157,37,250), size=(42, 27), 
+	L_RYOU_ACTIVITY_LIST = RuleList(folder="./tasks/Dokan/res", direction="vertical", mode="ocr", roi_back=(20,150,170,400), size=(42, 27), 
 					 array=["道馆", "首领", "狭间"])
 
 
@@ -97,7 +165,14 @@ class DokanAssets:
 	O_DOKAN_ATTACKING = RuleOcr(roi=(1122,546,92,51), area=(1122,546,92,51), mode="Single", method="Default", keyword="剩余", name="dokan_attacking")
 	# 道馆里找文字:后挑战馆主 
 	O_DOKAN_BOSS_WAITING = RuleOcr(roi=(603,148,130,32), area=(603,148,130,32), mode="Single", method="Default", keyword="馆主", name="dokan_boss_waiting")
-	# 道馆里找文字:后关闭 
-	O_DOKAN_SUCCEEDED = RuleOcr(roi=(655,76,49,28), area=(655,76,49,28), mode="Full", method="Default", keyword="关闭", name="dokan_succeeded")
+	# 查找道馆时,右侧边栏中的赏金 
+	O_DOKAN_RIGHTPAD_BOUNTY = RuleOcr(roi=(0,0,0,0), area=(0,0,0,0), mode="Single", method="Default", keyword="", name="dokan_rightpad_bounty")
+	# 查找道馆时,中间卡片上防守人数 
+	O_DOKAN_CENTER_PEOPLE_NUMBER = RuleOcr(roi=(0,0,0,0), area=(0,0,0,0), mode="Full", method="Default", keyword="", name="dokan_center_people_number")
+
+
+	# Swipe Rule Assets
+	# 道馆选择界面 右侧侧边栏 手指向上滑动 
+	S_DOKAN_LIST_UP = RuleSwipe(roi_front=(1100,420,30,21), roi_back=(1240,240,30,21), mode="default", name="dokan_list_up")
 
 

+ 140 - 4
tasks/Dokan/config.py

@@ -3,15 +3,118 @@
 # @author   jackyhwei
 # @note     draft version without full test
 # github    https://github.com/roarhill/oas
+import re
+from datetime import datetime
+from enum import Enum
 
 from pydantic import BaseModel, Field
-from enum import Enum
+
 from tasks.Component.GeneralBattle.config_general_battle import GeneralBattleConfig
 from tasks.Component.SwitchSoul.switch_soul_config import SwitchSoulConfig
-from tasks.Component.config_base import ConfigBase, Time
+from tasks.Component.config_base import ConfigBase
 from tasks.Component.config_scheduler import Scheduler
 
 
+class AttackDokanMasterType(str, Enum):
+    """
+        NOTE: 如果第一个道馆没有放弃突破,那么没有第二次选择道馆的机会
+            目前如果设置打一次馆主,如果打不过(失败),会一直等待->挑战循环
+            导致失去放弃突破的机会->无法进行第二次道馆
+    """
+    # 不打馆主                                  0
+    ATTACK_ZERO_ZERO = "ATTACK_ZERO_ZERO"
+    # 第二次攻击时攻击馆主一次                     1
+    ATTACK_ZERO_ONE = "ATTACK_ZERO_ONE"
+    # 第一次攻击时不攻击馆主,第二次攻击时攻击馆主一次     2
+    ATTACK_ZERO_TWO = "ATTACK_ZERO_TWO"
+    #                                           3
+    ATTACK_ONE_ZERO = "ATTACK_ONE_ZERO"
+    # 第一次攻击时攻击馆主一次,第二次攻击时攻击馆主一次 4
+    ATTACK_ONE_ONE = "ATTACK_ONE_ONE"
+    # 第一次攻击时攻击馆主一次,第二次攻击时攻击馆主二次 5
+    ATTACK_ONE_TWO = "ATTACK_ONE_TWO"
+    # 第一次攻击时攻击馆主二次, 没有第二次了          8
+    ATTACK_TWO_TWO = "ATTACK_TWO_TWO"
+
+    def __int__(self):
+        match self.value:
+            case "ATTACK_ZERO_ZERO":
+                return 0
+            case "ATTACK_ZERO_ONE":
+                return 1
+            case "ATTACK_ZERO_TWO":
+                return 2
+            case "ATTACK_ONE_ZERO":
+                return 3
+            case "ATTACK_ONE_ONE":
+                return 4
+            case "ATTACK_ONE_TWO":
+                return 5
+            case "ATTACK_TWO_TWO":
+                return 8
+            case _:
+                return 8
+
+
+class AttackAccountConfig(BaseModel):
+    # 当天可攻击次数,用以记录当天运行历史,用作状态恢复,不用配置
+    remain_attack_count: int = Field(default=2, description='remain_attack_count_help')
+    # remain_attack_count 值记录的时间,不用配置
+    attack_date: str = Field(default='2023-01-01', description='attack_date_help')
+    # 每日最大攻击次数(1-2,默认2次),建议:僵尸寮配置2,其他寮配置1
+    daily_attack_count: int = Field(default=2, description='daily_attack_count_help')
+    # 攻击馆主配置,格式:ATTACK_X_Y          X:  第一个道馆,只打馆主一阵/两阵都打
+    #                                    Y:  第二个道馆,只打馆主一阵/两阵都打
+    # 建议普通寮配置ATTACK_TWO_TWO,僵尸寮看自己喜好
+    attack_dokan_master: AttackDokanMasterType = Field(default=AttackDokanMasterType.ATTACK_TWO_TWO,
+                                                       description='attack_dokan_master_help')
+
+    def init_attack_count(self, callback=None):
+        today = datetime.now().strftime("%Y-%m-%d")
+        if today != self.attack_date:
+            self.attack_date = today
+            self.remain_attack_count = 2
+        if not callback:
+            return
+        callback()
+
+    def attack_dokan_master_count(self) -> int:
+        """
+        根据当前配置,获取此次道馆突破,需要攻击馆主的次数
+        @return: 当前突破,可攻击馆主的次数
+        @rtype:
+        """
+        if self.attack_dokan_master == AttackDokanMasterType.ATTACK_ZERO_ZERO:
+            return 0
+        if self.attack_dokan_master == AttackDokanMasterType.ATTACK_TWO_TWO:
+            return 2
+        # 只攻击一次
+        # 或者
+        # 还有一次选择寮的机会,即,在打第一个寮的过程中
+        if self.daily_attack_count == 1 or self.remain_attack_count >= 1:
+            return int(self.attack_dokan_master) // 3
+        # 攻击两次 且 在打第二个寮的过程中
+        return int(self.attack_dokan_master) % 3
+
+    def set_attack_count(self, count=2, callback=None):
+        if count < 0:
+            return
+        self.attack_date = datetime.now().strftime("%Y-%m-%d")
+        self.remain_attack_count = count
+        if not callback:
+            return
+        callback()
+
+    def del_attack_count(self, count, callback=None):
+        today = datetime.now().strftime("%Y-%m-%d")
+        if today != self.attack_date:
+            self.attack_date = today
+            self.remain_attack_count = 2
+        self.remain_attack_count -= count
+        if not callback:
+            return
+        callback()
+
 
 class DokanConfig(BaseModel):
     # # 寮管理开启道馆
@@ -29,10 +132,43 @@ class DokanConfig(BaseModel):
     random_delay: bool = Field(default=False, description='random_delay_help')
 
     # 防封:使用固定的随机区域进行随机点击,若为False将自动识别当前画面中的最大纯色区域作为随机点击区域
-    anti_detect_click_fixed_random_area: bool = Field(default=False, description='anti_detect_click_fixed_random_area_help')
+    anti_detect_click_fixed_random_area: bool = Field(default=False,
+                                                      description='anti_detect_click_fixed_random_area_help')
+
+    # 只在周一到周四开启道馆
+    monday_to_thursday: bool = Field(default=True, description='monday_to_thursday_help')
+
+    # 是否尝试开启道馆,在道馆未开启时,尝试查找合适道馆并开启,需要有权限
+    try_start_dokan: bool = Field(default=False, description='try_start_dokan')
+
+    # 道馆系数,赏金/人数 根据喜好配置
+    find_dokan_score: float = Field(default=4.6, description='dokan_score_help')
+
+    # 单次查找道馆时,最大刷新次数.超过此次数后,若还未找到符合要求的,会随机选择一个道馆
+    find_dokan_refresh_count: int = Field(default=7, description='find_dokan_refresh_count_help')
+
+    # 是否切换阵容(速攻阵容/挂机阵容)
+    switch_preset_enable: bool = Field(default=False, description='switch_preset_enable_help')
+
+    # 速攻阵容 格式:n,n
+    preset_group_1: str = Field(default="", description='preset_group_1_help')
+    # 挂机阵容
+    preset_group_2: str = Field(default="", description='preset_group_2_help')
+
+    # 按式神名字绿标,多个名字用“,”分隔
+    green_mark_shikigami_name: str = Field(default="", description='green_mark_shikigami_name_help')
+
+    def parse_preset_group(self, value: str):
+        re_str = r"([1-7])\,([1-5])"
+        tmp = re.match(re_str, value)
+        if not tmp:
+            return None, None
+        return int(tmp.group(1)), int(tmp.group(2))
+
 
 class Dokan(ConfigBase):
     scheduler: Scheduler = Field(default_factory=Scheduler)
     dokan_config: DokanConfig = Field(default_factory=DokanConfig)
     general_battle_config: GeneralBattleConfig = Field(default_factory=GeneralBattleConfig)
-    switch_soul_config: SwitchSoulConfig = Field(default_factory=SwitchSoulConfig)
+    switch_soul_config: SwitchSoulConfig = Field(default_factory=SwitchSoulConfig)
+    attack_count_config: AttackAccountConfig = Field(default_factory=AttackAccountConfig)

+ 146 - 0
tasks/Dokan/dokan_scene.py

@@ -0,0 +1,146 @@
+from enum import Enum
+
+from tasks.Component.GeneralBattle.assets import GeneralBattleAssets
+from tasks.Dokan.assets import DokanAssets
+from tasks.base_task import BaseTask
+
+
+class DokanScene(Enum):
+    # 未知界面
+    RYOU_DOKAN_SCENE_UNKNOWN = 0
+    # 进入道馆,集结中
+    RYOU_DOKAN_SCENE_GATHERING = 1
+    # 进入战场,等待用户点击开始战斗
+    RYOU_DOKAN_SCENE_IN_FIELD = 2
+    # 通常是失败了,并退出来到集结界面,可重新开始点击右下角挑战进入战斗
+    RYOU_DOKAN_SCENE_START_CHALLENGE = 3
+    # 失败次数超过上限,CD中
+    RYOU_DOKAN_SCENE_CD = 4
+    # 战斗进行中
+    RYOU_DOKAN_SCENE_FIGHTING = 5
+    # 馆主战第一阵容
+    RYOU_DOKAN_SCENE_BATTLE_MASTER_FIRST = 6
+    # 馆主战第二阵容
+    RYOU_DOKAN_SCENE_BATTLE_MASTER_SECOND = 7
+    # 加油进行中
+    RYOU_DOKAN_SCENE_CHEERING = 8
+    # 道馆是否投降投票
+    RYOU_DOKAN_SCENE_ABANDON_VOTE = 9
+    # 道馆投降后 投票再战还是保留赏金
+    RYOU_DOKAN_SCENE_FAILED_VOTE = 10
+    # 阴阳竂
+    RYOU_DOKAN_RYOU = 11
+    # 战斗结算,可能是打完小朋友了,也可能是失败了。
+    RYOU_DOKAN_SCENE_BATTLE_OVER = 12
+    # 等待BOSS战
+    RYOU_DOKAN_SCENE_BOSS_WAITING = 13
+    # 馆主战中,处于寮境
+    RYOU_DOKAN_SCENE_MASTER_BATTLING = 14
+    # 弹出窗口,道馆打完后,出现的排名
+    RYOU_DOKAN_SCENE_TOPPA_RANK = 15
+    # 道馆胜利后,出现的界面
+    RYOU_DOKAN_SCENE_WIN=16
+
+    # 阴阳寮神社界面
+    RYOU_DOKAN_SHENSHE = 17
+
+    # 正在查找道馆,处于地图界面
+    RYOU_DOKAN_SCENE_FINDING_DOKAN = 97
+    # 已选择道馆,处于地图界面
+    RYOU_DOKAN_SCENE_FOUND_DOKAN = 98
+    # 道馆结束
+    RYOU_DOKAN_SCENE_FINISHED = 99
+
+    def __str__(self):
+        return self.name.title()
+
+
+class DokanSceneDetector(DokanAssets, BaseTask, GeneralBattleAssets):
+    def get_current_scene(self, reuse_screenshot: bool = True) -> tuple[bool, DokanScene]:
+        """
+        检测当前场景
+        @type reuse_screenshot: object
+        @return 从道馆地图开始,及其后面的所有道馆界面,都返回True
+                一般界面,如庭院,式神录等 都返回False
+        """
+        if not reuse_screenshot:
+            self.screenshot()
+        # logger.info(f"get_current_scene={reuse_screenshot}")
+        # 场景检测:阴阳竂
+        if self.appear(self.I_SCENE_RYOU, threshold=0.8):
+            return False, DokanScene.RYOU_DOKAN_RYOU
+        # 场景检测:神社
+        if self.appear(self.I_SCENE_SHENSHE, threshold=0.8):
+            return False, DokanScene.RYOU_DOKAN_SHENSHE
+        # 状态, 判断是否正在查找道馆
+        if self.appear(self.I_RYOU_DOKAN_FINDING_DOKAN):
+            return True, DokanScene.RYOU_DOKAN_SCENE_FINDING_DOKAN
+        # 状态, 判断是否已查找到道馆
+        if self.appear(self.I_RYOU_DOKAN_FOUND_DOKAN):
+            return True, DokanScene.RYOU_DOKAN_SCENE_FOUND_DOKAN
+
+        # 状态:判断是否集结中
+        if self.appear(self.I_RYOU_DOKAN_GATHERING, threshold=0.95):
+            return True, DokanScene.RYOU_DOKAN_SCENE_GATHERING
+
+        # 状态:是否在等待馆主战
+        if self.appear(self.I_DOKAN_BOSS_WAITING):
+            return True, DokanScene.RYOU_DOKAN_SCENE_BOSS_WAITING
+        # 状态: 馆主战开始,且可以挑战
+        if self.appear(self.I_RYOU_DOKAN_MASTER_BATTLE) and self.appear(self.I_RYOU_DOKAN_START_CHALLENGE):
+            return True, DokanScene.RYOU_DOKAN_SCENE_MASTER_BATTLING
+
+        # 馆主战斗中,未开始战斗状态
+        if self.appear(self.I_RYOU_DOKAN_BATTLE_MASTER_FIRST) and \
+                self.appear(self.I_PREPARE_HIGHLIGHT):
+            return True, DokanScene.RYOU_DOKAN_SCENE_BATTLE_MASTER_FIRST
+        if self.appear(self.I_RYOU_DOKAN_BATTLE_MASTER_SECOND) and \
+                self.appear(self.I_PREPARE_HIGHLIGHT):
+            return True, DokanScene.RYOU_DOKAN_SCENE_BATTLE_MASTER_SECOND
+
+        # 状态:达到失败次数,CD中
+        if self.appear(self.I_RYOU_DOKAN_CD):
+            return True, DokanScene.RYOU_DOKAN_SCENE_CD
+
+        # 状态:检查右下角有没有挑战?通常是失败了,并退出来到集结界面,可重新开始点击右下角挑战进入战斗
+        if self.appear(self.I_RYOU_DOKAN_START_CHALLENGE):
+            return True, DokanScene.RYOU_DOKAN_SCENE_START_CHALLENGE
+
+        # 状态:进入战斗,待开始
+        if self.appear(self.I_RYOU_DOKAN_IN_FIELD):
+            return True, DokanScene.RYOU_DOKAN_SCENE_IN_FIELD
+        # 状态:战斗结算,可能是打完小朋友了,也可能是失败了。
+        if self.appear(self.I_RYOU_DOKAN_BATTLE_OVER) or self.appear(GeneralBattleAssets.I_WIN) \
+                or self.appear(GeneralBattleAssets.I_FALSE):
+            return True, DokanScene.RYOU_DOKAN_SCENE_BATTLE_OVER
+
+        # # 状态:加油中,左下角有鼓
+        # if self.appear_then_click(self.I_RYOU_DOKAN_CHEERING, threshold=0.8) or self.appear(
+        #         self.I_RYOU_DOKAN_CHEERING_GRAY, threshold=0.8):
+        #     return True, DokanScene.RYOU_DOKAN_SCENE_CHEERING
+        # # 状态:战斗中,左上角的加油图标
+        # if self.appear(self.I_RYOU_DOKAN_FIGHTING, threshold=0.8):
+        #     return True, DokanScene.RYOU_DOKAN_SCENE_FIGHTING
+        # if self.appear(self.I_RYOU_DOKAN_FAILED_VOTE_NO):
+        #     return True, DokanScene.RYOU_DOKAN_SCENE_FAILED_VOTE_NO
+
+        # 打完道馆后,弹出的排名界面
+        if self.appear(self.I_RYOU_DOKAN_TOPPA_RANK):
+            return True, DokanScene.RYOU_DOKAN_SCENE_TOPPA_RANK
+        # 放弃突破投票,右侧俩 按钮:放弃/继续
+        if self.appear(self.I_RYOU_DOKAN_ABANDONED_TOPPA_CONTINUE):
+            return True, DokanScene.RYOU_DOKAN_SCENE_ABANDON_VOTE
+        # 放弃后投票,右侧俩按钮: 保留赏金/再战道馆
+        if self.appear(self.I_RYOU_DOKAN_FAILED_VOTE_KEEP_BOUNTY):
+            return True, DokanScene.RYOU_DOKAN_SCENE_FAILED_VOTE
+        # 状态:胜利
+        if self.appear(self.I_RYOU_DOKAN_WIN):
+            return True, DokanScene.RYOU_DOKAN_SCENE_WIN
+
+        # 状态:道馆已经结束 在寮境,底部有 "今日可挑战机会" 字样
+        if (self.appear(self.I_RYOU_DOKAN_CENTER_TOP) and
+                (self.appear(self.I_RYOU_DOKAN_TODAY_ATTACK_COUNT)
+                 or self.appear(self.I_RYOU_DOKAN_REMAIN_ATTACK_COUNT_DONE))):
+            return True, DokanScene.RYOU_DOKAN_SCENE_FINISHED
+
+        return False, DokanScene.RYOU_DOKAN_SCENE_UNKNOWN

+ 431 - 0
tasks/Dokan/ex_green_mark.py

@@ -0,0 +1,431 @@
+import threading
+from enum import Enum
+
+import cv2
+import numpy as np
+from pydantic import BaseModel
+
+from module.base.timer import Timer
+from module.logger import logger
+from tasks.Component.GeneralBattle.config_general_battle import GreenMarkType
+from tasks.Component.GeneralBattle.general_battle import GeneralBattle
+from tasks.Dokan.utils import retry
+
+
+#
+# def green_marker_detector(func):
+#     def wrapper(self, *args, **kwargs):
+#         event = threading.Event()
+#
+#         def detect_green_marker(image):
+#             hsv_image = cv2.cvtColor(image, cv2.COLOR_RGB2HSV)
+#             lower_green = np.array([67, 115, 110])
+#             upper_green = np.array([80, 255, 232])
+#             mask = cv2.inRange(hsv_image, lower_green, upper_green)
+#             result = cv2.bitwise_and(image, image, mask=mask)
+#             res = self.I_GREEN_MARKER.match(result)
+#             return res
+#
+#         def emit_exists():
+#             logger.info("Green marker detected!")
+#             unpack_screenshot()
+#             event.set()
+#
+#         def screenshot_and_detect():
+#             self.just_screenshot()
+#             exists = detect_green_marker(self.device.image)
+#             if exists:
+#                 emit_exists()
+#             return self.device.image
+#
+#         def pack_screenshot():
+#             self.just_screenshot = self.screenshot
+#             self.screenshot = screenshot_and_detect
+#
+#         def unpack_screenshot():
+#             self.screenshot = self.just_screenshot
+#
+#         def thread_run(self, detect_time=3, cb=None, cbargs=None):
+#             logger.info("detect thread running...")
+#             t = Timer(detect_time)
+#             t.start()
+#             while event.wait(detect_time):
+#                 logger.info("detect thread quit")
+#                 return
+#             unpack_screenshot()
+#             if cb:
+#                 logger.info(f"didn't detect green mark ,start running callback with arg:{cbargs}")
+#                 try:
+#                     cb(**cbargs)
+#                 except Exception as e:
+#                     logger.error(f"callback error:{e}")
+#
+#         # wrapper
+#         callback = kwargs.get('callback', None)
+#         cbargs = kwargs.get('cbargs', None)
+#         detect_time = kwargs.get('detect_time', 3.0)
+#
+#         if callback:
+#             logger.info("Green marker detector running...")
+#             pack_screenshot()
+#         # green mark 函数的参数列表
+#         kwarg_key = ['enable', 'mark_mode']
+#         func_kwargs = {key: kwargs[key] for key in kwarg_key if key in kwargs}
+#         if not event.is_set():
+#             func(self, *args, **func_kwargs)
+#
+#         if callback:
+#             thread = threading.Thread(target=thread_run, args=(self, detect_time, callback, cbargs), daemon=True)
+#             thread.start()
+#         return
+#
+#     return wrapper
+
+
+class GreenMarkState(int, Enum):
+    #
+    NOT_INIT = 0,
+    INITED = 1,
+    # 备用
+    MARKED = 2,
+    DISAPPEARED = 3
+
+
+class ExtendGreenMark(GeneralBattle):
+    # 式神名称
+    _shikigami_name = ""
+    # 绿标检测范围,x,y,w,h
+    _green_mark_detect_area: list[int] = None
+    # 式神名称范围,OCR检测出的式神名位置,x,y,w,h
+    _green_mark_click_roi: list[int] = None
+    # 绿标消失临界值
+    MAX_DISAPPEAR_COUNT = 40
+    MAX_DISAPPEAR_TIME = 4
+    # 尝试生成绿标的间隔
+    GREEN_MARK_INTERVAL = 1
+    # 绿标消失后,screenshot的次数
+    _disappear_count = 0
+    # 绿标消失的时间
+    _disappear_timer = Timer(MAX_DISAPPEAR_TIME)
+    # 判断是否开始检测绿标
+    _state = GreenMarkState.NOT_INIT
+
+    #
+
+    def __init__(self, config, device):
+        super().__init__(config, device)
+        self.super_green_mark = self.green_mark
+
+    def init_green_mark_from_cfg(self, names: str = None, green_mark_type: GreenMarkType = None):
+        self._shikigami_name = names
+        if self._shikigami_name is None or self._shikigami_name == "":
+            # 使用默认的绿标模式
+            tmp = self.generate_green_mark_area(green_mark_type)
+            self._green_mark_click_roi = tmp.roi_front
+        else:
+            # 使用式神名称进行绿标
+            def detect_name_position_retry():
+                self.device.screenshot()
+                return self.detect_name_position(self.device.image, self._shikigami_name)
+
+            # 多试几次,避免识别失败
+            self._green_mark_click_roi = retry(detect_name_position_retry, 3)
+
+        #
+        self._green_mark_detect_area = self.calc_green_mark_locate_area(self._green_mark_click_roi)
+        self.start_green_mark()
+        return
+
+    # @green_marker_detector
+    # def ex_green_mark(self, enable=True, mark_mode=GreenMarkType.GREEN_MAIN):
+    #     if not enable:
+    #         return
+    #     return self.super_green_mark(enable=enable, mark_mode=mark_mode)
+    #
+    # def ex_green_mark_3_retry(self, enable=True, mark_mode=GreenMarkType.GREEN_MAIN):
+    #     if not enable:
+    #         return
+    #     return self.ex_green_mark(enable=enable, mark_mode=mark_mode, detect_time=3, callback=self.super_green_mark,
+    #                               cbargs={'enable': enable, 'mark_mode': mark_mode})
+
+    def generate_green_mark_area(self, mark_mode: GreenMarkType = GreenMarkType.GREEN_MAIN):
+        result = None
+        logger.info(mark_mode.name)
+        match mark_mode:
+            case GreenMarkType.GREEN_LEFT1:
+                result = self.C_GREEN_LEFT_1
+                logger.info("Green left 1")
+            case GreenMarkType.GREEN_LEFT2:
+                result = self.C_GREEN_LEFT_2
+                logger.info("Green left 2")
+            case GreenMarkType.GREEN_LEFT3:
+                result = self.C_GREEN_LEFT_3
+                logger.info("Green left 3")
+            case GreenMarkType.GREEN_LEFT4:
+                result = self.C_GREEN_LEFT_4
+                logger.info("Green left 4")
+            case GreenMarkType.GREEN_LEFT5:
+                result = self.C_GREEN_LEFT_5
+                logger.info("Green left 5")
+            case GreenMarkType.GREEN_MAIN:
+                result = self.C_GREEN_MAIN
+                logger.info("Green main")
+        return result
+
+    def detect_name_position(self, img, names: str) -> list[int]:
+        def similarity(txt1, txt2):
+            txtset1 = set(txt1)
+            txtset2 = set(txt2)
+            intersection = txtset1.intersection(txtset2)
+            union = txtset1.union(txtset2)
+            return len(intersection) / len(union)
+
+        name_list = names.split(',')
+        for name in name_list:
+            # 此处为了获取到OCR模型,随机选择一个了RuleOcr对象,可以使用任意的RuleOcr对象
+            res_list = self.O_EXP_50.model.detect_and_ocr(img, 0.7)
+            res = [item for item in res_list if similarity(item.ocr_text, name) > 0.5]
+            res = sorted(res, key=lambda x: x.score)
+            if len(res) <= 0:
+                continue
+            box = res[0].box
+            logger.info(f"detect{res[0].ocr_text} with name:{name} in {box}")
+            # 经实验,点击式神名称位置,可能点击不到,故此做一个修正
+            offset = [5, 30, -10, 0]
+            # x,y,w,h
+            return [box[0, 0] + offset[0], box[0, 1] + offset[1], box[2, 0] - box[0, 0] + offset[2],
+                    box[2, 1] - box[0, 1] + offset[3]]
+        return None
+
+    def calc_green_mark_locate_area(self, roi, margin=None):
+        """
+        @param roi: 根据名字OCR得出的ROI,格式为x,y,w,h
+        @type roi: list[int]
+        @param margin: 扩展大小,格式为top,right,bottom,left,同CSS margin
+        @type margin:
+        @return:
+        @rtype:
+
+        """
+        if roi is None:
+            return [0, 0, 1280, 720]
+        result = [0, 0, 0, 0]
+        if margin is None:
+            margin = [160, 40, 20, 80]
+        result[0] = x if (x := roi[0] - margin[3]) > 0 else 0
+        result[1] = y if (y := roi[1] - margin[0]) > 0 else 0
+        result[2] = w if (w := roi[2] + margin[1] + margin[3]) + x <= 1280 else 1280 - x
+        result[3] = h if (h := roi[3] + margin[0] + margin[2]) + y <= 720 else 720 - y
+        return result
+
+    def detect_green_mark(self, img=None, area=None):
+        def init_green_marker_roi(roi):
+            self.I_GREEN_MARKER.roi_back = roi
+            self.I_GREEN_MARKER_LEFT_TOP.roi_back = roi
+            self.I_GREEN_MARKER_BOTTOM.roi_back = roi
+
+        # 初始化绿标相关变量的roi信息
+        if area is not None:
+            init_green_marker_roi(area)
+        elif self._green_mark_detect_area is not None:
+            init_green_marker_roi(self._green_mark_detect_area)
+        else:
+            init_green_marker_roi((0, 0, 1280, 720))
+
+        if img is not None:
+            self.device.image = img
+
+        def detect_green_marker_base(image):
+            hsv_image = cv2.cvtColor(image, cv2.COLOR_RGB2HSV)
+            lower_green = np.array([67, 115, 110])
+            upper_green = np.array([80, 255, 232])
+            mask = cv2.inRange(hsv_image, lower_green, upper_green)
+            result = cv2.bitwise_and(image, image, mask=mask)
+            # 伤害数字,御魂生效后弹出会遮挡绿标信息,目前的策略:尽量的延长检测到绿标的时间
+            res = (self.I_GREEN_MARKER_LEFT_TOP.match(result)
+                   or self.I_GREEN_MARKER_BOTTOM.match(result)
+                   or self.I_GREEN_MARKER.match(result))
+            return res
+
+        if detect_green_marker_base(self.device.image):
+            return True
+        return False
+
+    def green_mark_screenshot(self, callback=None):
+        """
+            替代原有screenshot
+        @return:
+        @rtype:
+        """
+        self.screenshot()
+        # 若未初始化,直接返回,不检测绿标状态
+        if self._state == GreenMarkState.NOT_INIT or self._state is None:
+            return self.device.image
+
+        # 检测式神名区域
+        if self._green_mark_click_roi is None and (self._shikigami_name is not None and self._shikigami_name != ""):
+            self._green_mark_click_roi = self.detect_name_position(self.device.image, self._shikigami_name)
+            if self._green_mark_click_roi is not None:
+                self._green_mark_detect_area = self.calc_green_mark_locate_area(self._green_mark_click_roi)
+
+        # 如果检测到绿标,直接返回
+        if self.detect_green_mark(self.device.image):
+            self._disappear_count = 0
+            self._disappear_timer.reset()
+            if self._state != GreenMarkState.MARKED:
+                logger.info("green mark appear")
+                self._state = GreenMarkState.MARKED
+            return self.device.image
+
+        if self._state != GreenMarkState.DISAPPEARED:
+            logger.info("green mark DISappear")
+            self._state = GreenMarkState.DISAPPEARED
+        self._disappear_count += 1
+        self._disappear_timer.start()
+        if self.need_green_mark():
+            if self.green_mark_with_area(interval=self.GREEN_MARK_INTERVAL):
+                self._disappear_timer.reset()
+                self._disappear_count = 0
+                if callback is not None:
+                    callback()
+        return self.device.image
+
+    def need_green_mark(self):
+        result = self._disappear_count > self.MAX_DISAPPEAR_COUNT
+        if result:
+            logger.info("MAX DISAPPEAR COUNT reached,Need Green Mark")
+            return True
+        result |= self._disappear_timer.reached()
+        if result:
+            logger.info("MAX DISAPPEAR TIME reached,Need Green Mark")
+            return True
+        return result
+
+    def green_mark_with_area(self, area=None, interval=1.5):
+        """
+            点击区域尝试添加绿标,不保证添加成功
+        @param area: 格式 x,y,w,h
+        @type area:
+        @return:
+        @rtype:
+        """
+        if area is None:
+            area = self._green_mark_click_roi
+        if area is None:
+            logger.warn("Green Mark with area None,give up")
+            return False
+        self.C_GREEN_MARK_AREA.roi_front = area
+        if self.click(self.C_GREEN_MARK_AREA, interval=interval):
+            # NOTE 防止式神死亡导致的连续点击,程序退出
+            self.device.click_record_clear()
+            logger.info(f"green mark with area:{area}")
+            return True
+        return False
+
+    def set_shikigami_name(self, name):
+        self._shikigami_name = name
+
+    def start_green_mark(self):
+        self._state = GreenMarkState.INITED
+        self._disappear_timer.clear()
+        self._disappear_count = 0
+
+    def stop_green_mark(self):
+        self._state = GreenMarkState.NOT_INIT
+
+    def set_disappear_count(self, count):
+        # 设置消失次数,用于(主动触发执行绿标)
+        self._disappear_count = count
+
+
+def change_green_mark(obj):
+    obj.old_green_mark = obj.green_mark
+    obj.green_mark = obj.ex_green_mark_3_retry
+
+
+if __name__ == '__main__':
+    # 读取图片,然后转换为HSV格式 ,使用cv2 matchtemplate 比较
+    import cv2
+    import numpy as np
+
+
+    def detect_green_marker_with_template(image_path, template_path):
+        # 读取图片
+        image = cv2.imread(image_path)
+        if image is None:
+            logger.error(f"Failed to read image from {image_path}")
+            return None
+
+        # 读取模板图片
+        template = cv2.imread(template_path)
+        if template is None:
+            logger.error(f"Failed to read template from {template_path}")
+            return None
+
+        # 转换为HSV格式
+        image = cv2.cvtColor(image, cv2.COLOR_BGR2HLS)
+        template = cv2.cvtColor(template, cv2.COLOR_BGR2HLS)
+        #
+        # image_h, image_s, image_v = cv2.split(image)
+        # template_h, template_s, template_v = cv2.split(template)
+        # image_s_norm = cv2.normalize(image_s, None, 0, 255, cv2.NORM_MINMAX)
+        # image_v_norm = cv2.normalize(image_v, None, 0, 255, cv2.NORM_MINMAX)
+        # template_s_norm = cv2.normalize(template_s, None, 0, 255, cv2.NORM_MINMAX)
+        # template_v_norm = cv2.normalize(template_v, None, 0, 255, cv2.NORM_MINMAX)
+
+        # clahe = cv2.createCLAHE(clipLimit=3.0, tileGridSize=(8, 8))
+        # image = clahe.apply(image_v)
+        # template = clahe.apply(template_v)
+
+        # 合并增强后的 HSV 通道
+        # image_enhanced_hsv = cv2.merge([image_h, image_s, image_v])
+        # template_enhanced_hsv = cv2.merge([template_h, template_s, template_v])
+
+        # 合并归一化后的 HSV 通道
+        # image = cv2.merge([image_h, image_s_norm, image_v_norm])
+        # template = cv2.merge([template_h, template_s_norm, template_v_norm])
+
+        # 使用matchTemplate进行比较
+        result = cv2.matchTemplate(image, template, cv2.TM_CCOEFF_NORMED)
+        min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(result)
+
+        # 获取匹配结果的位置和相似度
+        top_left = max_loc
+        h, w = template.shape[:2]
+        bottom_right = (top_left[0] + w, top_left[1] + h)
+
+        # 绘制矩形框标记匹配区域(可选)
+        cv2.rectangle(image, top_left, bottom_right, (0, 255, 0), 2)
+
+        # 返回匹配结果
+        return {
+            "position": top_left,
+            "similarity": max_val,
+            "image": image
+        }
+
+
+    # 示例调用
+    result = detect_green_marker_with_template("E:\\111.png", "E:\\same.png")
+    if result:
+        logger.info(f"Match found at position: {result['position']} with similarity: {result['similarity']}")
+    else:
+        logger.info("No match found.")
+
+    result = detect_green_marker_with_template("E:\\111.png", "E:\\diff.png")
+    if result:
+        logger.info(f"Match found at position: {result['position']} with similarity: {result['similarity']}")
+    else:
+        logger.info("No match found.")
+
+    result = detect_green_marker_with_template("E:\\222.png", "E:\\gb_prepare_highlight.png")
+    if result:
+        logger.info(f"Match found at position: {result['position']} with similarity: {result['similarity']}")
+    else:
+        logger.info("No match found.")
+
+    result = detect_green_marker_with_template("E:\\222.png", "E:\\gb_prepare_dark.png")
+    if result:
+        logger.info(f"Match found at position: {result['position']} with similarity: {result['similarity']}")
+    else:
+        logger.info("No match found.")

+ 34 - 4
tasks/Dokan/res/click.json

@@ -1,14 +1,14 @@
 [
   {
     "itemName": "dokan_random_click_area",
-    "roiFront": "142,294,107,555",
-    "roiBack": "142,294,107,555",
+    "roiFront": "142,294,107,150",
+    "roiBack": "142,294,107,150",
     "description": "道馆随机点击安全区域"
   },
   {
     "itemName": "dokan_random_click_area1",
-    "roiFront": "42,594,10,100",
-    "roiBack": "42,594,10,100",
+    "roiFront": "42,594,10,30",
+    "roiBack": "42,594,10,30",
     "description": "道馆随机点击安全区域1:竂友突破信息"
   },
   {
@@ -23,10 +23,40 @@
     "roiBack": "333,44,107,20",
     "description": "道馆随机点击安全区域3"
   },
+  {
+    "itemName": "dokan_toppa_rank_close_area",
+    "roiFront": "1150,380,100,150",
+    "roiBack": "1150,380,100,150",
+    "description": "道馆突破排名弹出时,点击此区域关闭"
+  },
   {
     "itemName": "dokan_ready_for_battle",
     "roiFront": "42,94,1207,543",
     "roiBack": "42,94,1207,543",
     "description": "准备战斗"
+  },
+  {
+    "itemName": "dokan_cancel_select_dokan",
+    "roiFront": "1070,610,30,90",
+    "roiBack": "1070,610,30,90",
+    "description": "查找道馆时 点击此区域 隐藏道馆详情(显示防守人数,馆主等级等的卡片)"
+  },
+  {
+    "itemName": "dokan_cancel_select_dokan_check_animate",
+    "roiFront": "600,330,80,60",
+    "roiBack": "600,330,80,60",
+    "description": "ruleanimate 用作检测选择道馆时,确定地图区域稳定无动作"
+  },
+  {
+    "itemName": "dokan_refresh",
+    "roiFront": "1140,630,40,30",
+    "roiBack": "1140,630,40,30",
+    "description": "查找道馆时 刷新道馆列表"
+  },
+  {
+    "itemName": "dokan_battle_quit_area",
+    "roiFront": "10,36,50,14",
+    "roiBack": "10,36,50,14",
+    "description": "道馆战斗时,左上角 退出按钮区域"
   }
 ]

+ 296 - 45
tasks/Dokan/res/image.json

@@ -2,47 +2,47 @@
   {
     "itemName": "ryou_shenshe",
     "imageName": "res_ryou_shenshe.png",
-    "roiFront": "476,173,62,24",
-    "roiBack": "476,173,62,24",
+    "roiFront": "850,660,100,60",
+    "roiBack": "850,660,100,60",
     "method": "Template matching",
     "threshold": 0.8,
-    "description": "阴阳竂->神社"
+    "description": "阴阳寮->神社的按钮"
   },
   {
     "itemName": "ryou_dokan",
     "imageName": "res_ryou_dokan.png",
-    "roiFront": "476,173,62,24",
-    "roiBack": "476,173,62,24",
+    "roiFront": "465,160,100,50",
+    "roiBack": "465,160,100,50",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "神社->道馆"
   },
   {
-    "itemName": "ryou_dokan_ryou_select",
-    "imageName": "res_ryou_dokan_ryou_select.png",
-    "roiFront": "567,15,144,42",
-    "roiBack": "567,15,144,42",
+    "itemName": "ryou_dokan_activated",
+    "imageName": "res_ryou_dokan_activated.png",
+    "roiFront": "0,150,200,400",
+    "roiBack": "0,150,200,400",
     "method": "Template matching",
     "threshold": 0.8,
-    "description": "[]选择竂"
+    "description": "阴阳寮卡通人界面,左侧已开启的活动 列表"
   },
   {
-    "itemName": "ryou_dokan_ryou_list",
-    "imageName": "res_ryou_dokan_ryou_list.png",
+    "itemName": "ryou_dokan_check",
+    "imageName": "res_ryou_dokan_check.png",
     "roiFront": "567,15,144,42",
     "roiBack": "567,15,144,42",
     "method": "Template matching",
     "threshold": 0.8,
-    "description": "可选的竂列表"
+    "description": "是否已经成功进入道馆,上面中间的“道馆突破”文字"
   },
   {
-    "itemName": "ryou_dokan_check",
-    "imageName": "res_ryou_dokan_check.png",
-    "roiFront": "567,15,144,42",
-    "roiBack": "567,15,144,42",
+    "itemName": "ryou_dokan_shikigami",
+    "imageName": "res_ryou_dokan_shikigami.png",
+    "roiFront": "960,580,140,120",
+    "roiBack": "960,580,140,120",
     "method": "Template matching",
     "threshold": 0.8,
-    "description": "是否已经成功进入道馆,上面中间的“道馆突破”文字"
+    "description": "道馆内式神录"
   },
   {
     "itemName": "ryou_dokan_attack_priority",
@@ -98,8 +98,24 @@
     "threshold": 0.8,
     "description": "优先攻击: 黑脸"
   },
-
-
+  {
+    "itemName": "ryou_dokan_finding_dokan",
+    "imageName": "res_ryou_dokan_finding_dokan.png",
+    "roiFront": "980,60,100,160",
+    "roiBack": "980,60,100,160",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "正在查找道馆,还未选择"
+  },
+  {
+    "itemName": "ryou_dokan_found_dokan",
+    "imageName": "res_ryou_dokan_found_dokan.png",
+    "roiFront": "440,580,360,140",
+    "roiBack": "440,580,360,140",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "已选择道馆"
+  },
   {
     "itemName": "ryou_dokan_gathering",
     "imageName": "res_ryou_dokan_gathering.png",
@@ -112,8 +128,8 @@
   {
     "itemName": "ryou_dokan_start_challenge",
     "imageName": "res_ryou_dokan_start_challenge.png",
-    "roiFront": "1132,572,89,43",
-    "roiBack": "1132,572,89,43",
+    "roiFront": "1100,550,180,80",
+    "roiBack": "1100,550,180,80",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "状态:检查右下角有没有挑战?通常是失败了,并退出来到集结界面,可重新开始点击右下角挑战进入战斗"
@@ -143,28 +159,62 @@
     "roiBack": "1128,536,100,100",
     "method": "Template matching",
     "threshold": 0.8,
-    "description": "状态:进入战斗,待开始,右下角图标。TODO 欠截图。"
+    "description": "状态:进入战斗,待开始,右下角图标。"
   },
   {
     "itemName": "dokan_boss_waiting",
     "imageName": "res_dokan_boss_waiting.png",
-    "roiFront": "603,148,130,32",
-    "roiBack": "603,148,130,32",
+    "roiFront": "460,140,370,80",
+    "roiBack": "460,140,370,80",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "馆主战等待中"
   },
-
+  {
+    "itemName": "ryou_dokan_master_battle",
+    "imageName": "res_ryou_dokan_master_battle.png",
+    "roiFront": "640,0,640,360",
+    "roiBack": "640,0,640,360",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "馆主战 等待 或 进行中时 在寮境中出现的馆主图标"
+  },
+  {
+    "itemName": "dokan_abandoned_toppa",
+    "imageName": "res_ryou_dokan_abandoned_toppa.png",
+    "roiFront": "0,550,180,170",
+    "roiBack": "0,550,180,170",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "放弃突破"
+  },
+  {
+    "itemName": "dokan_abandoned_toppa_ensure",
+    "imageName": "res_ryou_dokan_abandoned_toppa_ensure.png",
+    "roiFront": "0,0,1280,720",
+    "roiBack": "0,0,1280,720",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "放弃突破 确认按钮"
+  },
+  {
+    "itemName": "dokan_abandoned_toppa_title",
+    "imageName": "res_ryou_dokan_abandoned_toppa_title.png",
+    "roiFront": "1020,160,260,80",
+    "roiBack": "1020,160,260,80",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "放弃突破"
+  },
   {
     "itemName": "ryou_dokan_win",
     "imageName": "res_ryou_dokan_win.png",
-    "roiFront": "628,60,45,33",
-    "roiBack": "628,60,45,33",
+    "roiFront": "620,50,100,80",
+    "roiBack": "620,50,100,80",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "状态:道馆胜利"
   },
-
   {
     "itemName": "ryou_dokan_in_field2",
     "imageName": "res_ryou_dokan_in_field2.png",
@@ -174,6 +224,24 @@
     "threshold": 0.8,
     "description": "状态:进入战斗,待开始,右下角图标。"
   },
+  {
+    "itemName": "ryou_dokan_battle_master_first",
+    "imageName": "res_ryou_dokan_battle_master_first.png",
+    "roiFront": "1080,180,160,70",
+    "roiBack": "1080,180,160,70",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "馆主战,第一阵容"
+  },
+  {
+    "itemName": "ryou_dokan_battle_master_second",
+    "imageName": "res_ryou_dokan_battle_master_second.png",
+    "roiFront": "1080,180,160,70",
+    "roiBack": "1080,180,160,70",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "馆主战,第二阵容 # TODO 截图"
+  },
   {
     "itemName": "ryou_dokan_battle_over",
     "imageName": "res_ryou_dokan_battle_over.png",
@@ -183,7 +251,6 @@
     "threshold": 0.8,
     "description": "状态:战斗结算,可能是打完小朋友了,也可能是失败了。"
   },
-
   {
     "itemName": "ryou_dokan_fighting",
     "imageName": "res_ryou_dokan_fighting.png",
@@ -203,13 +270,58 @@
     "description": "状态:道馆已经结束"
   },
   {
-    "itemName": "ryou_dokan_failed_vote_no",
-    "imageName": "res_ryou_dokan_failed_vote_no.png",
-    "roiFront": "567,15,144,42",
-    "roiBack": "567,15,144,42",
+    "itemName": "ryou_dokan_toppa_rank",
+    "imageName": "res_ryou_dokan_toppa_rank.png",
+    "roiFront": "110,80,170,70",
+    "roiBack": "110,80,170,70",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "道馆失败/成功 出现的突破排名 弹窗"
+  },
+  {
+    "itemName": "ryou_dokan_failed_vote_keep_bounty",
+    "imageName": "res_ryou_dokan_failed_vote_keep_bounty.png",
+    "roiFront": "1020,220,260,120",
+    "roiBack": "1020,220,260,120",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "状态:道馆挑战失败,投票 保留赏金"
+  },
+  {
+    "itemName": "ryou_dokan_failed_vote_battle_again",
+    "imageName": "res_ryou_dokan_failed_vote_battle_again.png",
+    "roiFront": "1020,220,260,120",
+    "roiBack": "1020,220,260,120",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "状态:道馆挑战失败,投票 再战道馆"
+  },
+  {
+    "itemName": "ryou_dokan_abandoned_toppa_abandoned",
+    "imageName": "res_ryou_dokan_abandoned_toppa_abandoned.png",
+    "roiFront": "1020,220,260,120",
+    "roiBack": "1020,220,260,120",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "状态:道馆投票 放弃突破"
+  },
+  {
+    "itemName": "ryou_dokan_abandoned_toppa_continue",
+    "imageName": "res_ryou_dokan_abandoned_toppa_continue.png",
+    "roiFront": "1020,220,260,120",
+    "roiBack": "1020,220,260,120",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "状态:道馆投票 继续突破"
+  },
+  {
+    "itemName": "ryou_dokan_quit_battle_ensure",
+    "imageName": "res_ryou_dokan_quit_battle_ensure.png",
+    "roiFront": "0,0,1280,720",
+    "roiBack": "0,0,1280,720",
     "method": "Template matching",
     "threshold": 0.8,
-    "description": "状态:道馆挑战失败,投票NO"
+    "description": "道馆战斗界面 点击退出按钮后 弹出的确认按钮"
   },
   {
     "itemName": "ryou_dokan_exit_ensure",
@@ -220,8 +332,6 @@
     "threshold": 0.8,
     "description": "道馆退出确认"
   },
-
-  
   {
     "itemName": "ryou_dokan_cheering_scores",
     "imageName": "res_ryou_dokan_cheering_scores.png",
@@ -240,8 +350,6 @@
     "threshold": 0.8,
     "description": "进入加油相关:前往战斗中的竂友"
   },
-
-
   {
     "itemName": "scene_ryou",
     "imageName": "scene_ryou.png",
@@ -252,13 +360,156 @@
     "description": "场景检测:阴阳竂"
   },
   {
-    "itemName": "scene_ryou",
-    "imageName": "scene_ryou.png",
-    "roiFront": "1161,674,75,31",
-    "roiBack": "1161,674,75,31",
+    "itemName": "scene_shenshe",
+    "imageName": "scene_shenshe.png",
+    "roiFront": "0,100,600,600",
+    "roiBack": "0,100,600,600",
     "method": "Template matching",
     "threshold": 0.8,
-    "description": "场景检测:阴阳竂"
+    "description": "场景检测:神社"
+  },
+  {
+    "itemName": "ryou_dokan_create_dokan",
+    "imageName": "res_ryou_dokan_create_dokan.png",
+    "roiFront": "230,580,130,120",
+    "roiBack": "230,580,130,120",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "道馆 地图界面 建立道馆按钮"
+  },
+  {
+    "itemName": "ryou_dokan_create_dokan_ensure",
+    "imageName": "res_ryou_dokan_create_dokan_ensure.png",
+    "roiFront": "0,0,1280,720",
+    "roiBack": "0,0,1280,720",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "道馆 地图界面 点击建立道馆按钮后弹窗中的 确认按钮"
+  },
+  {
+    "itemName": "ryou_dokan_dokan_info_close",
+    "imageName": "res_ryou_dokan_dokan_info_close.png",
+    "roiFront": "1150,80,100,90",
+    "roiBack": "1150,80,100,90",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "道馆信息 右上角关闭按钮"
+  },
+  {
+    "itemName": "ryou_dokan_today_attack_count",
+    "imageName": "res_ryou_dokan_today_attack_count.png",
+    "roiFront": "500,630,250,50",
+    "roiBack": "500,630,250,50",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "寮境界面,道馆打完后 出现在底部的'今日可挑战机会'字样"
+  },
+  {
+    "itemName": "ryou_dokan_remain_attack_count_done",
+    "imageName": "res_ryou_dokan_remain_attack_count_done.png",
+    "roiFront": "550,610,220,80",
+    "roiBack": "550,610,220,80",
+    "method": "Template matching",
+    "threshold": 0.9,
+    "description": "今日道馆已挑战成功"
+  },
+  {
+    "itemName": "ryou_dokan_remain_attack_count_zero",
+    "imageName": "res_ryou_dokan_remain_attack_count_zero.png",
+    "roiFront": "650,610,110,80",
+    "roiBack": "650,610,110,80",
+    "method": "Template matching",
+    "threshold": 0.9,
+    "description": "今日可挑战次数:0次"
+  },
+  {
+    "itemName": "ryou_dokan_remain_attack_count_one",
+    "imageName": "res_ryou_dokan_remain_attack_count_one.png",
+    "roiFront": "650,610,110,80",
+    "roiBack": "650,610,110,80",
+    "method": "Template matching",
+    "threshold": 0.9,
+    "description": "今日可挑战次数:1次"
+  },
+  {
+    "itemName": "ryou_dokan_remain_attack_count_two",
+    "imageName": "res_ryou_dokan_remain_attack_count_two.png",
+    "roiFront": "650,610,110,80",
+    "roiBack": "650,610,110,80",
+    "method": "Template matching",
+    "threshold": 0.9,
+    "description": "今日可挑战次数:2次"
+  },
+  {
+    "itemName": "center_guanzhu_xiuxi",
+    "imageName": "res_ryou_dokan_center_guanzhu_xiuxi.png",
+    "roiFront": "0,0,1280,720",
+    "roiBack": "0,0,1280,720",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "查找道馆时,中间信息卡片 馆主等级-修习"
+  },
+  {
+    "itemName": "center_point_people_number",
+    "imageName": "res_ryou_dokan_center_point_people_number.png",
+    "roiFront": "0,0,1280,720",
+    "roiBack": "0,0,1280,720",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "查找道馆时,中间防守人数字样,为了定位该图下方的 防守人数数字"
+  },
+  {
+    "itemName": "center_challenge",
+    "imageName": "res_ryou_dokan_center_challenge.png",
+    "roiFront": "0,0,1280,720",
+    "roiBack": "0,0,1280,720",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "查找道馆时,挑战按钮"
+  },
+  {
+    "itemName": "challenge_ensure",
+    "imageName": "res_ryou_dokan_challenge_ensure.png",
+    "roiFront": "0,0,1280,720",
+    "roiBack": "0,0,1280,720",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "查找道馆时,确认挑战按钮"
+  },
+  {
+    "itemName": "refresh_ensure",
+    "imageName": "res_ryou_dokan_refresh_ensure.png",
+    "roiFront": "0,0,1280,720",
+    "roiBack": "0,0,1280,720",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "查找道馆时,确认刷新道馆列表按钮"
+  },
+  {
+    "itemName": "rightpad_point_bounty",
+    "imageName": "res_ryou_dokan_rightpad_point_bounty.png",
+    "roiFront": "1050,0,230,0",
+    "roiBack": "1050,0,230,50",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "查找道馆时,右侧道馆赏金图标,为了定位该图右侧的 赏金金额"
+  },
+  {
+    "itemName": "ryou_dokan_center_top",
+    "imageName": "res_ryou_dokan_center_top.png",
+    "roiFront": "500,20,300,70",
+    "roiBack": "500,20,300,70",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "寮境中上部的标志"
+  },
+  {
+    "itemName": "ryou_dokan_dokan_quit",
+    "imageName": "res_ryou_dokan_dokan_quit.png",
+    "roiFront": "0,2,80,80",
+    "roiBack": "0,2,80,80",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "左上角退出按钮-"
   }
-
 ]

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

@@ -2,7 +2,7 @@
     "name": "ryou_activity_list",
     "direction": "vertical",
     "type": "ocr",
-    "roiBack": "35,157,37,250",
+    "roiBack": "20,150,170,400",
     "description": "这个是当前活跃的竂活动列表界面",
     "list": [
       {

+ 15 - 6
tasks/Dokan/res/ocr.json

@@ -36,13 +36,22 @@
     "description": "道馆里找文字:后挑战馆主"
   },
   {
-    "itemName": "dokan_succeeded",
-    "roiFront": "655,76,49,28",
-    "roiBack": "655,76,49,28",
+    "itemName": "dokan_rightpad_bounty",
+    "roiFront": "0,0,0,0",
+    "roiBack": "0,0,0,0",
+    "mode": "Single",
+    "method": "Default",
+    "keyword": "",
+    "description": "查找道馆时,右侧边栏中的赏金"
+  },
+
+  {
+    "itemName": "dokan_center_people_number",
+    "roiFront": "0,0,0,0",
+    "roiBack": "0,0,0,0",
     "mode": "Full",
     "method": "Default",
-    "keyword": "关闭",
-    "description": "道馆里找文字:后关闭"
+    "keyword": "",
+    "description": "查找道馆时,中间卡片上防守人数"
   }
-
 ]

BIN
tasks/Dokan/res/res_dokan_boss_waiting.png


BIN
tasks/Dokan/res/res_ryou_dokan_abandoned_toppa.png


BIN
tasks/Dokan/res/res_ryou_dokan_abandoned_toppa_abandoned.png


BIN
tasks/Dokan/res/res_ryou_dokan_abandoned_toppa_continue.png


BIN
tasks/Dokan/res/res_ryou_dokan_abandoned_toppa_ensure.png


BIN
tasks/Dokan/res/res_ryou_dokan_abandoned_toppa_title.png


BIN
tasks/Dokan/res/res_ryou_dokan_activated.png


BIN
tasks/Dokan/res/res_ryou_dokan_battle_master_first.png


BIN
tasks/Dokan/res/res_ryou_dokan_battle_master_second.png


BIN
tasks/Dokan/res/res_ryou_dokan_center_challenge.png


BIN
tasks/Dokan/res/res_ryou_dokan_center_guanzhu_xiuxi.png


BIN
tasks/Dokan/res/res_ryou_dokan_center_point_people_number.png


BIN
tasks/Dokan/res/res_ryou_dokan_center_top.png


BIN
tasks/Dokan/res/res_ryou_dokan_challenge_ensure.png


BIN
tasks/Dokan/res/res_ryou_dokan_create_dokan.png


BIN
tasks/Dokan/res/res_ryou_dokan_create_dokan_ensure.png


BIN
tasks/Dokan/res/res_ryou_dokan_dokan_info_close.png


BIN
tasks/Dokan/res/res_ryou_dokan_dokan_quit.png


BIN
tasks/Dokan/res/res_ryou_dokan_failed_vote_battle_again.png


BIN
tasks/Dokan/res/res_ryou_dokan_failed_vote_keep_bounty.png


BIN
tasks/Dokan/res/res_ryou_dokan_finding_dokan.png


Some files were not shown because too many files changed in this diff