Przeglądaj źródła

Merge pull request #309 from runhey/dev

Dev
huangrunheng 2 lat temu
rodzic
commit
39d4c1b690
100 zmienionych plików z 2159 dodań i 123 usunięć
  1. 4 3
      .gitignore
  2. 3 3
      README.md
  3. 2 2
      dev_tools/assets_extract.py
  4. 2 2
      module/config/config_manual.py
  5. 2 2
      module/config/config_menu.py
  6. 38 9
      module/config/config_model.py
  7. 5 0
      module/config/i18n/zh_CN.ts
  8. 2 2
      module/logger.py
  9. 11 0
      module/server/home_router.py
  10. 12 0
      module/server/updater.py
  11. 2 1
      script.py
  12. 4 1
      server.py
  13. 13 2
      tasks/AreaBoss/assets.py
  14. 14 0
      tasks/AreaBoss/click.json
  15. BIN
      tasks/AreaBoss/res/ab_filter_opened.png
  16. BIN
      tasks/AreaBoss/res/ab_filter_title_collection.png
  17. 18 0
      tasks/AreaBoss/res/image.json
  18. 4 4
      tasks/AreaBoss/res/ocr.json
  19. 16 7
      tasks/AreaBoss/script_task.py
  20. 3 3
      tasks/BondlingFairyland/script_task.py
  21. 107 0
      tasks/Dokan/assets.py
  22. 38 0
      tasks/Dokan/config.py
  23. 32 0
      tasks/Dokan/res/click.json
  24. BIN
      tasks/Dokan/res/dokan_attacking.png
  25. BIN
      tasks/Dokan/res/gb_prepare_dark.png
  26. BIN
      tasks/Dokan/res/gb_prepare_highlight.png
  27. 282 0
      tasks/Dokan/res/image.json
  28. 23 0
      tasks/Dokan/res/list.json
  29. 48 0
      tasks/Dokan/res/ocr.json
  30. BIN
      tasks/Dokan/res/res_dokan_boss_waiting.png
  31. BIN
      tasks/Dokan/res/res_ryou_dokan.png
  32. BIN
      tasks/Dokan/res/res_ryou_dokan_battle_over.png
  33. BIN
      tasks/Dokan/res/res_ryou_dokan_cd.png
  34. BIN
      tasks/Dokan/res/res_ryou_dokan_cd1.png
  35. BIN
      tasks/Dokan/res/res_ryou_dokan_check.png
  36. BIN
      tasks/Dokan/res/res_ryou_dokan_cheering.png
  37. BIN
      tasks/Dokan/res/res_ryou_dokan_cheering_attacking_sama.png
  38. BIN
      tasks/Dokan/res/res_ryou_dokan_cheering_gray.png
  39. BIN
      tasks/Dokan/res/res_ryou_dokan_cheering_scores.png
  40. BIN
      tasks/Dokan/res/res_ryou_dokan_exit_ensure.png
  41. BIN
      tasks/Dokan/res/res_ryou_dokan_failed_vote_no.png.png
  42. BIN
      tasks/Dokan/res/res_ryou_dokan_fighting.png
  43. BIN
      tasks/Dokan/res/res_ryou_dokan_finished.png
  44. BIN
      tasks/Dokan/res/res_ryou_dokan_gathering.png
  45. BIN
      tasks/Dokan/res/res_ryou_dokan_in_field.png
  46. BIN
      tasks/Dokan/res/res_ryou_dokan_in_field2.png
  47. BIN
      tasks/Dokan/res/res_ryou_dokan_priority.png
  48. BIN
      tasks/Dokan/res/res_ryou_dokan_priority_0.png
  49. BIN
      tasks/Dokan/res/res_ryou_dokan_priority_1.png
  50. BIN
      tasks/Dokan/res/res_ryou_dokan_priority_2.png
  51. BIN
      tasks/Dokan/res/res_ryou_dokan_priority_3.png
  52. BIN
      tasks/Dokan/res/res_ryou_dokan_priority_4.png
  53. BIN
      tasks/Dokan/res/res_ryou_dokan_start_challenge.png
  54. BIN
      tasks/Dokan/res/res_ryou_dokan_start_challenge2.png
  55. BIN
      tasks/Dokan/res/res_ryou_dokan_win.png
  56. BIN
      tasks/Dokan/res/res_ryou_shenshe.png
  57. BIN
      tasks/Dokan/res/scene_ryou.png
  58. 525 0
      tasks/Dokan/script_task.py
  59. 197 0
      tasks/Dokan/utils.py
  60. 6 2
      tasks/Duel/assets.py
  61. BIN
      tasks/Duel/duel/duel_battle_with_train.png
  62. BIN
      tasks/Duel/duel/duel_d_battle2.png
  63. 22 4
      tasks/Duel/duel/image.json
  64. 16 2
      tasks/Duel/script_task.py
  65. 39 0
      tasks/FloatParade/assets.py
  66. 25 0
      tasks/FloatParade/config.py
  67. BIN
      tasks/FloatParade/fp/fp_fp_access.png
  68. BIN
      tasks/FloatParade/fp/fp_fp_batch.png
  69. BIN
      tasks/FloatParade/fp/fp_fp_batch_false.png
  70. BIN
      tasks/FloatParade/fp/fp_fp_batch_true.png
  71. BIN
      tasks/FloatParade/fp/fp_fp_getall0.png
  72. BIN
      tasks/FloatParade/fp/fp_fp_getall1.png
  73. BIN
      tasks/FloatParade/fp/fp_fp_red_close.png
  74. BIN
      tasks/FloatParade/fp/fp_fp_red_point0.png
  75. BIN
      tasks/FloatParade/fp/fp_fp_red_point1.png
  76. BIN
      tasks/FloatParade/fp/fp_fp_red_point2.png
  77. BIN
      tasks/FloatParade/fp/fp_fp_tasks.png
  78. BIN
      tasks/FloatParade/fp/fp_fp_upgrade.png
  79. 110 0
      tasks/FloatParade/fp/image.json
  80. 113 0
      tasks/FloatParade/script_task.py
  81. 6 2
      tasks/GameUi/page.py
  82. BIN
      tasks/GameUi/page/page_check_ryou_daoguan.png
  83. 2 2
      tasks/Hyakkiyakou/assets.py
  84. 4 4
      tasks/Hyakkiyakou/hya/click.json
  85. 1 1
      tasks/Hyakkiyakou/script_task.py
  86. 27 8
      tasks/Hyakkiyakou/slave/hya_device.py
  87. 5 8
      tasks/Restart/config.py
  88. 8 6
      tasks/RichMan/assets.py
  89. 1 0
      tasks/RichMan/mall/scales.py
  90. 21 12
      tasks/RichMan/mall/scales/image.json
  91. BIN
      tasks/RichMan/mall/scales/scales_sca_demon_boss_7.png
  92. 2 0
      tasks/Utils/config_enum.py
  93. 52 5
      tasks/WantedQuests/assets.py
  94. 72 6
      tasks/WantedQuests/config.py
  95. 200 20
      tasks/WantedQuests/invite/image.json
  96. 20 0
      tasks/WantedQuests/invite/ocr.json
  97. BIN
      tasks/WantedQuests/invite/wq_cooperation_type_cat_food.png
  98. BIN
      tasks/WantedQuests/invite/wq_cooperation_type_dog_food.png
  99. BIN
      tasks/WantedQuests/invite/wq_cooperation_type_gold.png
  100. BIN
      tasks/WantedQuests/invite/wq_cooperation_type_jade.png

+ 4 - 3
.gitignore

@@ -33,9 +33,10 @@ module/config/argument/setting.json
 !dev_tools/Spyxx/spyxx_amd64.exe
 !dev_tools/Spyxx/spyxx_amd64.exe
 !dev_tools/ViewWizard2/ViewWizard2.exe
 !dev_tools/ViewWizard2/ViewWizard2.exe
 !dev_tools/ViewWizard3/ViewWizard.exe
 !dev_tools/ViewWizard3/ViewWizard.exe
-./hya
-
-
+hya
+deploy/launcher/oas-backend.bat
+deploy/launcher/oas-server.bat
+oas-backend.bat
 
 
 
 
 
 

+ 3 - 3
README.md

@@ -36,16 +36,16 @@
 - OAS 还在开发中,[查看已实现](https://github.com/runhey/OnmyojiAutoScript/issues/54)
 - OAS 还在开发中,[查看已实现](https://github.com/runhey/OnmyojiAutoScript/issues/54)
 - **日常任务**: 悬赏封印、小猫咪、小杂签到、金币妖怪、年兽、花合战、地鬼、封魔、御魂整理
 - **日常任务**: 悬赏封印、小猫咪、小杂签到、金币妖怪、年兽、花合战、地鬼、封魔、御魂整理
 - **每周相关**: 真蛇、秘闻竞速、神秘商店、搜刮商店、斗技、每周小杂事
 - **每周相关**: 真蛇、秘闻竞速、神秘商店、搜刮商店、斗技、每周小杂事
-- **阴阳寮**: 结界上卡、结界蹭卡、结界突破、寮突破、狩猎战、集体任务
+- **阴阳寮**: 结界上卡、结界蹭卡、结界突破、寮突破、狩猎战、集体任务、道馆
 - **御魂副本**: 八岐大蛇、业原火、日轮之城、永生之海
 - **御魂副本**: 八岐大蛇、业原火、日轮之城、永生之海
-- **肝帝专属**: 探索、契灵、御灵、觉醒副本、石距
+- **肝帝专属**: 探索、契灵、御灵、觉醒副本、石距、百鬼夜行
 - **限时活动**: 每期爬塔、超鬼王、对弈竞猜
 - **限时活动**: 每期爬塔、超鬼王、对弈竞猜
 
 
 ### 显著特点 
 ### 显著特点 
 - **全部任务**: 你能想到的没有想到的都有,一条龙给你解放双手(该画饼画饼,该挖坑挖坑)
 - **全部任务**: 你能想到的没有想到的都有,一条龙给你解放双手(该画饼画饼,该挖坑挖坑)
 - **无缝衔接**: 时间管理大师,优异的任务调度系统,无缝寄养,无缝执行任务
 - **无缝衔接**: 时间管理大师,优异的任务调度系统,无缝寄养,无缝执行任务
 - **装饰可选**: 全部初始皮肤是什么鬼,这里支持你喜欢的庭院、主题等等,[详细说明](https://github.com/runhey/OnmyojiAutoScript/issues/180)
 - **装饰可选**: 全部初始皮肤是什么鬼,这里支持你喜欢的庭院、主题等等,[详细说明](https://github.com/runhey/OnmyojiAutoScript/issues/180)
-- **...**
+- **百鬼夜行**: 利用AI来智能撒豆子,模型包含所有式神,[效果展示](https://runhey.github.io/OnmyojiAutoScript-website/docs/user-manual/hyakkiyakou)
 
 
 ## 许可证 LICENSE
 ## 许可证 LICENSE
 
 

+ 2 - 2
dev_tools/assets_extract.py

@@ -357,7 +357,7 @@ class AssetsExtractor:
         将自身的_resule写入文件
         将自身的_resule写入文件
         :return:
         :return:
         """
         """
-        with open(self.assets_file, 'w', encoding='utf-8') as f:
+        with open(self.assets_file, 'w', encoding='utf-8', newline='\n') as f:
             f.write(self._result)
             f.write(self._result)
 
 
     def extract(self) -> str:
     def extract(self) -> str:
@@ -408,7 +408,7 @@ class AllAssetsExtractor:
         self.task_paths = [x for x in self.task_paths if 'Component' not in x]
         self.task_paths = [x for x in self.task_paths if 'Component' not in x]
         self.task_paths.extend([str(x) for x in (self.task_path / 'Component').iterdir() if x.is_dir()])
         self.task_paths.extend([str(x) for x in (self.task_path / 'Component').iterdir() if x.is_dir()])
 
 
-        process_map(self.work, self.task_paths, max_workers=4)
+        process_map(self.work, self.task_paths, max_workers=1)
 
 
     @staticmethod
     @staticmethod
     def work(task_path: str):
     def work(task_path: str):

+ 2 - 2
module/config/config_manual.py

@@ -11,14 +11,14 @@ class ConfigManual:
         Restart
         Restart
         > KekkaiUtilize > KekkaiActivation > DemonEncounter
         > KekkaiUtilize > KekkaiActivation > DemonEncounter
         > AreaBoss > GoldYoukai > ExperienceYoukai > Nian > Tako > RealmRaid > RyouToppa > DailyTrifles > Exploration
         > AreaBoss > GoldYoukai > ExperienceYoukai > Nian > Tako > RealmRaid > RyouToppa > DailyTrifles > Exploration
-        > Hunt 
+        > Dokan > Hunt 
         > Orochi > OrochiMoans > OrochiJudgement > Sougenbi > FallenSun > EternitySea
         > Orochi > OrochiMoans > OrochiJudgement > Sougenbi > FallenSun > EternitySea
         > ActivityShikigami > WantedQuests
         > ActivityShikigami > WantedQuests
         > BondlingFairyland > EvoZone > GoryouRealm
         > BondlingFairyland > EvoZone > GoryouRealm
         > TrueOrochi > RichMan
         > TrueOrochi > RichMan
         > CollectiveMissions
         > CollectiveMissions
         > Pets > TalismanPass > SoulsTidy > Delegation > Hyakkiyakou
         > Pets > TalismanPass > SoulsTidy > Delegation > Hyakkiyakou
-        > Secret > WeeklyTrifles > MysteryShop > Duel > MetaDemon > FrogBoss
+        > Secret > WeeklyTrifles > MysteryShop > Duel > MetaDemon > FrogBoss > FloatParade
         """
         """
 
 
     DEVICE_OVER_HTTP = False
     DEVICE_OVER_HTTP = False

+ 2 - 2
module/config/config_menu.py

@@ -28,12 +28,12 @@ class ConfigMenu:
         self.menu["Liver Emperor Exclusive"] = ['BondlingFairyland', 'EvoZone', 'GoryouRealm', 'Exploration',
         self.menu["Liver Emperor Exclusive"] = ['BondlingFairyland', 'EvoZone', 'GoryouRealm', 'Exploration',
                                                 'Hyakkiyakou']
                                                 'Hyakkiyakou']
         # 阴阳寮
         # 阴阳寮
-        self.menu["Guild"] = ['KekkaiUtilize', 'KekkaiActivation', 'RealmRaid', 'RyouToppa', 'CollectiveMissions',
+        self.menu["Guild"] = ['KekkaiUtilize', 'KekkaiActivation', 'RealmRaid', 'RyouToppa', 'Dokan', 'CollectiveMissions',
                               'Hunt']
                               'Hunt']
         # 每周任务
         # 每周任务
         self.menu["Weekly Task"] = ['TrueOrochi', 'RichMan', 'Secret', 'WeeklyTrifles', 'MysteryShop', 'Duel']
         self.menu["Weekly Task"] = ['TrueOrochi', 'RichMan', 'Secret', 'WeeklyTrifles', 'MysteryShop', 'Duel']
         # 活动的任务
         # 活动的任务
-        self.menu["Activity Task"] = ['ActivityShikigami', 'MetaDemon', 'FrogBoss']
+        self.menu["Activity Task"] = ['ActivityShikigami', 'MetaDemon', 'FrogBoss', 'FloatParade']
         # 开发工具
         # 开发工具
         self.menu["Tools"] = ['Image Rule', 'Ocr Rule', 'Click Rule', 'Long Click Rule', 'Swipe Rule', 'List Rule']
         self.menu["Tools"] = ['Image Rule', 'Ocr Rule', 'Click Rule', 'Long Click Rule', 'Swipe Rule', 'List Rule']
 
 

+ 38 - 9
module/config/config_model.py

@@ -16,6 +16,7 @@ from module.logger import logger
 from tasks.Component.config_base import ConfigBase, TimeDelta
 from tasks.Component.config_base import ConfigBase, TimeDelta
 from tasks.Exploration.config import Exploration
 from tasks.Exploration.config import Exploration
 from tasks.RyouToppa.config import RyouToppa
 from tasks.RyouToppa.config import RyouToppa
+from tasks.Dokan.config import Dokan
 from tasks.Script.config import Script
 from tasks.Script.config import Script
 from tasks.Restart.config import Restart
 from tasks.Restart.config import Restart
 from tasks.GlobalGame.config import GlobalGame
 from tasks.GlobalGame.config import GlobalGame
@@ -48,6 +49,7 @@ from tasks.Hunt.config import Hunt
 from tasks.ActivityShikigami.config import ActivityShikigami
 from tasks.ActivityShikigami.config import ActivityShikigami
 from tasks.MetaDemon.config import MetaDemon
 from tasks.MetaDemon.config import MetaDemon
 from tasks.FrogBoss.config import FrogBoss
 from tasks.FrogBoss.config import FrogBoss
+from tasks.FloatParade.config import FloatParade
 # ----------------------------------------------------------------------------------------------------------------------
 # ----------------------------------------------------------------------------------------------------------------------
 
 
 # 肝帝专属---------------------------------------------------------------------------------------------------------------
 # 肝帝专属---------------------------------------------------------------------------------------------------------------
@@ -102,6 +104,7 @@ class ConfigModel(ConfigBase):
     activity_shikigami: ActivityShikigami = Field(default_factory=ActivityShikigami)
     activity_shikigami: ActivityShikigami = Field(default_factory=ActivityShikigami)
     meta_demon: MetaDemon = Field(default_factory=MetaDemon)
     meta_demon: MetaDemon = Field(default_factory=MetaDemon)
     frog_boss: FrogBoss = Field(default_factory=FrogBoss)
     frog_boss: FrogBoss = Field(default_factory=FrogBoss)
+    float_parade: FloatParade = Field(default_factory=FloatParade)
 
 
     # 这些是肝帝专属
     # 这些是肝帝专属
     bondling_fairyland: BondlingFairyland = Field(default_factory=BondlingFairyland)
     bondling_fairyland: BondlingFairyland = Field(default_factory=BondlingFairyland)
@@ -120,6 +123,7 @@ class ConfigModel(ConfigBase):
     # 阴阳寮
     # 阴阳寮
     collective_missions: CollectiveMissions = Field(default_factory=CollectiveMissions)
     collective_missions: CollectiveMissions = Field(default_factory=CollectiveMissions)
     hunt: Hunt = Field(default_factory=Hunt)
     hunt: Hunt = Field(default_factory=Hunt)
+    dokan: Dokan = Field(default_factory=Dokan)
 
 
     # @validator('script')
     # @validator('script')
     # def script_validator(cls, v):
     # def script_validator(cls, v):
@@ -323,16 +327,9 @@ class ConfigModel(ConfigBase):
                 result.append(item)
                 result.append(item)
             return result
             return result
 
 
-
-
-
-
-
-
         schema = task.schema()
         schema = task.schema()
         groups = extract_groups(schema)
         groups = extract_groups(schema)
 
 
-
         result: dict[str, list] = {}
         result: dict[str, list] = {}
         for key, value in task.dict().items():
         for key, value in task.dict().items():
             result[key] = merge_value(groups[key], value, schema["definitions"])
             result[key] = merge_value(groups[key], value, schema["definitions"])
@@ -345,7 +342,6 @@ class ConfigModel(ConfigBase):
         group = convert_to_underscore(group)
         group = convert_to_underscore(group)
         argument = convert_to_underscore(argument)
         argument = convert_to_underscore(argument)
 
 
-
         # pandtic验证
         # pandtic验证
         if isinstance(value, str) and len(value) == 8:
         if isinstance(value, str) and len(value) == 8:
             try:
             try:
@@ -377,6 +373,12 @@ class ConfigModel(ConfigBase):
         if argument_object is None:
         if argument_object is None:
             logger.error(f'Set arg {task}.{group}.{argument}.{value} failed')
             logger.error(f'Set arg {task}.{group}.{argument}.{value} failed')
             return False
             return False
+        
+        # XXX temp implementation to enable oasx control the datetime configuration globally rather than a single task
+        if task == "restart" and group == "task_config" and argument == "reset_task_datetime_enable" and value == True:
+            date_time = self.restart.task_config.reset_task_datetime
+            logger.info(f"reset_task_datetime={date_time}")
+            self.reset_datetime_for_all_enabled_tasks(date_time)
 
 
         # 设置参数
         # 设置参数
         try:
         try:
@@ -388,7 +390,34 @@ class ConfigModel(ConfigBase):
             logger.error(e)
             logger.error(e)
             return False
             return False
 
 
-
+    def replace_next_run(self, d, dt: datetime):
+        for k, v in d.items():
+            if isinstance(v, dict):
+                self.replace_next_run(v, dt=dt)
+            elif k == "next_run":
+                d[k] = dt
+                # convert value to datetime if it's a str
+                if isinstance(v, str):
+                    current_time = datetime.strptime(v, "%Y-%m-%d %H:%M:%S")
+                    if current_time != dt:
+                        d[k] = dt.strftime("%Y-%m-%d %H:%M:%S")
+                # already a datetime value
+                elif isinstance(v, datetime) and v != dt:
+                    d[k] = dt.strftime("%Y-%m-%d %H:%M:%S")
+
+    def reset_datetime_for_all_enabled_tasks(self, task_datetime: datetime):
+        logger.warn(f"trying to reset datetime of all tasks to: {task_datetime}")
+        # logger.info(f"current config: {self.dict()}")
+        data = self.dict()
+        self.replace_next_run(data, task_datetime)
+        # logger.info(f"new config: {data}")
+
+        # write to json config  file
+        self.write_json(self.config_name, data)
+
+        # reload from the newly modified json config file
+        data = self.read_json(self.config_name)
+        super().__init__(**data)
 
 
 if __name__ == "__main__":
 if __name__ == "__main__":
     try:
     try:

+ 5 - 0
module/config/i18n/zh_CN.ts

@@ -173,6 +173,7 @@
 	<message><source>GlobalGame</source><translation>全局游戏设置</translation></message>
 	<message><source>GlobalGame</source><translation>全局游戏设置</translation></message>
 	<message><source>RealmRaid</source><translation>个人突破</translation></message>
 	<message><source>RealmRaid</source><translation>个人突破</translation></message>
 	<message><source>RyouToppa</source><translation>寮突破</translation></message>
 	<message><source>RyouToppa</source><translation>寮突破</translation></message>
+	<message><source>Dokan</source><translation>道馆</translation></message>
 	<message><source>Exploration</source><translation>探索</translation></message>
 	<message><source>Exploration</source><translation>探索</translation></message>
 	<message><source>List Rule</source><translation>列表规则</translation></message>
 	<message><source>List Rule</source><translation>列表规则</translation></message>
 	<message><source>Activity Task</source><translation>限时活动</translation></message>
 	<message><source>Activity Task</source><translation>限时活动</translation></message>
@@ -219,6 +220,7 @@
 	<message><source>GlobalGame</source><translation>全局游戏设置</translation></message>
 	<message><source>GlobalGame</source><translation>全局游戏设置</translation></message>
 	<message><source>RealmRaid</source><translation>个人突破</translation></message>
 	<message><source>RealmRaid</source><translation>个人突破</translation></message>
 	<message><source>RyouToppa</source><translation>寮突破</translation></message>
 	<message><source>RyouToppa</source><translation>寮突破</translation></message>
+	<message><source>Dokan</source><translation>道馆</translation></message>
 	<message><source>Exploration</source><translation>探索</translation></message>
 	<message><source>Exploration</source><translation>探索</translation></message>
 	<message><source>List Rule</source><translation>列表规则</translation></message>
 	<message><source>List Rule</source><translation>列表规则</translation></message>
 	<message><source>Activity Task</source><translation>限时活动</translation></message>
 	<message><source>Activity Task</source><translation>限时活动</translation></message>
@@ -418,6 +420,9 @@ window_background >>> DroidCast_raw >  ADB_nc >> DroidCast > uiautomator2 ~= ADB
 	<message><source>Buy Ap Activity</source><translation>游戏体力不足是否需要话勾玉购买</translation></message>
 	<message><source>Buy Ap Activity</source><translation>游戏体力不足是否需要话勾玉购买</translation></message>
 	<message><source>buy_ap_activity_help</source><translation>该设置只有是设定为活动次数时有效</translation></message>
 	<message><source>buy_ap_activity_help</source><translation>该设置只有是设定为活动次数时有效</translation></message>
 	<message><source>activity_toggle_help</source><translation>该设置只有是设定为活动次数时有效</translation></message>
 	<message><source>activity_toggle_help</source><translation>该设置只有是设定为活动次数时有效</translation></message>
+	<message><source>dokan_attack_priority_help</source><translation>道馆攻击优先顺序</translation></message>
+	<message><source>dokan_auto_cheering_while_cd_help</source><translation>失败CD后自动加油</translation></message>
+	<message><source>anti_detect_click_fixed_random_area_help</source><translation>防封:使用固定的随机区域进行随机点击,若为False将自动识别当前画面中的最大纯色区域作为随机点击区域</translation></message>
 </context>
 </context>
 <context>
 <context>
     <name>Args</name>
     <name>Args</name>

+ 2 - 2
module/logger.py

@@ -166,9 +166,9 @@ logger_debug = False
 logger = logging.getLogger('oas')
 logger = logging.getLogger('oas')
 logger.setLevel(logging.DEBUG if logger_debug else logging.INFO)
 logger.setLevel(logging.DEBUG if logger_debug else logging.INFO)
 file_formatter = logging.Formatter(
 file_formatter = logging.Formatter(
-    fmt='%(asctime)s.%(msecs)03d | %(levelname)8s | %(message)s', datefmt='%Y-%m-%d %H:%M:%S')
+    fmt='%(asctime)s.%(msecs)03d | %(filename)s:%(lineno)d | %(levelname)8s | %(message)s', datefmt='%Y-%m-%d %H:%M:%S')
 console_formatter = logging.Formatter(
 console_formatter = logging.Formatter(
-    fmt='%(asctime)s.%(msecs)03d │ %(message)s', datefmt='%Y-%m-%d %H:%M:%S')
+    fmt='%(asctime)s.%(msecs)03d | %(filename)s:%(lineno)d│ %(message)s', datefmt='%Y-%m-%d %H:%M:%S')
 flutter_formatter = logging.Formatter(
 flutter_formatter = logging.Formatter(
     fmt='| %(asctime)s.%(msecs)03d | %(message)08s', datefmt='%H:%M:%S')
     fmt='| %(asctime)s.%(msecs)03d | %(message)08s', datefmt='%H:%M:%S')
 
 

+ 11 - 0
module/server/home_router.py

@@ -60,3 +60,14 @@ async def update_info():
     except Exception as e:
     except Exception as e:
         logger.error(e)
         logger.error(e)
         return None
         return None
+
+@home_app.get('/execute_update')
+async def execute_update():
+    # 下拉仓库 -> 关闭所有脚本进程 -> 最后重启oasx
+    try:
+        updater = Updater()
+        updater.execute_pull()
+    except Exception as e:
+        logger.error(e)
+    return '手动更新将会立即结束运行中的脚本服务, 最后你还需重启oasx'
+

+ 12 - 0
module/server/updater.py

@@ -121,6 +121,18 @@ class Updater(DeployConfig, GitManager, PipManager):
             logger.info(f"No update")
             logger.info(f"No update")
             return False
             return False
 
 
+    def execute_pull(self) -> bool:
+        source = "origin"
+        for _ in range(3):
+            if self.execute(
+                    f'"{self.git}" pull {source} {self.Branch} --no-rebase', allow_failure=True
+            ):
+                break
+        else:
+            logger.warning("Git fetch failed")
+            return False
+
+
 
 
 if __name__ == "__main__":
 if __name__ == "__main__":
     updater = Updater()
     updater = Updater()

+ 2 - 1
script.py

@@ -386,7 +386,8 @@ class Script:
             logger.critical('This is likely to be a mistake of developers, but sometimes just random issues')
             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=command, content=f"<{self.config_name}> ScriptError")
             exit(1)
             exit(1)
-        except RequestHumanTakeover:
+        except RequestHumanTakeover as e:
+            logger.critical(e)
             logger.critical('Request human takeover')
             logger.critical('Request human takeover')
             self.config.notifier.push(title=command, content=f"<{self.config_name}> RequestHumanTakeover")
             self.config.notifier.push(title=command, content=f"<{self.config_name}> RequestHumanTakeover")
             exit(1)
             exit(1)

+ 4 - 1
server.py

@@ -54,7 +54,10 @@ def fun(ev: threading.Event):
     logger.attr("Port", port)
     logger.attr("Port", port)
     logger.attr("Reload", ev is not None)
     logger.attr("Reload", ev is not None)
 
 
-    uvicorn.run("module.server.app:fastapi_app", host=host, port=port, factory=True)
+    uvicorn.run("module.server.app:fastapi_app",
+                host=host,
+                port=port,
+                factory=True)
 
 
 
 
 
 

+ 13 - 2
tasks/AreaBoss/assets.py

@@ -10,6 +10,13 @@ from module.atom.list import RuleList
 class AreaBossAssets: 
 class AreaBossAssets: 
 
 
 
 
+	# Click Rule Assets
+	# 热门按钮 
+	C_AB_FAMOUS_BTN = RuleClick(roi_front=(1190,220,50,120), roi_back=(1190,220,50,120), name="ab_famous_btn")
+	# 收藏按钮 
+	C_AB_COLLECTION_BTN = RuleClick(roi_front=(1190,580,50,120), roi_back=(1190,580,50,120), name="ab_collection_btn")
+
+
 	# Image Rule Assets
 	# Image Rule Assets
 	# 探索图标 
 	# 探索图标 
 	I_EXPLORE = RuleImage(roi_front=(758,122,66,77), roi_back=(339,104,836,120), threshold=0.8, method="Template matching", file="./tasks/AreaBoss/res/res_explore.png")
 	I_EXPLORE = RuleImage(roi_front=(758,122,66,77), roi_back=(339,104,836,120), threshold=0.8, method="Template matching", file="./tasks/AreaBoss/res/res_explore.png")
@@ -31,6 +38,10 @@ class AreaBossAssets:
 	I_CLOSE_RED = RuleImage(roi_front=(1190,24,37,38), roi_back=(1190,24,37,38), threshold=0.8, method="Template matching", file="./tasks/AreaBoss/res/res_close_red.png")
 	I_CLOSE_RED = RuleImage(roi_front=(1190,24,37,38), roi_back=(1190,24,37,38), threshold=0.8, method="Template matching", file="./tasks/AreaBoss/res/res_close_red.png")
 	# 红色关闭 
 	# 红色关闭 
 	I_AB_CLOSE_RED = RuleImage(roi_front=(1194,24,38,37), roi_back=(1194,24,38,37), threshold=0.8, method="Template matching", file="./tasks/AreaBoss/res/res_ab_close_red.png")
 	I_AB_CLOSE_RED = RuleImage(roi_front=(1194,24,38,37), roi_back=(1194,24,38,37), threshold=0.8, method="Template matching", file="./tasks/AreaBoss/res/res_ab_close_red.png")
+	# 筛选中 选中收藏标识 
+	I_AB_FILTER_TITLE_COLLECTION = RuleImage(roi_front=(940,110,170,70), roi_back=(940,110,170,70), threshold=0.8, method="Template matching", file="./tasks/AreaBoss/res/ab_filter_title_collection.png")
+	# 筛选界面打开标识 
+	I_AB_FILTER_OPENED = RuleImage(roi_front=(840,110,130,70), roi_back=(840,110,130,70), threshold=0.8, method="Template matching", file="./tasks/AreaBoss/res/ab_filter_opened.png")
 
 
 
 
 	# Ocr Rule Assets
 	# Ocr Rule Assets
@@ -39,8 +50,8 @@ class AreaBossAssets:
 	# 我的收藏 
 	# 我的收藏 
 	O_AB_MY_COLLECT = RuleOcr(roi=(949,124,129,53), area=(949,124,129,53), mode="Single", method="Default", keyword="我的收藏", name="ab_my_collect")
 	O_AB_MY_COLLECT = RuleOcr(roi=(949,124,129,53), area=(949,124,129,53), mode="Single", method="Default", keyword="我的收藏", name="ab_my_collect")
 	# 热门 
 	# 热门 
-	O_AB_FAMOUS = RuleOcr(roi=(1188,181,78,82), area=(1188,181,78,82), mode="Single", method="Default", keyword="热门", name="ab_famous")
+	O_AB_FAMOUS = RuleOcr(roi=(1190,220,50,120), area=(1190,220,50,120), mode="Single", method="Default", keyword="热门", name="ab_famous")
 	# 收藏 
 	# 收藏 
-	O_AB_COLLECTING = RuleOcr(roi=(1163,522,88,100), area=(1163,522,88,100), mode="Single", method="Default", keyword="收藏", name="ab_collecting")
+	O_AB_COLLECTING = RuleOcr(roi=(1190,580,50,120), area=(1190,580,50,120), mode="Single", method="Default", keyword="收藏", name="ab_collecting")
 
 
 
 

+ 14 - 0
tasks/AreaBoss/click.json

@@ -0,0 +1,14 @@
+[
+  {
+    "itemName": "ab_famous_btn",
+    "roiFront": "1190,220,50,120",
+    "roiBack": "1190,220,50,120",
+    "description": "热门按钮"
+  },
+  {
+    "itemName": "ab_collection_btn",
+    "roiFront": "1190,580,50,120",
+    "roiBack": "1190,580,50,120",
+    "description": "收藏按钮"
+  }
+]

BIN
tasks/AreaBoss/res/ab_filter_opened.png


BIN
tasks/AreaBoss/res/ab_filter_title_collection.png


+ 18 - 0
tasks/AreaBoss/res/image.json

@@ -88,5 +88,23 @@
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "红色关闭"
     "description": "红色关闭"
+  },
+  {
+    "itemName": "ab_filter_title_collection",
+    "imageName": "ab_filter_title_collection.png",
+    "roiFront": "940,110,170,70",
+    "roiBack":  "940,110,170,70",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "筛选中 选中收藏标识"
+  },
+  {
+    "itemName": "ab_filter_opened",
+    "imageName": "ab_filter_opened.png",
+    "roiFront": "840,110,130,70",
+    "roiBack":  "840,110,130,70",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "筛选界面打开标识"
   }
   }
 ]
 ]

+ 4 - 4
tasks/AreaBoss/res/ocr.json

@@ -19,8 +19,8 @@
   },
   },
   {
   {
     "itemName": "ab_famous",
     "itemName": "ab_famous",
-    "roiFront": "1188,181,78,82",
-    "roiBack": "1188,181,78,82",
+    "roiFront": "1190,220,50,120",
+    "roiBack": "1190,220,50,120",
     "mode": "Single",
     "mode": "Single",
     "method": "Default",
     "method": "Default",
     "keyword": "热门",
     "keyword": "热门",
@@ -28,8 +28,8 @@
   },
   },
   {
   {
     "itemName": "ab_collecting",
     "itemName": "ab_collecting",
-    "roiFront": "1163,522,88,100",
-    "roiBack": "1163,522,88,100",
+    "roiFront": "1190,580,50,120",
+    "roiBack": "1190,580,50,120",
     "mode": "Single",
     "mode": "Single",
     "method": "Default",
     "method": "Default",
     "keyword": "收藏",
     "keyword": "收藏",

+ 16 - 7
tasks/AreaBoss/script_task.py

@@ -3,6 +3,7 @@
 # github https://github.com/runhey
 # github https://github.com/runhey
 import time
 import time
 
 
+import cv2
 from tasks.base_task import BaseTask
 from tasks.base_task import BaseTask
 from tasks.Component.GeneralBattle.general_battle import GeneralBattle
 from tasks.Component.GeneralBattle.general_battle import GeneralBattle
 from tasks.GameUi.game_ui import GameUi
 from tasks.GameUi.game_ui import GameUi
@@ -71,26 +72,33 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, AreaBossAssets):
             if self.appear(self.I_CHECK_MAIN, threshold=0.6):
             if self.appear(self.I_CHECK_MAIN, threshold=0.6):
                 break
                 break
 
 
-    def boss(self, battle: RuleImage, collect: bool=False):
-        def switch_collect():
+    def boss(self, battle: RuleImage, collect: bool = False):
+        def switch2mycollect():
             while 1:
             while 1:
                 self.screenshot()
                 self.screenshot()
-                if self.ocr_appear(self.O_AB_MY_COLLECT):
+                if self.appear(self.I_AB_FILTER_TITLE_COLLECTION):
                     break
                     break
-                if self.ocr_appear_click(self.O_AB_COLLECTING, interval=1):
+                if self.appear(self.I_AB_FILTER_OPENED):
+                    self.click(self.C_AB_COLLECTION_BTN, 1.5)
                     continue
                     continue
 
 
         # 点击右上角的鬼王选择
         # 点击右上角的鬼王选择
         logger.info("Script filter")
         logger.info("Script filter")
         while 1:
         while 1:
             self.screenshot()
             self.screenshot()
-            if self.appear(self.I_BATTLE_1) or self.appear(self.I_BATTLE_2) or self.appear(self.I_BATTLE_3):
+            # 如果筛选界面已经打开 点击热门按钮
+            if self.appear(self.I_AB_FILTER_OPENED):
+                self.click(self.C_AB_FAMOUS_BTN)
                 break
                 break
-            if self.appear_then_click(self.I_FILTER, interval=2):
+            if self.appear_then_click(self.I_FILTER, interval=3):
                 continue
                 continue
 
 
         if collect:
         if collect:
-            switch_collect()
+            switch2mycollect()
+        # 页面没有可挑战的BOSS
+        if not (self.appear(self.I_BATTLE_1) or self.appear(self.I_BATTLE_2) or self.appear(self.I_BATTLE_3)):
+            logger.error("There is no boss could be challenged")
+            return
         # 点击第几个鬼王
         # 点击第几个鬼王
         logger.info(f'Script area boss {battle}')
         logger.info(f'Script area boss {battle}')
         self.ui_click(battle, self.I_AB_CLOSE_RED)
         self.ui_click(battle, self.I_AB_CLOSE_RED)
@@ -109,6 +117,7 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, AreaBossAssets):
         self.wait_until_appear(self.I_AB_CLOSE_RED)
         self.wait_until_appear(self.I_AB_CLOSE_RED)
         self.ui_click(self.I_AB_CLOSE_RED, self.I_FILTER)
         self.ui_click(self.I_AB_CLOSE_RED, self.I_FILTER)
 
 
+
 if __name__ == '__main__':
 if __name__ == '__main__':
     from module.config.config import Config
     from module.config.config import Config
     from module.device.device import Device
     from module.device.device import Device

+ 3 - 3
tasks/BondlingFairyland/script_task.py

@@ -377,11 +377,11 @@ class ScriptTask(GameUi, BondlingBattle, SwitchSoul, BondlingFairylandAssets):
             self.screenshot()
             self.screenshot()
             if self.appear(self.I_CLICK_CAPTION):
             if self.appear(self.I_CLICK_CAPTION):
                 return True
                 return True
-            if click_count >= 4:
+            if click_count >= 5:
                 return False
                 return False
             # 点击
             # 点击
-            self.click(click_target, interval=1)
-            click_count += 1
+            if self.click(click_target, interval=1):
+                click_count += 1
 
 
 
 
     def capture_setting(self, mode: BondlingMode) -> None:
     def capture_setting(self, mode: BondlingMode) -> None:

+ 107 - 0
tasks/Dokan/assets.py

@@ -0,0 +1,107 @@
+from module.atom.image import RuleImage
+from module.atom.click import RuleClick
+from module.atom.long_click import RuleLongClick
+from module.atom.swipe import RuleSwipe
+from module.atom.ocr import RuleOcr
+from module.atom.list import RuleList
+
+# This file was automatically generated by ./dev_tools/assets_extract.py.
+# Don't modify it manually.
+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")
+	# 道馆随机点击安全区域1:竂友突破信息 
+	C_DOKAN_RANDOM_CLICK_AREA1 = RuleClick(roi_front=(42,594,10,100), roi_back=(42,594,10,100), 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_READY_FOR_BATTLE = RuleClick(roi_front=(42,94,1207,543), roi_back=(42,94,1207,543), name="dokan_ready_for_battle")
+
+
+	# 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_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_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_ATTACK_PRIORITY = 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_attack_priority.png")
+	# 优先攻击: 见习 
+	I_RYOU_DOKAN_ATTACK_PRIORITY_0 = RuleImage(roi_front=(98,170,94,43), roi_back=(98,170,94,43), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_attack_priority_0.png")
+	# 优先攻击: 初级 
+	I_RYOU_DOKAN_ATTACK_PRIORITY_1 = RuleImage(roi_front=(342,175,96,42), roi_back=(342,175,96,42), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_attack_priority_1.png")
+	# 优先攻击: 中级 
+	I_RYOU_DOKAN_ATTACK_PRIORITY_2 = RuleImage(roi_front=(585,175,89,35), roi_back=(585,175,89,35), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_attack_priority_2.png")
+	# 优先攻击: 高级 
+	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_attack_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_attack_priority_4.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")
+	# 状态:达到失败次数,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_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_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_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_CHEERING = RuleImage(roi_front=(68,597,69,33), roi_back=(68,597,69,33), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_cheering.png")
+	# 状态:加油中,左下角有鼓,灰色的鼓 
+	I_RYOU_DOKAN_CHEERING_GRAY = RuleImage(roi_front=(59,600,81,38), roi_back=(59,600,81,38), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_cheering_gray.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_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")
+	# 进入加油相关:道馆战报按钮 
+	I_RYOU_DOKAN_CHEERING_SCORES = RuleImage(roi_front=(157,100,35,39), roi_back=(157,100,35,39), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_cheering_scores.png")
+	# 进入加油相关:前往战斗中的竂友 
+	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")
+
+
+	# List Rule Assets
+	# 这个是当前活跃的竂活动列表界面 
+	L_LAYER_LIST = RuleList(folder="./tasks/Dokan/res", direction="vertical", mode="ocr", roi_back=(35,157,37,250), size=(42, 27), 
+					 array=["道馆", "首领", "狭间"])
+
+
+	# Ocr Rule Assets
+	# 道馆地图里找文字:万 
+	O_DOKAN_MAP = RuleOcr(roi=(1122,546,92,51), area=(1122,546,92,51), mode="Full", method="Default", keyword="万", name="dokan_map")
+	# 道馆里找文字:后开战 
+	O_DOKAN_GATHERING = RuleOcr(roi=(535,75,211,29), area=(535,75,211,29), mode="Single", method="Default", keyword="开战", name="dokan_gathering")
+	# 道馆里找文字:剩余突破时间 
+	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=(1122,546,92,51), area=(1122,546,92,51), mode="Full", method="Default", keyword="关闭", name="dokan_succeeded")
+
+

+ 38 - 0
tasks/Dokan/config.py

@@ -0,0 +1,38 @@
+# This Python file uses the following encoding: utf-8
+# @brief    Configurations for Ryou Dokan Toppa (阴阳竂道馆突破配置)
+# @author   jackyhwei
+# @note     draft version without full test
+# github    https://github.com/roarhill/oas
+
+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_scheduler import Scheduler
+
+
+
+class DokanConfig(BaseModel):
+    # # 寮管理开启道馆
+    # dokan_declare_war: bool = Field(default=False, description='dokan_declare_war_help')
+    # # 选择哪一个竂
+    # dokan_declear_war_priority: int = Field(default=0, description='dokan_declear_war_priority_help')
+
+    # 攻击优先顺序: 见习=0,初级=1...
+    dokan_attack_priority: int = Field(default=0, description='dokan_attack_priority_help')
+
+    # 失败CD后自动加油
+    dokan_auto_cheering_while_cd: bool = Field(default=False, description='dokan_auto_cheering_while_cd_help')
+
+    # 正式进攻会设定 2s - 10s 的随机延迟,避免攻击间隔及其相近被检测为脚本。
+    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')
+
+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)

+ 32 - 0
tasks/Dokan/res/click.json

@@ -0,0 +1,32 @@
+[
+  {
+    "itemName": "dokan_random_click_area",
+    "roiFront": "142,294,107,555",
+    "roiBack": "142,294,107,555",
+    "description": "道馆随机点击安全区域"
+  },
+  {
+    "itemName": "dokan_random_click_area1",
+    "roiFront": "42,594,10,100",
+    "roiBack": "42,594,10,100",
+    "description": "道馆随机点击安全区域1:竂友突破信息"
+  },
+  {
+    "itemName": "dokan_random_click_area2",
+    "roiFront": "1122,360,10,40",
+    "roiBack": "1122,360,10,40",
+    "description": "道馆随机点击安全区域2:切换查看队伍模式"
+  },
+  {
+    "itemName": "dokan_random_click_area3",
+    "roiFront": "333,44,107,20",
+    "roiBack": "333,44,107,20",
+    "description": "道馆随机点击安全区域3"
+  },
+  {
+    "itemName": "dokan_ready_for_battle",
+    "roiFront": "42,94,1207,543",
+    "roiBack": "42,94,1207,543",
+    "description": "准备战斗"
+  }
+]

BIN
tasks/Dokan/res/dokan_attacking.png


BIN
tasks/Dokan/res/gb_prepare_dark.png


BIN
tasks/Dokan/res/gb_prepare_highlight.png


+ 282 - 0
tasks/Dokan/res/image.json

@@ -0,0 +1,282 @@
+[
+  {
+    "itemName": "ryou_shenshe",
+    "imageName": "res_ryou_shenshe.png",
+    "roiFront": "476,173,62,24",
+    "roiBack": "476,173,62,24",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "阴阳竂->神社"
+  },
+  {
+    "itemName": "ryou_dokan",
+    "imageName": "res_ryou_dokan.png",
+    "roiFront": "476,173,62,24",
+    "roiBack": "476,173,62,24",
+    "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",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "[]选择竂"
+  },
+  {
+    "itemName": "ryou_dokan_ryou_list",
+    "imageName": "res_ryou_dokan_ryou_list.png",
+    "roiFront": "567,15,144,42",
+    "roiBack": "567,15,144,42",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "可选的竂列表"
+  },
+  {
+    "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": "是否已经成功进入道馆,上面中间的“道馆突破”文字"
+  },
+  {
+    "itemName": "ryou_dokan_attack_priority",
+    "imageName": "res_ryou_dokan_attack_priority.png",
+    "roiFront": "567,15,144,42",
+    "roiBack": "567,15,144,42",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "优先攻击选项"
+  },
+  {
+    "itemName": "ryou_dokan_attack_priority_0",
+    "imageName": "res_ryou_dokan_attack_priority_0.png",
+    "roiFront": "98,170,94,43",
+    "roiBack": "98,170,94,43",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "优先攻击: 见习"
+  },
+  {
+    "itemName": "ryou_dokan_attack_priority_1",
+    "imageName": "res_ryou_dokan_attack_priority_1.png",
+    "roiFront": "342,175,96,42",
+    "roiBack": "342,175,96,42",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "优先攻击: 初级"
+  },
+  {
+    "itemName": "ryou_dokan_attack_priority_2",
+    "imageName": "res_ryou_dokan_attack_priority_2.png",
+    "roiFront": "585,175,89,35",
+    "roiBack": "585,175,89,35",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "优先攻击: 中级"
+  },
+  {
+    "itemName": "ryou_dokan_attack_priority_3",
+    "imageName": "res_ryou_dokan_attack_priority_3.png",
+    "roiFront": "830,175,88,41",
+    "roiBack": "830,175,88,41",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "优先攻击: 高级"
+  },
+  {
+    "itemName": "ryou_dokan_attack_priority_4",
+    "imageName": "res_ryou_dokan_attack_priority_4.png",
+    "roiFront": "1072,178,94,39",
+    "roiBack": "1072,178,94,39",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "优先攻击: 黑脸"
+  },
+
+
+  {
+    "itemName": "ryou_dokan_gathering",
+    "imageName": "res_ryou_dokan_gathering.png",
+    "roiFront": "653,76,46,26",
+    "roiBack": "653,76,46,26",
+    "method": "Template matching",
+    "threshold": 0.85,
+    "description": "状态:集结等待中。检查右下角的挑战是不是灰色的。FIXME 黄色和灰色的挑战截图总是傻傻分不清,先改用OCR"
+  },
+  {
+    "itemName": "ryou_dokan_start_challenge",
+    "imageName": "res_ryou_dokan_start_challenge.png",
+    "roiFront": "1132,572,89,43",
+    "roiBack": "1132,572,89,43",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "状态:检查右下角有没有挑战?通常是失败了,并退出来到集结界面,可重新开始点击右下角挑战进入战斗"
+  },
+  {
+    "itemName": "ryou_dokan_cd1",
+    "imageName": "res_ryou_dokan_cd1.png",
+    "roiFront": "1068,500,146,27",
+    "roiBack": "1068,500,146,27",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "状态:达到失败次数,CD中。挑战次数恢复倒数"
+  },
+  {
+    "itemName": "ryou_dokan_cd",
+    "imageName": "res_ryou_dokan_cd.png",
+    "roiFront": "1122,566,117,74",
+    "roiBack": "1122,566,117,74",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "状态:达到失败次数,CD中。观战按钮"
+  },
+  {
+    "itemName": "ryou_dokan_in_field",
+    "imageName": "res_ryou_dokan_in_field.png",
+    "roiFront": "1128,536,100,100",
+    "roiBack": "1128,536,100,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "状态:进入战斗,待开始,右下角图标。TODO 欠截图。"
+  },
+  {
+    "itemName": "dokan_boss_waiting",
+    "imageName": "res_dokan_boss_waiting.png",
+    "roiFront": "603,148,130,32",
+    "roiBack": "603,148,130,32",
+    "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",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "状态:道馆胜利"
+  },
+
+  {
+    "itemName": "ryou_dokan_in_field2",
+    "imageName": "res_ryou_dokan_in_field2.png",
+    "roiFront": "1131,562,88,48",
+    "roiBack": "1131,562,88,48",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "状态:进入战斗,待开始,右下角图标。"
+  },
+  {
+    "itemName": "ryou_dokan_battle_over",
+    "imageName": "res_ryou_dokan_battle_over.png",
+    "roiFront": "571,503,106,49",
+    "roiBack": "571,503,106,49",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "状态:战斗结算,可能是打完小朋友了,也可能是失败了。"
+  },
+
+  {
+    "itemName": "ryou_dokan_fighting",
+    "imageName": "res_ryou_dokan_fighting.png",
+    "roiFront": "232,36,42,19",
+    "roiBack": "232,36,42,19",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "状态:战斗中,左上角的加油图标"
+  },
+  {
+    "itemName": "ryou_dokan_cheering",
+    "imageName": "res_ryou_dokan_cheering.png",
+    "roiFront": "68,597,69,33",
+    "roiBack": "68,597,69,33",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "状态:加油中,左下角有鼓"
+  },
+  {
+    "itemName": "ryou_dokan_cheering_gray",
+    "imageName": "res_ryou_dokan_cheering_gray.png",
+    "roiFront": "59,600,81,38",
+    "roiBack": "59,600,81,38",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "状态:加油中,左下角有鼓,灰色的鼓"
+  },
+  {
+    "itemName": "ryou_dokan_finished",
+    "imageName": "res_ryou_dokan_finished.png",
+    "roiFront": "658,649,91,27",
+    "roiBack": "658,649,91,27",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "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",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "状态:道馆挑战失败,投票NO"
+  },
+  {
+    "itemName": "ryou_dokan_exit_ensure",
+    "imageName": "res_ryou_dokan_exit_ensure.png",
+    "roiFront": "678,395,125,56",
+    "roiBack": "678,395,125,56",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "道馆退出确认"
+  },
+
+  
+  {
+    "itemName": "ryou_dokan_cheering_scores",
+    "imageName": "res_ryou_dokan_cheering_scores.png",
+    "roiFront": "157,100,35,39",
+    "roiBack": "157,100,35,39",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "进入加油相关:道馆战报按钮"
+  },
+  {
+    "itemName": "ryou_dokan_cheering_attacking_sama",
+    "imageName": "res_ryou_dokan_cheering_attacking_sama.png",
+    "roiFront": "948,182,56,295",
+    "roiBack": "948,182,56,295",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "进入加油相关:前往战斗中的竂友"
+  },
+
+
+  {
+    "itemName": "scene_ryou",
+    "imageName": "scene_ryou.png",
+    "roiFront": "1161,674,75,31",
+    "roiBack": "1161,674,75,31",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "场景检测:阴阳竂"
+  },
+  {
+    "itemName": "scene_ryou",
+    "imageName": "scene_ryou.png",
+    "roiFront": "1161,674,75,31",
+    "roiBack": "1161,674,75,31",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "场景检测:阴阳竂"
+  }
+
+]

+ 23 - 0
tasks/Dokan/res/list.json

@@ -0,0 +1,23 @@
+{
+    "name": "layer_list",
+    "direction": "vertical",
+    "type": "ocr",
+    "roiBack": "35,157,37,250",
+    "description": "这个是当前活跃的竂活动列表界面",
+    "list": [
+      {
+        "itemName": "道馆",
+        "roiFront": "33,253,42,26"
+      },
+      {
+        "itemName": "首领",
+        "roiFront": "34,433,43,28",
+        "description": "首领退治"
+      },
+      {
+        "itemName": "狭间",
+        "roiFront": "34,523,43,28",
+        "description": "狭间暗域"
+      }
+    ]
+  }

+ 48 - 0
tasks/Dokan/res/ocr.json

@@ -0,0 +1,48 @@
+[
+  {
+    "itemName": "dokan_map",
+    "roiFront": "1122,546,92,51",
+    "roiBack": "1122,546,92,51",
+    "mode": "Full",
+    "method": "Default",
+    "keyword": "万",
+    "description": "道馆地图里找文字:万"
+  },
+  {
+    "itemName": "dokan_gathering",
+    "roiFront": "535,75,211,29",
+    "roiBack": "535,75,211,29",
+    "mode": "Single",
+    "method": "Default",
+    "keyword": "开战",
+    "description": "道馆里找文字:后开战"
+  },
+  {
+    "itemName": "dokan_attacking",
+    "roiFront": "1122,546,92,51",
+    "roiBack": "1122,546,92,51",
+    "mode": "Single",
+    "method": "Default",
+    "keyword": "剩余",
+    "description": "道馆里找文字:剩余突破时间"
+  },
+  {
+    "itemName": "dokan_boss_waiting",
+    "roiFront": "603,148,130,32",
+    "roiBack": "603,148,130,32",
+    "mode": "Single",
+    "method": "Default",
+    "keyword": "馆主",
+    "description": "道馆里找文字:后挑战馆主"
+  },
+  {
+    "itemName": "dokan_succeeded",
+    "roiFront": "1122,546,92,51",
+    "roiBack": "1122,546,92,51",
+    "mode": "Full",
+    "method": "Default",
+    "keyword": "关闭",
+    "description": "道馆里找文字:后关闭"
+  }
+
+]

BIN
tasks/Dokan/res/res_dokan_boss_waiting.png


BIN
tasks/Dokan/res/res_ryou_dokan.png


BIN
tasks/Dokan/res/res_ryou_dokan_battle_over.png


BIN
tasks/Dokan/res/res_ryou_dokan_cd.png


BIN
tasks/Dokan/res/res_ryou_dokan_cd1.png


BIN
tasks/Dokan/res/res_ryou_dokan_check.png


BIN
tasks/Dokan/res/res_ryou_dokan_cheering.png


BIN
tasks/Dokan/res/res_ryou_dokan_cheering_attacking_sama.png


BIN
tasks/Dokan/res/res_ryou_dokan_cheering_gray.png


BIN
tasks/Dokan/res/res_ryou_dokan_cheering_scores.png


BIN
tasks/Dokan/res/res_ryou_dokan_exit_ensure.png


BIN
tasks/Dokan/res/res_ryou_dokan_failed_vote_no.png.png


BIN
tasks/Dokan/res/res_ryou_dokan_fighting.png


BIN
tasks/Dokan/res/res_ryou_dokan_finished.png


BIN
tasks/Dokan/res/res_ryou_dokan_gathering.png


BIN
tasks/Dokan/res/res_ryou_dokan_in_field.png


BIN
tasks/Dokan/res/res_ryou_dokan_in_field2.png


BIN
tasks/Dokan/res/res_ryou_dokan_priority.png


BIN
tasks/Dokan/res/res_ryou_dokan_priority_0.png


BIN
tasks/Dokan/res/res_ryou_dokan_priority_1.png


BIN
tasks/Dokan/res/res_ryou_dokan_priority_2.png


BIN
tasks/Dokan/res/res_ryou_dokan_priority_3.png


BIN
tasks/Dokan/res/res_ryou_dokan_priority_4.png


BIN
tasks/Dokan/res/res_ryou_dokan_start_challenge.png


BIN
tasks/Dokan/res/res_ryou_dokan_start_challenge2.png


BIN
tasks/Dokan/res/res_ryou_dokan_win.png


BIN
tasks/Dokan/res/res_ryou_shenshe.png


BIN
tasks/Dokan/res/scene_ryou.png


+ 525 - 0
tasks/Dokan/script_task.py

@@ -0,0 +1,525 @@
+# This Python file uses the following encoding: utf-8
+# @brief    Ryou Dokan Toppa (阴阳竂道馆突破功能)
+# @author   jackyhwei
+# @note     draft version without full test
+# github    https://github.com/roarhill/oas
+import time
+import random
+import numpy as np
+from enum import Enum
+from cached_property import cached_property
+
+from tasks.Component.GeneralBattle.config_general_battle import GeneralBattleConfig
+from tasks.Component.SwitchSoul.switch_soul import SwitchSoul
+from tasks.Component.GeneralBattle.general_battle import GeneralBattle
+from tasks.Component.config_base import ConfigBase, Time
+from tasks.GameUi.game_ui import GameUi
+from tasks.GameUi.page import page_main, page_kekkai_toppa, page_shikigami_records, page_guild
+from tasks.RealmRaid.assets import RealmRaidAssets
+
+from module.logger import logger
+from module.exception import TaskEnd
+from module.atom.image_grid import ImageGrid
+from module.base.utils import point2str
+from module.base.timer import Timer
+from module.exception import GamePageUnknownError
+
+from tasks.Dokan.config import DokanConfig, Dokan
+from tasks.Dokan.assets import DokanAssets
+from tasks.Dokan.utils import detect_safe_area2
+
+
+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_CHEERING = 6
+    # 道馆失败投票保留
+    RYOU_DOKAN_SCENE_FAILED_VOTE_NO = 7
+    # 阴阳竂
+    RYOU_DOKAN_RYOU = 8
+    # 战斗结算,可能是打完小朋友了,也可能是失败了。
+    RYOU_DOKAN_SCENE_BATTLE_OVER = 9
+    # 等待BOSS战
+    RYOU_DOKAN_SCENE_BOSS_WAITING = 10
+    # 道馆结束
+    RYOU_DOKAN_SCENE_FINISHED = 99
+
+    def __str__(self):
+        return self.name.title()
+
+    def print(self):
+        print(DokanScene.RYOU_DOKAN_SCENE_GATHERING)  # 输出: DokanScene.Ryou_Daoguan_Scene_Gathering
+        print(DokanScene.RYOU_DOKAN_SCENE_CD.value)  # 输出: 2
+        print(str(DokanScene.RYOU_DOKAN_SCENE_FIGHTING))  # 输出: Ryou_Daoguan_Scene_Fighting
+
+
+class ScriptTask(GeneralBattle, GameUi, SwitchSoul, DokanAssets):
+    medal_grid: ImageGrid = None
+    attack_priority_selected: bool = False
+    team_switched: bool = False
+    green_mark_done: bool = False
+
+    @cached_property
+    def _attack_priorities(self) -> list:
+        return [self.I_RYOU_DOKAN_PRIORITY_0,
+                self.I_RYOU_DOKAN_PRIORITY_1,
+                self.I_RYOU_DOKAN_PRIORITY_2,
+                self.I_RYOU_DOKAN_PRIORITY_3,
+                self.I_RYOU_DOKAN_PRIORITY_4]
+
+    def run(self):
+        """ 道馆主函数
+
+        :return:
+        """
+        cfg: Dokan = self.config.dokan
+        current_scene: DokanScene = DokanScene.RYOU_DOKAN_SCENE_UNKNOWN
+        in_dokan: bool = False
+
+        # 攻击优先顺序
+        attack_priority: int = cfg.dokan_config.dokan_attack_priority
+
+        # 自动换御魂
+        if cfg.switch_soul_config.enable:
+            self.ui_get_current_page()
+            self.ui_goto(page_shikigami_records)
+            self.run_switch_soul(cfg.switch_soul_config.switch_group_team)
+        if cfg.switch_soul_config.enable_switch_by_name:
+            self.ui_get_current_page()
+            self.ui_goto(page_shikigami_records)
+            self.run_switch_soul_by_name(cfg.switch_soul_config.group_name, cfg.switch_soul_config.team_name)
+
+        success = True
+        scene_err_count = 0
+
+        # 在阴阳竂界面点击并进入道馆
+        # 检测当前界面的场景(时间关系,暂时没有做庭院、町中等主界面的场景检测, 应考虑在GameUI.game_ui.ui_get_current_page()里实现)
+        in_dokan, current_scene = self.get_current_scene(True)
+
+        if not in_dokan:
+            self.ui_get_current_page()
+            self.ui_goto(page_guild)
+
+            self.goto_dokan()
+
+        # 开始道馆流程
+        while 1:
+            self.screenshot()
+
+            # 检测当前界面的场景(时间关系,暂时没有做庭院、町中等主界面的场景检测, 应考虑在GameUI.game_ui.ui_get_current_page()里实现)
+            in_dokan, current_scene = self.get_current_scene(True)
+
+            logger.info(f"in_dokan={in_dokan}, current_scene={current_scene}")
+
+            # 如果当前不在道馆,或者被人工操作退出道馆了,重新尝试进入道馆
+            if not in_dokan:
+                scene_err_count += 1
+                logger.info(f"err count={scene_err_count}")
+                if scene_err_count >= 3:
+                    self.goto_dokan()
+                # 先点击一下,然后等5秒再重新截图
+                self.anti_detect(True, True, False)
+                time.sleep(5)
+                continue
+            else:
+                scene_err_count = 0
+
+            # 场景状态:道馆集结中
+            if current_scene == DokanScene.RYOU_DOKAN_SCENE_GATHERING:
+                logger.debug(f"Ryou DOKAN gathering, 集结中...")
+                # 如果还未选择优先攻击,选一下
+                if not self.attack_priority_selected:
+                    self.dokan_choose_attack_priority(attack_priority=attack_priority)
+                    self.attack_priority_selected = True
+            # 场景状态:等待馆主战开始
+            elif current_scene == DokanScene.RYOU_DOKAN_SCENE_BOSS_WAITING:
+                logger.debug(f"Ryou DOKAN boss battle waiting...")
+            # 场景状态:检查右下角有没有挑战?通常是失败了,并退出来到集结界面,可重新开始点击右下角挑战进入战斗
+            elif current_scene == DokanScene.RYOU_DOKAN_SCENE_START_CHALLENGE:
+                self.appear_then_click(self.I_RYOU_DOKAN_START_CHALLENGE)
+            # 场景状态:进入战斗,待开始
+            elif current_scene == DokanScene.RYOU_DOKAN_SCENE_IN_FIELD:
+                # 战斗
+                success = self.dokan_battle(cfg)
+                # 战斗结束后,随便点三下,确保跳过各种结算画面
+                self.click(click=self.C_DOKAN_READY_FOR_BATLLE, interval=1.5)
+                self.click(click=self.C_DOKAN_RANDOM_CLICK_AREA2, interval=2.2)
+                self.click(click=self.C_DOKAN_RANDOM_CLICK_AREA3, interval=1.8)
+                # 每次战斗结束都重置绿标
+                self.green_mark_done = False
+            # 场景状态:如果CD中,开始加油
+            elif current_scene == DokanScene.RYOU_DOKAN_SCENE_CD:
+                logger.info(f"CD中,是否加油:{cfg.dokan_config.dokan_auto_cheering_while_cd}..")
+                if cfg.dokan_config.dokan_auto_cheering_while_cd:
+                    self.start_cheering()
+            # 场景状态:战斗中,左上角的加油图标
+            elif current_scene == DokanScene.RYOU_DOKAN_SCENE_FIGHTING:
+                logger.info("战斗进行中")
+            # 场景状态:加油中
+            elif current_scene == DokanScene.RYOU_DOKAN_SCENE_CHEERING:
+                self.appear_then_click(self.I_RYOU_DOKAN_CHEERING)
+            # 场景状态:道馆已经结束
+            elif current_scene == DokanScene.RYOU_DOKAN_SCENE_FINISHED:
+                logger.info("道馆已经结束,退出")
+                break
+            elif current_scene == DokanScene.RYOU_DOKAN_SCENE_FAILED_VOTE_NO:
+                logger.info("道馆挑战失败:投票保留")
+            else:
+                logger.info(f"unknown scene, skipped")
+
+            # 防封,随机移动,随机点击(安全点击),随机时延
+            if not self.anti_detect(True, True, True):
+                time.sleep(1)
+
+        # 保持好习惯,一个任务结束了就返回到庭院,方便下一任务的开始
+        self.goto_main()
+
+        # 设置下次运行时间
+        if success:
+            self.set_next_run(task='Dokan', finish=True, server=True, success=True)
+        else:
+            self.set_next_run(task='Dokan', finish=True, server=True, success=False)
+        raise TaskEnd
+
+    def dokan_battle(self, cfg: Dokan):
+        """ 道馆战斗
+        道馆集结结束后会自动进入战斗,打完一个也会自动进入下一个,因此直接点击右下角的开始
+
+        :return: 战斗成功(True) or 战斗失败(False) or 区域不可用(False)
+        """
+        config: GeneralBattleConfig = cfg.general_battle_config
+
+        # 正式进攻会设定 2s - 10s 的随机延迟,避免攻击间隔及其相近被检测为脚本。
+        if cfg.dokan_config.random_delay:
+            self.anti_detect(False, False, True)
+
+        # 上面可能睡了一觉,重新截图
+        self.screenshot()
+
+        # 更换队伍
+        if not self.team_switched:
+            logger.info(
+                f"更换队伍: config.preset_enable={config.preset_enable}, config.preset_group={config.preset_group}, config.preset_team={config.preset_team}")
+            self.switch_preset_team(config.preset_enable, config.preset_group, config.preset_team)
+            self.team_switched = True
+            # 切完队伍后有时候会卡顿,先睡一觉,防止快速跳到绿标流程,导致未能成功绿标
+            time.sleep(3)
+
+        # 等待准备按钮的出现
+        logger.debug("等待准备按钮的出现")
+        self.wait_until_appear(self.I_PREPARE_HIGHLIGHT)
+
+        # 点击准备
+        if self.appear_then_click(self.I_PREPARE_HIGHLIGHT, interval=1.5):
+            logger.info("点击准备")
+
+            # 绿标式神, should we check there's a green marked role?
+            if not self.green_mark_done and self.is_in_battle(False):
+                logger.info(
+                    f"绿标式神:config.green_enable={config.green_enable}, config.green_mark={config.green_mark}")
+                self.green_mark(config.green_enable, config.green_mark)
+                self.green_mark_done = True
+
+        # 等待战斗结果
+        logger.info(f"等待战斗结果:config.random_click_swipt_enable={config.random_click_swipt_enable}")
+        logger.info("come on baby, let's go.")
+
+        while 1:
+            # logger.info("take a nap")
+            time.sleep(1)
+
+            self.device.stuck_record_add('BATTLE_STATUS_S')
+            self.device.click_record_clear()
+
+            self.screenshot()
+
+            # 如果出现赢 就点击
+            if self.appear(GeneralBattle.I_WIN, threshold=0.8):
+                logger.info("道馆的小朋友们打完了,boss is on the way")
+                win = True
+                break
+
+            # 如果出现打败馆主的赢,就点击
+            if self.appear(self.I_RYOU_DOKAN_WIN, threshold=0.8):
+                logger.info("We've defeated the boss, and win the final game.")
+                win = True
+                break
+
+            # 如果出现失败 就点击,返回False。 TODO 不知道挑战馆主失败是不是同一个画面?
+            if self.appear(GeneralBattle.I_FALSE, threshold=0.8):
+                logger.info("Battle failed")
+                win = False
+                break
+
+            # 如果领奖励
+            if self.appear(self.I_RYOU_DOKAN_BATTLE_OVER, threshold=0.6):
+                logger.info("Battle over")
+                win = True
+                break
+
+            # 如果领奖励出现金币
+            if self.appear(GeneralBattle.I_REWARD_GOLD, threshold=0.8):
+                win = True
+                break
+
+            # 如果开启战斗过程随机滑动
+            if config.random_click_swipt_enable:
+                logger.info("random swipt ...")
+                self.random_click_swipt()
+
+            # 打完一个小朋友,自动进入下一个小朋友
+            if self.appear_then_click(self.I_RYOU_DOKAN_IN_FIELD):
+                logger.info("New battle starts")
+
+            continue
+
+        logger.info(f"输赢:{win}")
+        if win:
+            return True
+        else:
+            return False
+
+    def dokan_choose_attack_priority(self, attack_priority: int) -> bool:
+        """ 选择优先攻击
+        : return 
+        """
+        logger.hr('Try to choose attack priority')
+        max_try = 5
+
+        if not self.appear_then_click(self.I_RYOU_DOKAN_PRIORITY, interval=2):
+            logger.error(f"can not find dokan priority option button, choose attack priority process skipped")
+            return False
+
+        logger.info(f"start select attack priority: {attack_priority}, remain try: {max_try}")
+        try:
+            target_attack = self._attack_priorities[attack_priority]
+        except:
+            target_attack = self._attack_priorities[0]
+
+        while 1:
+            self.screenshot()
+            if max_try <= 0:
+                logger.warn("give up priority selection!")
+                break
+
+            if self.appear_then_click(target_attack, interval=1.8):
+                logger.info(f"selected attack priority: {attack_priority}")
+                max_try -= 1
+
+            self.attack_priority_selected = True
+
+        return True
+
+    def anti_detect(self, random_move: bool = True, random_click: bool = True, random_delay: bool = True):
+        '''额外的防封测试
+
+        准备找个号做做爬楼活动的每天300次试试
+        '''
+        res = False
+        # 三个行为中,任何一个生效了都返回True, 否则返回False
+        if random_move:
+            self.random_click_swipt()
+            res = True
+        if random_click:
+            # 0到2秒之间的随机浮点数
+            sleep = random.uniform(0, 2)
+            # 只保留2位小数
+            sleep = round(sleep, 2)
+            if not self.config.dokan.dokan_config.anti_detect_click_fixed_random_area:
+                # 多搞几个安全点击区域
+                num = random.randint(0, 5)
+                if num == 0:
+                    self.click(click=self.C_DOKAN_RANDOM_CLICK_AREA, interval=sleep)
+                elif num == 1:
+                    self.click(click=self.C_DOKAN_RANDOM_CLICK_AREA2, interval=sleep)
+                elif num == 2:
+                    self.click(click=self.C_DOKAN_RANDOM_CLICK_AREA3, interval=sleep)
+                elif num == 3:
+                    self.click(click=self.C_DOKAN_RANDOM_CLICK_AREA, interval=sleep)
+                else:
+                    self.click(click=self.C_DOKAN_RANDOM_CLICK_AREA2, interval=sleep)
+            else:
+                # 假设安全区域是绿色的  
+                safe_color_lower = np.array([45, 25, 25])  # HSV颜色空间的绿色下界  
+                safe_color_upper = np.array([90, 255, 255])  # HSV颜色空间的绿色上界
+                pos = detect_safe_area2(self.device.image, safe_color_lower, safe_color_upper, 3, True)
+                logger.info(f"random click area: {pos}, delay: {sleep}")
+                self.click(pos)
+
+            res = True
+        if random_delay:
+            # 0到2秒之间的随机浮点数
+            sleep = random.uniform(0, 5)
+            # 只保留2位小数
+            sleep = round(sleep, 2)
+            time.sleep(sleep)
+            res = True
+        return res
+
+    def goto_main(self):
+        ''' 保持好习惯,一个任务结束了就返回庭院,方便下一任务的开始或者是出错重启
+         FIXME 退出道馆。注意:有的时候有退出确认框,有的时候没有。未找到规律。
+               先试试用确认框的,若是实在不行,就改成等道馆时间结束后,系统自动退出
+               但是如果出错了,需要重启任务时必须走GameUi.ui_goto(page_main),
+               那样有或者无确认框不确定性还是会导致ui_goto()出错
+        '''
+        # self.ui_current = page_dokan
+        # self.ui_goto(page_main)
+
+        max_try = 3
+        while 1:
+            self.screenshot()
+            if self.appear_then_click(GeneralBattle.I_EXIT, interval=1.5):
+                logger.info(f"Click {GeneralBattle.I_EXIT.name}")
+                continue
+            # 点了后EXIT后,可能无确认框
+            if self.appear_then_click(self.I_RYOU_DOKAN_EXIT_ENSURE, interval=1.5):
+                logger.info(f"Click {self.I_RYOU_DOKAN_EXIT_ENSURE}")
+                break
+            else:
+                max_try -= 1
+                time.sleep(1.2)
+
+            if max_try <= 0:
+                break
+
+        # 退出道馆地图
+        while 1:
+            self.screenshot()
+            # 确认后会跳到竂地图,再点击左上角的蓝色的返回,但是不知道这个返回有没有确认
+            if self.appear_then_click(GameUi.I_BACK_BL, interval=2.5):
+                logger.info(f"Click {GameUi.I_BACK_BL.name}")
+                break
+
+    def goto_dokan(self):
+        ''' 进入道馆
+        TODO 道馆相关场景
+        :return 
+        '''
+        self.ui_get_current_page()
+        try_count = 0
+        while try_count < 5:
+            # 点击进入道馆
+            logger.info("进入阴阳竂")
+            self.ui_goto(page_guild)
+            # 查找道馆
+            activity = "道馆"
+            pos = self.list_find(self.L_RYOU_ACTIVITY_LIST, activity)
+            if pos:
+                logger.info(f"Enter Dokan map: pos = {pos}")
+                self.device.click(x=pos[0], y=pos[1])
+
+                # 进了后的画面,我没有截图,盲猜应该是在画面正中间的
+                time.sleep(2)
+                image = self.screenshot()
+
+                # O_DOKAN_MAP = RuleOcr(roi=(270,130,740,460), area=(270,130,740,460), mode="Full", method="Default", keyword="万", name="dokan_map")
+                # image = cv2.imread("g:/yys/oas/tests/2.png")
+                pos = self.O_DOKAN_MAP.ocr_full(image)
+                if pos == (0, 0, 0, 0):
+                    logger.info("failed to find {self.O_DOKAN_MAP.keyword}")
+                else:
+                    # 取中间
+                    x = pos[0] + pos[2] / 2
+                    # 往上偏移20
+                    y = pos[1] - 20
+
+                    logger.info("ocr detect result pos={pos}, try click pos, x={x}, y={y}")
+
+                    self.device.click(x=x, y=y)
+                    break
+            try_count += 1
+            time.sleep(1)
+
+        print(f"try_count: {try_count}")
+
+    def start_cheering(self):
+        logger.info("start cheering")
+
+    def get_current_scene(self, reuse_screenshot: bool = True):
+        ''' 检测当前场景
+        '''
+        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.ocr_appear(self.O_DOKAN_GATHERING):
+        if self.appear(self.I_RYOU_DOKAN_GATHERING, threshold=0.95):
+            return True, DokanScene.RYOU_DOKAN_SCENE_GATHERING
+        # 状态:是否在等待馆主战
+        # if self.ocr_appear(self.O_DOKAN_BOSS_WAITING):
+        if self.appear(self.I_DOKAN_BOSS_WAITING):
+            return True, DokanScene.RYOU_DOKAN_SCENE_BOSS_WAITING
+
+        # 状态:检查右下角有没有挑战?通常是失败了,并退出来到集结界面,可重新开始点击右下角挑战进入战斗
+        elif self.appear(self.I_RYOU_DOKAN_START_CHALLENGE, 0.95):
+            return True, DokanScene.RYOU_DOKAN_SCENE_START_CHALLENGE
+
+        # 状态:进入战斗,待开始
+        elif self.appear(self.I_RYOU_DOKAN_IN_FIELD, threshold=0.85):
+            return True, DokanScene.RYOU_DOKAN_SCENE_IN_FIELD
+        # 状态:战斗结算,可能是打完小朋友了,也可能是失败了。
+        if self.appear(self.I_RYOU_DOKAN_BATTLE_OVER, threshold=0.85):
+            return True, DokanScene.RYOU_DOKAN_SCENE_BATTLE_OVER
+
+        # 状态:达到失败次数,CD中
+        if self.appear(self.I_RYOU_DOKAN_CD, threshold=0.8):
+            return True, DokanScene.RYOU_DOKAN_SCENE_CD
+        # 状态:加油中,左下角有鼓
+        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.ocr_appear(self.O_DOKAN_SUCCEEDED):
+        if self.appear(self.I_RYOU_DOKAN_FINISHED, threshold=0.8):
+            return True, DokanScene.RYOU_DOKAN_SCENE_FINISHED
+
+        return False, DokanScene.RYOU_DOKAN_SCENE_UNKNOWN
+
+
+def test_goto_main():
+    from module.config.config import Config
+    from module.device.device import Device
+    from tasks.GameUi.page import page_dokan
+
+    config = Config('oas1')
+    device = Device(config)
+    t = ScriptTask(config, device)
+    # t.run()
+    t.ui_current = page_dokan
+    t.ui_goto(page_main)
+
+
+if __name__ == "__main__":
+    # from module.config.config import Config
+    # from module.device.device import Device
+
+    # config = Config('oas1')
+    # device = Device(config)
+    # t = ScriptTask(config, device)
+    # t.run()
+
+    # test_ocr_locate_dokan_target()
+    # test_anti_detect_random_click()
+    test_goto_main()

+ 197 - 0
tasks/Dokan/utils.py

@@ -0,0 +1,197 @@
+import cv2
+import numpy as np
+
+from module.logger import logger
+
+
+def detect_safe_area(image, target_gray_value=255, tolerance=0):
+    """
+    在灰度图片中查找与目标灰度值在容差范围内的纯色区块,并返回这些区块的坐标。
+
+    :param image_path: 图片路径
+    :param target_gray_value: 目标灰度值,默认为255(最亮)
+    :param tolerance: 灰度差异容忍度,默认为0(即完全匹配)
+    :return: 包含找到的纯色区块坐标元组的列表
+    """
+    # 加载图片并转换为灰度图
+    # img = Image.open(image_path).convert('L')  # 'L' 表示转换为灰度图
+    # img_arr = np.array(img)  # 转换为numpy数组以便高效处理
+
+    # 将图片转换为灰度图
+    gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
+    _, img_arr = cv2.threshold(gray, 127, 255, cv2.THRESH_BINARY)
+
+    # 初始化结果列表
+    solid_regions = []
+
+    # 遍历图片的每个像素
+    for y in range(img_arr.shape[0]):  # 高度
+        for x in range(img_arr.shape[1]):  # 宽度
+            pixel_gray_value = img_arr[y, x]
+
+            # 检查当前像素灰度值是否与目标灰度值在容差范围内匹配
+            if abs(pixel_gray_value - target_gray_value) <= tolerance:
+                # 检查周围是否也是同样的灰度值,以确定这是一个区块而非单个像素
+                is_solid_region = True
+                for dy in range(-1, 2):  # 检查3x3区域
+                    for dx in range(-1, 2):
+                        if dy == 0 and dx == 0:
+                            continue  # 跳过中心点
+                        ny, nx = y + dy, x + dx
+                        if 0 <= ny < img_arr.shape[0] and 0 <= nx < img_arr.shape[1]:
+                            if abs(img_arr[ny, nx] - target_gray_value) > tolerance:
+                                is_solid_region = False
+                                break
+                    if not is_solid_region:
+                        break
+
+                if is_solid_region:
+                    # 记录纯色区块的左上角坐标和右下角坐标
+                    start_x, start_y = x, y
+                    while start_y > 0 and abs(img_arr[start_y - 1, x] - target_gray_value) <= tolerance:
+                        start_y -= 1
+                    while start_x > 0 and abs(img_arr[y, start_x - 1] - target_gray_value) <= tolerance:
+                        start_x -= 1
+                    end_x, end_y = x, y
+                    while end_y < img_arr.shape[0] - 1 and abs(img_arr[end_y + 1, x] - target_gray_value) <= tolerance:
+                        end_y += 1
+                    while end_x < img_arr.shape[1] - 1 and abs(img_arr[y, end_x + 1] - target_gray_value) <= tolerance:
+                        end_x += 1
+
+                    solid_regions.append(((start_x, start_y), (end_x + 1, end_y + 1)))
+
+    return solid_regions
+
+
+def detect_safe_area2(image, safe_color_lower, safe_color_upper, num_areas=3, debug=False):
+    """
+    找出当前截图里最大的纯色区域,找出来的这个区域将被用于随机点击的区域。
+    :note:          注意拿到这个区域后要马上点击,不要sleep!
+    :param image:   截图图像
+    :return:        最大纯色区域的坐标
+    """
+    # 将图片从BGR转换到HSV色彩空间
+    hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
+
+    # 定义颜色范围
+    # 注意:这里的颜色范围需要根据实际图片中的安全区域颜色进行调整
+    mask = cv2.inRange(hsv, safe_color_lower, safe_color_upper)
+
+    # 应用形态学操作来消除噪点和填补小的孔洞
+    kernel = np.ones((5, 5), np.uint8)
+    mask = cv2.dilate(mask, kernel, iterations=1)
+    mask = cv2.erode(mask, kernel, iterations=1)
+
+    # 查找轮廓
+    contours, _ = cv2.findContours(mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
+
+    # 计算每个轮廓的面积并排序
+    # areas = [(cv2.contourArea(contour), contour) for contour in contours]
+    areas = []
+    for contour in contours:
+        area = cv2.contourArea(contour)
+        print(f"area={area}")
+        areas.append((area, contour))
+
+    # areas.sort(reverse=True)
+    # 按面积降序排序
+    areas_sorted = sorted(areas, key=lambda x: x[0], reverse=True)
+
+    if debug:
+        # 绘制面积排名前3的区域
+        for area, contour in areas_sorted[:num_areas]:
+            x1, y1, w1, h1 = cv2.boundingRect(contour)
+            # 使用蓝色边框,线宽为4
+            cv2.rectangle(image, (x1, y1), (x1 + w1, y1 + h1), (255, 0, 0), 4)
+            # 使用红色边框,线宽为3
+            cv2.drawContours(image, [contour], -1, (0, 0, 255), 3)
+
+    # 假设最大的轮廓是安全区域
+    if contours:
+        safe_area = max(contours, key=cv2.contourArea)
+        x, y, w, h = cv2.boundingRect(safe_area)
+
+        if debug:
+            # 绘制安全区域
+            cv2.drawContours(image, [safe_area], -1, (0, 255, 0), 3)
+
+        return (x, y, w, h)
+
+    return (0, 0, 0, 0)
+
+
+def test_ocr_locate_dokan_target():
+    import cv2
+    from module.atom.ocr import RuleOcr
+
+    logger.info("========================================>>test 2")
+    O_DOKAN_MAP = RuleOcr(roi=(270, 130, 740, 460), area=(270, 130, 740, 460), mode="Full", method="Default",
+                          keyword="万", name="dokan_map")
+
+    image = cv2.imread("g:/yys/oas/tests/1.png")
+    pos = O_DOKAN_MAP.ocr_full(image)
+    print(f"image1: {pos}")
+
+    image = cv2.imread("g:/yys/oas/tests/2.png")
+    pos = O_DOKAN_MAP.ocr_full(image)
+    print(f"image2: {pos}")
+
+    image = cv2.imread("g:/yys/oas/tests/3.png")
+    pos = O_DOKAN_MAP.ocr_full(image)
+    print(f"image3: {pos}")
+
+    image = cv2.imread("g:/yys/oas/tests/4.png")
+    pos = O_DOKAN_MAP.ocr_full(image)
+    print(f"image4: {pos}")
+    if pos == (0, 0, 0, 0):
+        logger.info("failed to find {self.O_DOKAN_MAP.keyword}")
+    else:
+        # 取中间
+        x = pos[0] + pos[2] / 2
+        # 往上偏移20
+        y = pos[1] - 20
+
+        logger.info(f"ocr detect result pos={pos}, try click pos, x={x}, y={y}")
+
+
+def test_anti_detect_random_click():
+    import cv2
+
+    # image_list = ['g:/yys/oas/tests/1.png', 'g:/yys/oas/tests/2.png', 'g:/yys/oas/tests/3.png', 'g:/yys/oas/tests/4.png', 'g:/yys/oas/tests/5.png']
+    image_list = ['g:/yys/oas/tests/a.png', 'g:/yys/oas/tests/b.png', 'g:/yys/oas/tests/c.png']
+
+    for item in image_list:
+        print(f"item: {item}")
+        image = cv2.imread(item)
+
+        # 注意:这里的颜色范围需要根据实际图片进行调整
+        # http://kb.rg4.net/docs/omassistant/omassistant-1fnirpstkhdnh
+        # 0<=h<20, 红色
+        # 30<=h<45,黄色
+        # 45<=h<90,绿色
+        # 90<=h<125,青色
+        # 125<=h<150,蓝色
+        # 150<=h<175,紫色
+        # 175<=h<200,粉红色
+        # 200<=h<220,砖红色
+        # 220<=h<255,品红色
+
+        # 示例使用:假设安全区域是绿色的
+        safe_color_lower = np.array([45, 25, 25])  # HSV颜色空间的绿色下界
+        safe_color_upper = np.array([90, 255, 255])  # HSV颜色空间的绿色上界
+
+        # 读取图片
+        image = cv2.imread('c.png')
+        if image is None:
+            print("Error: Image not found.")
+        else:
+            # 调用函数
+            pos = detect_safe_area2(image, safe_color_lower, safe_color_upper, 3, True)
+            print(f"pos={pos}")
+
+            # 显示结果
+            cv2.imshow('Safe Area', image)
+            cv2.waitKey(0)
+            cv2.destroyAllWindows()
+
+

+ 6 - 2
tasks/Duel/assets.py

@@ -23,9 +23,9 @@ class DuelAssets:
 	# 观战 
 	# 观战 
 	I_D_VISIT = RuleImage(roi_front=(1045,613,53,55), roi_back=(1045,613,53,55), threshold=0.8, method="Template matching", file="./tasks/Duel/duel/duel_d_visit.png")
 	I_D_VISIT = RuleImage(roi_front=(1045,613,53,55), roi_back=(1045,613,53,55), threshold=0.8, method="Template matching", file="./tasks/Duel/duel/duel_d_visit.png")
 	# description 
 	# description 
-	I_D_BATTLE = RuleImage(roi_front=(1143,566,100,100), roi_back=(1143,566,100,100), threshold=0.8, method="Template matching", file="./tasks/Duel/duel/duel_d_battle.png")
+	I_D_BATTLE = RuleImage(roi_front=(1153,573,100,100), roi_back=(1123,537,154,177), threshold=0.8, method="Template matching", file="./tasks/Duel/duel/duel_d_battle.png")
 	# 战斗带保护的 
 	# 战斗带保护的 
-	I_D_BATTLE_PROTECT = RuleImage(roi_front=(1145,563,100,100), roi_back=(1145,563,100,100), threshold=0.8, method="Template matching", file="./tasks/Duel/duel/duel_d_battle_protect.png")
+	I_D_BATTLE_PROTECT = RuleImage(roi_front=(1153,578,100,100), roi_back=(1118,553,155,149), threshold=0.8, method="Template matching", file="./tasks/Duel/duel/duel_d_battle_protect.png")
 	# 预选点击确认 
 	# 预选点击确认 
 	I_D_CONFIRM = RuleImage(roi_front=(1097,517,139,156), roi_back=(1097,517,139,156), threshold=0.8, method="Template matching", file="./tasks/Duel/duel/duel_d_confirm.png")
 	I_D_CONFIRM = RuleImage(roi_front=(1097,517,139,156), roi_back=(1097,517,139,156), threshold=0.8, method="Template matching", file="./tasks/Duel/duel/duel_d_confirm.png")
 	# 自动上阵 
 	# 自动上阵 
@@ -50,6 +50,10 @@ class DuelAssets:
 	I_D_CELEB_STAR = RuleImage(roi_front=(586,456,30,32), roi_back=(574,444,53,54), threshold=0.75, method="Template matching", file="./tasks/Duel/duel/duel_d_celeb_star.png")
 	I_D_CELEB_STAR = RuleImage(roi_front=(586,456,30,32), roi_back=(574,444,53,54), threshold=0.75, method="Template matching", file="./tasks/Duel/duel/duel_d_celeb_star.png")
 	# 名士专属 
 	# 名士专属 
 	I_D_CELEB_HONOR = RuleImage(roi_front=(665,531,25,30), roi_back=(652,517,52,53), threshold=0.75, method="Template matching", file="./tasks/Duel/duel/duel_d_celeb_honor.png")
 	I_D_CELEB_HONOR = RuleImage(roi_front=(665,531,25,30), roi_back=(652,517,52,53), threshold=0.75, method="Template matching", file="./tasks/Duel/duel/duel_d_celeb_honor.png")
+	# 练 
+	I_BATTLE_WITH_TRAIN = RuleImage(roi_front=(1161,588,78,81), roi_back=(1114,547,163,172), threshold=0.8, method="Template matching", file="./tasks/Duel/duel/duel_battle_with_train.png")
+	# 活动的战斗按钮 
+	I_D_BATTLE2 = RuleImage(roi_front=(1171,592,69,78), roi_back=(1119,566,154,143), threshold=0.8, method="Template matching", file="./tasks/Duel/duel/duel_d_battle2.png")
 
 
 
 
 	# Ocr Rule Assets
 	# Ocr Rule Assets

BIN
tasks/Duel/duel/duel_battle_with_train.png


BIN
tasks/Duel/duel/duel_d_battle2.png


+ 22 - 4
tasks/Duel/duel/image.json

@@ -29,8 +29,8 @@
   {
   {
     "itemName": "d_battle",
     "itemName": "d_battle",
     "imageName": "duel_d_battle.png",
     "imageName": "duel_d_battle.png",
-    "roiFront": "1143,566,100,100",
-    "roiBack": "1143,566,100,100",
+    "roiFront": "1153,573,100,100",
+    "roiBack": "1123,537,154,177",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "description"
     "description": "description"
@@ -38,8 +38,8 @@
   {
   {
     "itemName": "d_battle_protect",
     "itemName": "d_battle_protect",
     "imageName": "duel_d_battle_protect.png",
     "imageName": "duel_d_battle_protect.png",
-    "roiFront": "1145,563,100,100",
-    "roiBack": "1145,563,100,100",
+    "roiFront": "1153,578,100,100",
+    "roiBack": "1118,553,155,149",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "战斗带保护的"
     "description": "战斗带保护的"
@@ -151,5 +151,23 @@
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.75,
     "threshold": 0.75,
     "description": "名士专属"
     "description": "名士专属"
+  },
+  {
+    "itemName": "battle_with_train",
+    "imageName": "duel_battle_with_train.png",
+    "roiFront": "1161,588,78,81",
+    "roiBack": "1114,547,163,172",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "练"
+  },
+  {
+    "itemName": "d_battle2",
+    "imageName": "duel_d_battle2.png",
+    "roiFront": "1171,592,69,78",
+    "roiBack": "1119,566,154,143",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "活动的战斗按钮"
   }
   }
 ]
 ]

+ 16 - 2
tasks/Duel/script_task.py

@@ -5,7 +5,7 @@ from time import sleep
 from datetime import time, datetime, timedelta
 from datetime import time, datetime, timedelta
 
 
 from module.logger import logger
 from module.logger import logger
-from module.exception import TaskEnd
+from module.exception import TaskEnd, RequestHumanTakeover
 from module.base.timer import Timer
 from module.base.timer import Timer
 
 
 from tasks.Component.GeneralBattle.general_battle import GeneralBattle
 from tasks.Component.GeneralBattle.general_battle import GeneralBattle
@@ -106,7 +106,17 @@ class ScriptTask(GameUi, GeneralBattle, DuelAssets):
                 logger.info('You are already a celeb')
                 logger.info('You are already a celeb')
                 return None
                 return None
             current_score = self.O_D_SCORE.ocr(self.device.image)
             current_score = self.O_D_SCORE.ocr(self.device.image)
-            if current_score < 1200 or current_score > 3000:
+            if current_score < 1200:
+                # 分太低了
+                logger.warning('Score is too low')
+                logger.error('Please enhance your score')
+                raise RequestHumanTakeover
+            elif current_score > 10000:
+                # 识别错误分数超过一万, 去掉最高位
+                logger.warning('Recognition error, score is too high')
+                logger.warning('Remove the highest digit')
+                current_score = int(str(current_score)[1:])
+            elif current_score > 3000:
                 continue
                 continue
             return current_score if current_score <= target else None
             return current_score if current_score <= target else None
 
 
@@ -125,6 +135,10 @@ class ScriptTask(GameUi, GeneralBattle, DuelAssets):
                 break
                 break
             if self.appear_then_click(self.I_D_BATTLE, interval=1):
             if self.appear_then_click(self.I_D_BATTLE, interval=1):
                 continue
                 continue
+            if self.appear_then_click(self.I_D_BATTLE2, interval=1):
+                continue
+            if self.appear_then_click(self.I_BATTLE_WITH_TRAIN, interval=1):
+                continue
             if self.appear_then_click(self.I_D_BATTLE_PROTECT, interval=1.6):
             if self.appear_then_click(self.I_D_BATTLE_PROTECT, interval=1.6):
                 continue
                 continue
         # 点击斗技 开始匹配对手
         # 点击斗技 开始匹配对手

+ 39 - 0
tasks/FloatParade/assets.py

@@ -0,0 +1,39 @@
+from module.atom.image import RuleImage
+from module.atom.click import RuleClick
+from module.atom.long_click import RuleLongClick
+from module.atom.swipe import RuleSwipe
+from module.atom.ocr import RuleOcr
+from module.atom.list import RuleList
+
+# This file was automatically generated by ./dev_tools/assets_extract.py.
+# Don't modify it manually.
+class FloatParadeAssets: 
+
+
+	# Image Rule Assets
+	# 从庭院进入花车活动 
+	I_FP_ACCESS = RuleImage(roi_front=(183,413,36,34), roi_back=(95,344,1042,229), threshold=0.8, method="Template matching", file="./tasks/FloatParade/fp/fp_fp_access.png")
+	# description 
+	I_FP_GETALL0 = RuleImage(roi_front=(1153,287,65,56), roi_back=(1134,261,100,100), threshold=0.8, method="Template matching", file="./tasks/FloatParade/fp/fp_fp_getall0.png")
+	# description 
+	I_FP_RED_POINT0 = RuleImage(roi_front=(1242,604,22,21), roi_back=(1225,585,53,54), threshold=0.8, method="Template matching", file="./tasks/FloatParade/fp/fp_fp_red_point0.png")
+	# description 
+	I_FP_GETALL1 = RuleImage(roi_front=(1194,539,60,61), roi_back=(1167,520,100,100), threshold=0.8, method="Template matching", file="./tasks/FloatParade/fp/fp_fp_getall1.png")
+	# description 
+	I_FP_RED_POINT1 = RuleImage(roi_front=(1249,155,21,21), roi_back=(1223,138,56,62), threshold=0.8, method="Template matching", file="./tasks/FloatParade/fp/fp_fp_red_point1.png")
+	# description 
+	I_FP_RED_POINT2 = RuleImage(roi_front=(1246,288,22,21), roi_back=(1232,278,43,41), threshold=0.8, method="Template matching", file="./tasks/FloatParade/fp/fp_fp_red_point2.png")
+	# description 
+	I_FP_BATCH = RuleImage(roi_front=(985,520,94,31), roi_back=(978,507,112,64), threshold=0.8, method="Template matching", file="./tasks/FloatParade/fp/fp_fp_batch.png")
+	# description 
+	I_FP_BATCH_TRUE = RuleImage(roi_front=(938,518,35,37), roi_back=(924,506,64,62), threshold=0.8, method="Template matching", file="./tasks/FloatParade/fp/fp_fp_batch_true.png")
+	# description 
+	I_FP_BATCH_FALSE = RuleImage(roi_front=(936,515,40,45), roi_back=(924,505,63,65), threshold=0.8, method="Template matching", file="./tasks/FloatParade/fp/fp_fp_batch_false.png")
+	# 右下角的任务 
+	I_FP_TASKS = RuleImage(roi_front=(1175,617,79,76), roi_back=(1162,605,100,100), threshold=0.8, method="Template matching", file="./tasks/FloatParade/fp/fp_fp_tasks.png")
+	# 升级 
+	I_FP_UPGRADE = RuleImage(roi_front=(1075,75,116,49), roi_back=(1040,52,169,100), threshold=0.8, method="Template matching", file="./tasks/FloatParade/fp/fp_fp_upgrade.png")
+	# description 
+	I_FP_RED_CLOSE = RuleImage(roi_front=(1170,109,43,44), roi_back=(1157,101,72,62), threshold=0.8, method="Template matching", file="./tasks/FloatParade/fp/fp_fp_red_close.png")
+
+

+ 25 - 0
tasks/FloatParade/config.py

@@ -0,0 +1,25 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+from datetime import timedelta
+from enum import Enum
+from pydantic import BaseModel, Field
+
+from tasks.Component.config_scheduler import Scheduler as BaseScheduler
+from tasks.Component.config_base import ConfigBase, TimeDelta
+
+class Scheduler(BaseScheduler):
+    success_interval: TimeDelta = Field(default=TimeDelta(days=3), description='success_interval_help')
+    failure_interval: TimeDelta = Field(default=TimeDelta(days=3), description='failure_interval_help')
+
+class LevelReward(str, Enum):
+    ONE = '蛇皮/青吉鬼'
+    TWO = '金币/勾玉'
+    THREE = '体力/樱饼'
+
+class FloatParadeConfig(BaseModel):
+    level_reward: LevelReward = Field(default=LevelReward.TWO)
+
+class FloatParade(ConfigBase):
+    scheduler: Scheduler = Field(default_factory=Scheduler)
+    float_parade: FloatParadeConfig = Field(default_factory=FloatParadeConfig)

BIN
tasks/FloatParade/fp/fp_fp_access.png


BIN
tasks/FloatParade/fp/fp_fp_batch.png


BIN
tasks/FloatParade/fp/fp_fp_batch_false.png


BIN
tasks/FloatParade/fp/fp_fp_batch_true.png


BIN
tasks/FloatParade/fp/fp_fp_getall0.png


BIN
tasks/FloatParade/fp/fp_fp_getall1.png


BIN
tasks/FloatParade/fp/fp_fp_red_close.png


BIN
tasks/FloatParade/fp/fp_fp_red_point0.png


BIN
tasks/FloatParade/fp/fp_fp_red_point1.png


BIN
tasks/FloatParade/fp/fp_fp_red_point2.png


BIN
tasks/FloatParade/fp/fp_fp_tasks.png


BIN
tasks/FloatParade/fp/fp_fp_upgrade.png


+ 110 - 0
tasks/FloatParade/fp/image.json

@@ -0,0 +1,110 @@
+[
+  {
+    "itemName": "fp_access",
+    "imageName": "fp_fp_access.png",
+    "roiFront": "183,413,36,34",
+    "roiBack": "95,344,1042,229",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "从庭院进入花车活动"
+  },
+  {
+    "itemName": "fp_getall0",
+    "imageName": "fp_fp_getall0.png",
+    "roiFront": "1153,287,65,56",
+    "roiBack": "1134,261,100,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "fp_red_point0",
+    "imageName": "fp_fp_red_point0.png",
+    "roiFront": "1242,604,22,21",
+    "roiBack": "1225,585,53,54",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "fp_getall1",
+    "imageName": "fp_fp_getall1.png",
+    "roiFront": "1194,539,60,61",
+    "roiBack": "1167,520,100,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "fp_red_point1",
+    "imageName": "fp_fp_red_point1.png",
+    "roiFront": "1249,155,21,21",
+    "roiBack": "1223,138,56,62",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "fp_red_point2",
+    "imageName": "fp_fp_red_point2.png",
+    "roiFront": "1246,288,22,21",
+    "roiBack": "1232,278,43,41",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "fp_batch",
+    "imageName": "fp_fp_batch.png",
+    "roiFront": "985,520,94,31",
+    "roiBack": "978,507,112,64",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "fp_batch_true",
+    "imageName": "fp_fp_batch_true.png",
+    "roiFront": "938,518,35,37",
+    "roiBack": "924,506,64,62",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "fp_batch_false",
+    "imageName": "fp_fp_batch_false.png",
+    "roiFront": "936,515,40,45",
+    "roiBack": "924,505,63,65",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "fp_tasks",
+    "imageName": "fp_fp_tasks.png",
+    "roiFront": "1175,617,79,76",
+    "roiBack": "1162,605,100,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "右下角的任务"
+  },
+  {
+    "itemName": "fp_upgrade",
+    "imageName": "fp_fp_upgrade.png",
+    "roiFront": "1075,75,116,49",
+    "roiBack": "1040,52,169,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "升级"
+  },
+  {
+    "itemName": "fp_red_close",
+    "imageName": "fp_fp_red_close.png",
+    "roiFront": "1170,109,43,44",
+    "roiBack": "1157,101,72,62",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "红色关闭"
+  }
+]

+ 113 - 0
tasks/FloatParade/script_task.py

@@ -0,0 +1,113 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+import time
+
+from tasks.GameUi.game_ui import GameUi
+from tasks.GameUi.page import page_main
+from tasks.TalismanPass.assets import TalismanPassAssets
+from tasks.FloatParade.assets import FloatParadeAssets
+from tasks.FloatParade.config import FloatParadeConfig, LevelReward
+
+from module.logger import logger
+from module.exception import TaskEnd
+from module.base.timer import Timer
+
+class ScriptTask(GameUi, FloatParadeAssets, TalismanPassAssets):
+
+    def run(self):
+        self.ui_get_current_page()
+        self.ui_goto(page_main)
+        con: FloatParadeConfig = self.config.talisman_pass.talisman
+
+        # 收取全部奖励
+        self.get_all()
+        # 回退
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_FP_TASKS):
+                break
+            if self.appear_then_click(self.I_BACK_Y, interval=3):
+                continue
+        logger.info('Goback to float parade main page')
+        # 收取花车等级奖励
+        self.get_flower(con.level_reward)
+        # main page
+        self.ui_get_current_page()
+        self.ui_goto(page_main)
+
+        self.set_next_run(task='FloatParade', success=True, finish=True)
+        raise TaskEnd('FloatParade')
+
+
+    def get_all(self):
+        """
+        一键收取所有的, 从庭院进入
+        :return:
+        """
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_FP_UPGRADE):
+                break
+            if self.appear_then_click(self.I_FP_ACCESS, interval=0.8):
+                continue
+            if self.appear_then_click(self.I_FP_RED_CLOSE, interval=1.5):
+                continue
+            if self.appear_then_click(self.I_FP_TASKS, interval=1.8):
+                continue
+        logger.info('Enter float parade')
+        logger.info('Click get all reward')
+        if not self.appear(self.I_FP_GETALL1):
+            logger.info('No appear get all button')
+            return
+        self.ui_get_reward(self.I_FP_GETALL1)
+        logger.info('Got all reward')
+
+    def get_flower(self, level: LevelReward = LevelReward.TWO):
+        """
+        收取花合战等级奖励
+        :return:
+        """
+        match_level = {
+            LevelReward.ONE: self.I_TP_LEVEL_1,
+            LevelReward.TWO: self.I_TP_LEVEL_2,
+            LevelReward.THREE: self.I_TP_LEVEL_3,
+        }
+        self.screenshot()
+        if not self.appear(self.I_FP_GETALL0):
+            logger.info('No any level reward')
+            return
+        logger.info('Appear level reward')
+        # self.ui_click(self.I_FP_GETALL0, self.I_TP_GET_ALL)
+        logger.info('Click level reward')
+        check_timer = Timer(2)
+        check_timer.start()
+        while 1:
+            self.screenshot()
+            if self.appear_then_click(match_level[level], interval=0.8):
+                logger.info(f'Select {level} reward')
+                check_timer.reset()
+                continue
+
+            if self.ui_reward_appear_click(False):
+                logger.info('Get reward')
+                check_timer.reset()
+                continue
+            if check_timer.reached():
+                logger.warning('No reward and break')
+                break
+            if self.appear_then_click(self.I_FP_GETALL0, interval=2.1):
+                logger.info('Get all reward')
+                check_timer.reset()
+                continue
+
+
+if __name__ == '__main__':
+    from module.config.config import Config
+    from module.device.device import Device
+    c = Config('oas1')
+    d = Device(c)
+    t = ScriptTask(c, d)
+    t.screenshot()
+
+    t.run()

+ 6 - 2
tasks/GameUi/page.py

@@ -3,7 +3,6 @@ import traceback
 from tasks.GameUi.assets import GameUiAssets as G
 from tasks.GameUi.assets import GameUiAssets as G
 from tasks.RyouToppa.assets import RyouToppaAssets
 from tasks.RyouToppa.assets import RyouToppaAssets
 
 
-
 class Page:
 class Page:
     parent = None
     parent = None
 
 
@@ -94,7 +93,6 @@ page_bondling_fairyland = Page(G.I_CHECK_BONDLING_FAIRYLAND)
 page_bondling_fairyland.link(button=G.I_BACK_YOLLOW, destination=page_exploration)
 page_bondling_fairyland.link(button=G.I_BACK_YOLLOW, destination=page_exploration)
 page_exploration.link(button=G.I_EXPLORATION_GOTO_BONDLING_FAIRYLAND, destination=page_bondling_fairyland)
 page_exploration.link(button=G.I_EXPLORATION_GOTO_BONDLING_FAIRYLAND, destination=page_bondling_fairyland)
 
 
-
 # ************************************* 町中部分 *****************************************#
 # ************************************* 町中部分 *****************************************#
 # 斗鸡 duel
 # 斗鸡 duel
 page_duel = Page(G.I_CHECK_DUEL)
 page_duel = Page(G.I_CHECK_DUEL)
@@ -164,6 +162,12 @@ page_travel.link(button=G.I_BACK_Y, destination=page_main)
 page_main.link(button=G.I_MAIN_GOTO_TRAVEL, destination=page_travel)
 page_main.link(button=G.I_MAIN_GOTO_TRAVEL, destination=page_travel)
 
 
 
 
+# 道馆
+from tasks.Component.GeneralBattle.assets import GeneralBattleAssets
+from tasks.Dokan.assets import DokanAssets
+page_dokan = Page(DokanAssets.I_RYOU_DOKAN_CHECK)
+page_dokan.additional = [GeneralBattleAssets.I_EXIT, DokanAssets.I_RYOU_DOKAN_EXIT_ENSURE, G.I_BACK_BLUE]
+page_dokan.link(button=G.I_BACK_Y, destination=page_main)
 
 
 
 
 
 

BIN
tasks/GameUi/page/page_check_ryou_daoguan.png


+ 2 - 2
tasks/Hyakkiyakou/assets.py

@@ -18,9 +18,9 @@ class HyakkiyakouAssets:
 	# description 
 	# description 
 	C_HSELECT_3 = RuleClick(roi_front=(934,298,115,306), roi_back=(934,298,115,306), name="hselect_3")
 	C_HSELECT_3 = RuleClick(roi_front=(934,298,115,306), roi_back=(934,298,115,306), name="hselect_3")
 	# description 
 	# description 
-	C_FRIEND_1 = RuleClick(roi_front=(446,227,181,67), roi_back=(446,227,181,67), name="friend_1")
+	C_FRIEND_1 = RuleClick(roi_front=(466,227,161,67), roi_back=(466,227,161,67), name="friend_1")
 	# description 
 	# description 
-	C_FRIEND_2 = RuleClick(roi_front=(718,229,178,64), roi_back=(718,229,178,64), name="friend_2")
+	C_FRIEND_2 = RuleClick(roi_front=(738,229,158,64), roi_back=(738,229,158,64), name="friend_2")
 	# description 
 	# description 
 	C_FRIEND_3 = RuleClick(roi_front=(445,310,183,66), roi_back=(445,310,183,66), name="friend_3")
 	C_FRIEND_3 = RuleClick(roi_front=(445,310,183,66), roi_back=(445,310,183,66), name="friend_3")
 	# description 
 	# description 

+ 4 - 4
tasks/Hyakkiyakou/hya/click.json

@@ -19,14 +19,14 @@
   },
   },
   {
   {
     "itemName": "friend_1",
     "itemName": "friend_1",
-    "roiFront": "446,227,181,67",
-    "roiBack": "446,227,181,67",
+    "roiFront": "466,227,161,67",
+    "roiBack": "466,227,161,67",
     "description": "description"
     "description": "description"
   },
   },
   {
   {
     "itemName": "friend_2",
     "itemName": "friend_2",
-    "roiFront": "718,229,178,64",
-    "roiBack": "718,229,178,64",
+    "roiFront": "738,229,158,64",
+    "roiBack": "738,229,158,64",
     "description": "description"
     "description": "description"
   },
   },
   {
   {

+ 1 - 1
tasks/Hyakkiyakou/script_task.py

@@ -135,7 +135,6 @@ class ScriptTask(GameUi, HyaSlave):
             if datetime.now() - self.start_time >= self.limit_time:
             if datetime.now() - self.start_time >= self.limit_time:
                 logger.info('Hyakkiyakou time limit out')
                 logger.info('Hyakkiyakou time limit out')
                 break
                 break
-                
 
 
             self.one()
             self.one()
             hya_count += 1
             hya_count += 1
@@ -175,6 +174,7 @@ class ScriptTask(GameUi, HyaSlave):
         logger.hr('Start Hyakkiyakou')
         logger.hr('Start Hyakkiyakou')
         init_bean_flag: bool = False
         init_bean_flag: bool = False
         last_action = [0, 0, False, 10]
         last_action = [0, 0, False, 10]
+        self.hya_fs_check_timer.reset()
         if self._config.debug_config.hya_show:
         if self._config.debug_config.hya_show:
             self.debugger.show_start()
             self.debugger.show_start()
         while 1:
         while 1:

+ 27 - 8
tasks/Hyakkiyakou/slave/hya_device.py

@@ -1,11 +1,20 @@
 import timeit
 import timeit
+import numpy as np
 
 
 from module.base.timer import Timer
 from module.base.timer import Timer
 from module.logger import logger
 from module.logger import logger
 from module.base.utils import point2str
 from module.base.utils import point2str
+from module.exception import RequestHumanTakeover, GameStuckError
 from tasks.base_task import BaseTask
 from tasks.base_task import BaseTask
 
 
 
 
+def image_black(img) -> bool:
+    for y, x in [(0, 0), (719, 1279), (719, 0), (0, 1279)]:
+        if np.all(img[y, x] != 0):
+            return False
+    return True
+
+
 class HyaDevice(BaseTask):
 class HyaDevice(BaseTask):
     """
     """
     这个类主要是是优化截屏点击速度
     这个类主要是是优化截屏点击速度
@@ -15,11 +24,19 @@ class HyaDevice(BaseTask):
     我宣布世界上最好的 Linux 系统是 Windows
     我宣布世界上最好的 Linux 系统是 Windows
     """
     """
     hya_screenshot_interval = Timer(0.2)  # 300ms
     hya_screenshot_interval = Timer(0.2)  # 300ms
+    hya_fs_check_timer = Timer(5 * 60)  # 五分钟跑不完就应该是出问题了
 
 
     def fast_screenshot(self):
     def fast_screenshot(self):
         self.hya_screenshot_interval.wait()
         self.hya_screenshot_interval.wait()
         self.hya_screenshot_interval.reset()
         self.hya_screenshot_interval.reset()
         self.device.image = self.device.screenshot_window_background()
         self.device.image = self.device.screenshot_window_background()
+        if image_black(self.device.image):
+            logger.error('Screenshot image is black, try again')
+            raise RequestHumanTakeover('Screenshot image is black, try again')
+        if self.hya_fs_check_timer.reached():
+            logger.error('Fast screenshot check timer reached')
+            logger.error('Five minutes have not ended, the game is probably stuck, please check the game')
+            raise GameStuckError
         return self.device.image
         return self.device.image
 
 
     def fast_click(self, x: int, y: int) -> None:
     def fast_click(self, x: int, y: int) -> None:
@@ -37,7 +54,6 @@ class HyaDevice(BaseTask):
         self.hya_screenshot_interval = Timer(interval / 1000.)
         self.hya_screenshot_interval = Timer(interval / 1000.)
 
 
 
 
-
 if __name__ == '__main__':
 if __name__ == '__main__':
     from module.config.config import Config
     from module.config.config import Config
     from module.device.device import Device
     from module.device.device import Device
@@ -46,10 +62,13 @@ if __name__ == '__main__':
     d = Device(c)
     d = Device(c)
     hd = HyaDevice(c, d)
     hd = HyaDevice(c, d)
 
 
-    def screenshot():
-        global hd
-        # hd.fast_screenshot()
-        hd.fast_click(420, 370)
-        hd.fast_click(750, 400)
-    execution_time = timeit.timeit(screenshot, number=50)
-    print(f"执行总的时间: {execution_time * 1000} ms")
+    # def screenshot():
+    #     global hd
+    #     # hd.fast_screenshot()
+    #     hd.fast_click(420, 370)
+    #     hd.fast_click(750, 400)
+    # execution_time = timeit.timeit(screenshot, number=50)
+    # print(f"执行总的时间: {execution_time * 1000} ms")
+
+    hd.fast_screenshot()
+

+ 5 - 8
tasks/Restart/config.py

@@ -4,9 +4,7 @@
 from pydantic import BaseModel, Field
 from pydantic import BaseModel, Field
 
 
 from tasks.Restart.config_scheduler import RestartScheduler
 from tasks.Restart.config_scheduler import RestartScheduler
-from tasks.Component.config_base import ConfigBase
-
-
+from tasks.Component.config_base import ConfigBase, DateTime
 
 
 class HarvestConfig(BaseModel):
 class HarvestConfig(BaseModel):
     # 默认启用
     # 默认启用
@@ -24,13 +22,12 @@ class HarvestConfig(BaseModel):
     # 体力
     # 体力
     enable_ap: bool = Field(default=True)
     enable_ap: bool = Field(default=True)
 
 
-
-
-
-
-
+class TasksReset(BaseModel):
+    reset_task_datetime_enable: bool = Field(default=False, description='reset_task_datetime_enable_help')
+    reset_task_datetime: DateTime = Field(default="2023-01-01 00:00:00", description='rest_task_datetime_help')
 
 
 class Restart(ConfigBase):
 class Restart(ConfigBase):
     scheduler: RestartScheduler = Field(default_factory=RestartScheduler)
     scheduler: RestartScheduler = Field(default_factory=RestartScheduler)
+    tasks_config_reset: TasksReset = Field(default_factory=TasksReset)
     harvest_config: HarvestConfig = Field(default_factory=HarvestConfig)
     harvest_config: HarvestConfig = Field(default_factory=HarvestConfig)
 
 

+ 8 - 6
tasks/RichMan/assets.py

@@ -234,17 +234,17 @@ class RichManAssets:
 	# 永生之海 
 	# 永生之海 
 	I_SCA_PICTURE_BOOK = RuleImage(roi_front=(995,258,100,100), roi_back=(995,258,100,100), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/scales/scales_sca_picture_book.png")
 	I_SCA_PICTURE_BOOK = RuleImage(roi_front=(995,258,100,100), roi_back=(995,258,100,100), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/scales/scales_sca_picture_book.png")
 	# 土蜘蛛 
 	# 土蜘蛛 
-	I_SCA_DEMON_BOSS_1 = RuleImage(roi_front=(225,169,192,193), roi_back=(225,169,192,193), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/scales/scales_sca_demon_boss_1.png")
+	I_SCA_DEMON_BOSS_1 = RuleImage(roi_front=(209,168,192,193), roi_back=(168,142,346,290), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/scales/scales_sca_demon_boss_1.png")
 	# 胧车 
 	# 胧车 
-	I_SCA_DEMON_BOSS_2 = RuleImage(roi_front=(539,161,180,198), roi_back=(539,161,180,198), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/scales/scales_sca_demon_boss_2.png")
+	I_SCA_DEMON_BOSS_2 = RuleImage(roi_front=(457,158,180,198), roi_back=(413,136,273,250), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/scales/scales_sca_demon_boss_2.png")
 	# 荒骷髅 
 	# 荒骷髅 
-	I_SCA_DEMON_BOSS_3 = RuleImage(roi_front=(864,180,181,175), roi_back=(864,180,181,175), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/scales/scales_sca_demon_boss_3.png")
+	I_SCA_DEMON_BOSS_3 = RuleImage(roi_front=(687,178,181,175), roi_back=(631,132,344,273), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/scales/scales_sca_demon_boss_3.png")
 	# 地震鲶 
 	# 地震鲶 
-	I_SCA_DEMON_BOSS_4 = RuleImage(roi_front=(228,412,188,211), roi_back=(228,412,188,211), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/scales/scales_sca_demon_boss_4.png")
+	I_SCA_DEMON_BOSS_4 = RuleImage(roi_front=(883,162,188,211), roi_back=(804,121,315,292), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/scales/scales_sca_demon_boss_4.png")
 	# 蜃气楼 
 	# 蜃气楼 
-	I_SCA_DEMON_BOSS_5 = RuleImage(roi_front=(534,414,211,218), roi_back=(534,414,211,218), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/scales/scales_sca_demon_boss_5.png")
+	I_SCA_DEMON_BOSS_5 = RuleImage(roi_front=(326,425,211,218), roi_back=(241,414,504,242), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/scales/scales_sca_demon_boss_5.png")
 	# 歌姬 
 	# 歌姬 
-	I_SCA_DEMON_BOSS_6 = RuleImage(roi_front=(862,432,178,189), roi_back=(862,432,178,189), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/scales/scales_sca_demon_boss_6.png")
+	I_SCA_DEMON_BOSS_6 = RuleImage(roi_front=(561,432,178,189), roi_back=(437,401,555,236), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/scales/scales_sca_demon_boss_6.png")
 	# 永生之海第一个选择 
 	# 永生之海第一个选择 
 	I_SCA_SELECT_1 = RuleImage(roi_front=(189,519,113,51), roi_back=(189,519,113,51), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/scales/scales_sca_select_1.png")
 	I_SCA_SELECT_1 = RuleImage(roi_front=(189,519,113,51), roi_back=(189,519,113,51), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/scales/scales_sca_select_1.png")
 	# description 
 	# description 
@@ -257,6 +257,8 @@ class RichManAssets:
 	I_SCA_REWARD = RuleImage(roi_front=(584,503,100,100), roi_back=(584,503,100,100), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/scales/scales_sca_reward.png")
 	I_SCA_REWARD = RuleImage(roi_front=(584,503,100,100), roi_back=(584,503,100,100), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/scales/scales_sca_reward.png")
 	# 点击兑换 
 	# 点击兑换 
 	I_SCA_DEMON_BUY = RuleImage(roi_front=(861,572,180,62), roi_back=(861,572,180,62), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/scales/scales_sca_demon_buy.png")
 	I_SCA_DEMON_BUY = RuleImage(roi_front=(861,572,180,62), roi_back=(861,572,180,62), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/scales/scales_sca_demon_buy.png")
+	# 夜荒魂 
+	I_SCA_DEMON_BOSS_7 = RuleImage(roi_front=(819,489,100,100), roi_back=(640,423,412,222), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/scales/scales_sca_demon_boss_7.png")
 
 
 
 
 	# Ocr Rule Assets
 	# Ocr Rule Assets

+ 1 - 0
tasks/RichMan/mall/scales.py

@@ -202,6 +202,7 @@ class Scales(Buy, MallNavbar):
             DemonClass.NAMAZU: self.I_SCA_DEMON_BOSS_4,  # 鲶鱼
             DemonClass.NAMAZU: self.I_SCA_DEMON_BOSS_4,  # 鲶鱼
             DemonClass.SHINKIRO: self.I_SCA_DEMON_BOSS_5,  # 神木鸟
             DemonClass.SHINKIRO: self.I_SCA_DEMON_BOSS_5,  # 神木鸟
             DemonClass.GHOSTLY_SONGSTRESS: self.I_SCA_DEMON_BOSS_6,  # 歌姬
             DemonClass.GHOSTLY_SONGSTRESS: self.I_SCA_DEMON_BOSS_6,  # 歌姬
+            DemonClass.BOSS_7: self.I_SCA_DEMON_BOSS_7,  # 夜荒魂
         }
         }
         match_position = {
         match_position = {
             1: self.C_SCA_DEMON_1,
             1: self.C_SCA_DEMON_1,

+ 21 - 12
tasks/RichMan/mall/scales/image.json

@@ -29,8 +29,8 @@
   {
   {
     "itemName": "sca_demon_boss_1",
     "itemName": "sca_demon_boss_1",
     "imageName": "scales_sca_demon_boss_1.png",
     "imageName": "scales_sca_demon_boss_1.png",
-    "roiFront": "225,169,192,193",
-    "roiBack": "225,169,192,193",
+    "roiFront": "209,168,192,193",
+    "roiBack": "168,142,346,290",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "土蜘蛛"
     "description": "土蜘蛛"
@@ -38,8 +38,8 @@
   {
   {
     "itemName": "sca_demon_boss_2",
     "itemName": "sca_demon_boss_2",
     "imageName": "scales_sca_demon_boss_2.png",
     "imageName": "scales_sca_demon_boss_2.png",
-    "roiFront": "539,161,180,198",
-    "roiBack": "539,161,180,198",
+    "roiFront": "457,158,180,198",
+    "roiBack": "413,136,273,250",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "胧车"
     "description": "胧车"
@@ -47,8 +47,8 @@
   {
   {
     "itemName": "sca_demon_boss_3",
     "itemName": "sca_demon_boss_3",
     "imageName": "scales_sca_demon_boss_3.png",
     "imageName": "scales_sca_demon_boss_3.png",
-    "roiFront": "864,180,181,175",
-    "roiBack": "864,180,181,175",
+    "roiFront": "687,178,181,175",
+    "roiBack": "631,132,344,273",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "荒骷髅"
     "description": "荒骷髅"
@@ -56,8 +56,8 @@
   {
   {
     "itemName": "sca_demon_boss_4",
     "itemName": "sca_demon_boss_4",
     "imageName": "scales_sca_demon_boss_4.png",
     "imageName": "scales_sca_demon_boss_4.png",
-    "roiFront": "228,412,188,211",
-    "roiBack": "228,412,188,211",
+    "roiFront": "883,162,188,211",
+    "roiBack": "804,121,315,292",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "地震鲶"
     "description": "地震鲶"
@@ -65,8 +65,8 @@
   {
   {
     "itemName": "sca_demon_boss_5",
     "itemName": "sca_demon_boss_5",
     "imageName": "scales_sca_demon_boss_5.png",
     "imageName": "scales_sca_demon_boss_5.png",
-    "roiFront": "534,414,211,218",
-    "roiBack": "534,414,211,218",
+    "roiFront": "326,425,211,218",
+    "roiBack": "241,414,504,242",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "蜃气楼"
     "description": "蜃气楼"
@@ -74,8 +74,8 @@
   {
   {
     "itemName": "sca_demon_boss_6",
     "itemName": "sca_demon_boss_6",
     "imageName": "scales_sca_demon_boss_6.png",
     "imageName": "scales_sca_demon_boss_6.png",
-    "roiFront": "862,432,178,189",
-    "roiBack": "862,432,178,189",
+    "roiFront": "561,432,178,189",
+    "roiBack": "437,401,555,236",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "歌姬"
     "description": "歌姬"
@@ -133,5 +133,14 @@
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "点击兑换"
     "description": "点击兑换"
+  },
+  {
+    "itemName": "sca_demon_boss_7",
+    "imageName": "scales_sca_demon_boss_7.png",
+    "roiFront": "819,489,100,100",
+    "roiBack": "640,423,412,222",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "夜荒魂"
   }
   }
 ]
 ]

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


+ 2 - 0
tasks/Utils/config_enum.py

@@ -26,6 +26,8 @@ class DemonClass(str, Enum):
     SHINKIRO = '蜃气楼'
     SHINKIRO = '蜃气楼'
     # ghostly songstress 鬼灵歌伎
     # ghostly songstress 鬼灵歌伎
     GHOSTLY_SONGSTRESS = '鬼灵歌伎'
     GHOSTLY_SONGSTRESS = '鬼灵歌伎'
+    # Boss_7 夜荒魂
+    BOSS_7 = '夜荒魂'
 
 
 
 
 
 

+ 52 - 5
tasks/WantedQuests/assets.py

@@ -65,15 +65,62 @@ class WantedQuestsAssets:
 	# description 
 	# description 
 	I_WQ_INVITE_3 = RuleImage(roi_front=(754,366,39,42), roi_back=(728,339,100,100), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/invite_wq_invite_3.png")
 	I_WQ_INVITE_3 = RuleImage(roi_front=(754,366,39,42), roi_back=(728,339,100,100), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/invite_wq_invite_3.png")
 	# description 
 	# description 
-	I_WQ_FIREND_1 = RuleImage(roi_front=(245,190,175,70), roi_back=(245,190,175,70), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/invite_wq_firend_1.png")
+	I_WQ_FRIEND_1 = RuleImage(roi_front=(240,185,180,80), roi_back=(240,185,180,80), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/invite_wq_friend_1.png")
 	# description 
 	# description 
-	I_WQ_FIREND_2 = RuleImage(roi_front=(537,190,175,70), roi_back=(537,190,175,70), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/invite_wq_firend_2.png")
+	I_WQ_FRIEND_2 = RuleImage(roi_front=(530,185,180,80), roi_back=(530,185,180,80), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/invite_wq_friend_2.png")
 	# description 
 	# description 
-	I_WQ_FIREND_3 = RuleImage(roi_front=(245,286,175,70), roi_back=(245,286,175,70), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/invite_wq_firend_3.png")
+	I_WQ_FRIEND_3 = RuleImage(roi_front=(240,285,180,80), roi_back=(240,285,180,80), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/invite_wq_friend_3.png")
 	# description 
 	# description 
-	I_WQ_FIREND_4 = RuleImage(roi_front=(537,286,175,70), roi_back=(537,286,175,70), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/invite_wq_firend_4.png")
+	I_WQ_FRIEND_4 = RuleImage(roi_front=(530,285,180,80), roi_back=(530,285,180,80), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/invite_wq_friend_4.png")
 	# description 
 	# description 
-	I_WQ_FIREND_5 = RuleImage(roi_front=(245,382,175,70), roi_back=(245,382,175,70), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/invite_wq_firend_5.png")
+	I_WQ_FRIEND_5 = RuleImage(roi_front=(240,385,180,80), roi_back=(240,385,180,80), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/invite_wq_friend_5.png")
+	# 悬赏封印邀请确定按钮 
+	I_WQ_INVITE_ENSURE = RuleImage(roi_front=(500,540,132,60), roi_back=(500,540,140,65), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/wq_invite_ensure.png")
+	# 悬赏封印邀请取消按钮 
+	I_WQ_INVITE_CANCEL = RuleImage(roi_front=(230,540,132,60), roi_back=(230,540,140,65), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/wq_invite_cancel.png")
+	# 邀请好友被选中标记 
+	I_WQ_INVITE_SELECTED = RuleImage(roi_front=(380,185,32,32), roi_back=(380,185,345,350), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/wq_invite_selected.png")
+	# 邀请同服好友,由于选中与未选中亮度有区别,查找图片可能会出错,建议只使用位置信息 
+	I_WQ_INVITE_SAME_SVR = RuleImage(roi_front=(170,90,60,35), roi_back=(170,90,105,65), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/wq_invite_same_svr.png")
+	# 邀请跨服好友,由于选中与未选中亮度有区别,查找图片可能会出错,建议只使用位置信息 
+	I_WQ_INVITE_DIFF_SVR = RuleImage(roi_front=(280,90,60,35), roi_back=(280,90,105,65), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/wq_invite_diff_svr.png")
+	# 从左到右第一个协作任务的类型 
+	I_WQ_COOPERATION_TYPE_GOLD_1 = RuleImage(roi_front=(195,505,180,90), roi_back=(195,505,180,90), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/wq_cooperation_type_gold.png")
+	# 从左到右第一个协作任务的类型 
+	I_WQ_COOPERATION_TYPE_JADE_1 = RuleImage(roi_front=(195,505,180,90), roi_back=(195,505,180,90), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/wq_cooperation_type_jade.png")
+	# 从左到右第一个协作任务的类型为狗粮 
+	I_WQ_COOPERATION_TYPE_DOG_FOOD_1 = RuleImage(roi_front=(195,505,180,90), roi_back=(195,505,180,90), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/wq_cooperation_type_dog_food.png")
+	# 从左到右第一个协作任务的类型为猫粮 
+	I_WQ_COOPERATION_TYPE_CAT_FOOD_1 = RuleImage(roi_front=(195,505,180,90), roi_back=(195,505,180,90), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/wq_cooperation_type_cat_food.png")
+	# 从左到右第一个协作任务的类型 
+	I_WQ_COOPERATION_TYPE_SUSHI_1 = RuleImage(roi_front=(195,505,180,90), roi_back=(195,505,180,90), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/wq_cooperation_type_sushi.png")
+	# 从左到右第二个协作任务的类型 
+	I_WQ_COOPERATION_TYPE_GOLD_2 = RuleImage(roi_front=(490,505,180,90), roi_back=(490,505,180,90), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/wq_cooperation_type_gold.png")
+	# 从左到右第二个协作任务的类型 
+	I_WQ_COOPERATION_TYPE_JADE_2 = RuleImage(roi_front=(490,505,180,90), roi_back=(490,505,180,90), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/wq_cooperation_type_jade.png")
+	# 从左到右第二个协作任务的类型为狗粮 
+	I_WQ_COOPERATION_TYPE_DOG_FOOD_2 = RuleImage(roi_front=(490,505,180,90), roi_back=(490,505,180,90), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/wq_cooperation_type_dog_food.png")
+	# 从左到右第二个协作任务的类型为猫粮 
+	I_WQ_COOPERATION_TYPE_CAT_FOOD_2 = RuleImage(roi_front=(490,505,180,90), roi_back=(490,505,180,90), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/wq_cooperation_type_cat_food.png")
+	# 从左到右第二个协作任务的类型 
+	I_WQ_COOPERATION_TYPE_SUSHI_2 = RuleImage(roi_front=(490,505,180,90), roi_back=(490,505,180,90), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/wq_cooperation_type_sushi.png")
+	# 从左到右第三个协作任务的类型 
+	I_WQ_COOPERATION_TYPE_GOLD_3 = RuleImage(roi_front=(790,505,180,90), roi_back=(790,505,180,90), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/wq_cooperation_type_gold.png")
+	# 从左到右第三个协作任务的类型 
+	I_WQ_COOPERATION_TYPE_JADE_3 = RuleImage(roi_front=(790,505,180,90), roi_back=(790,505,180,90), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/wq_cooperation_type_jade.png")
+	# 从左到右第三个协作任务的类型为狗粮 
+	I_WQ_COOPERATION_TYPE_DOG_FOOD_3 = RuleImage(roi_front=(790,505,180,90), roi_back=(790,505,180,90), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/wq_cooperation_type_dog_food.png")
+	# 从左到右第三个协作任务的类型为猫粮 
+	I_WQ_COOPERATION_TYPE_CAT_FOOD_3 = RuleImage(roi_front=(790,505,180,90), roi_back=(790,505,180,90), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/wq_cooperation_type_cat_food.png")
+	# 从左到右第三个协作任务的类型 
+	I_WQ_COOPERATION_TYPE_SUSHI_3 = RuleImage(roi_front=(790,505,180,90), roi_back=(790,505,180,90), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/wq_cooperation_type_sushi.png")
+
+
+	# Ocr Rule Assets
+	# 邀请好友界面 好友列表第一列 
+	O_WQ_INVITE_COLUMN_1 = RuleOcr(roi=(240,185,190,340), area=(240,185,190,340), mode="FULL", method="Default", keyword="", name="wq_invite_column_1")
+	# 邀请好友界面 好友列表第二列 
+	O_WQ_INVITE_COLUMN_2 = RuleOcr(roi=(520,185,190,340), area=(520,185,190,340), mode="FULL", method="Default", keyword="", name="wq_invite_column_2")
 
 
 
 
 	# Image Rule Assets
 	# Image Rule Assets

+ 72 - 6
tasks/WantedQuests/config.py

@@ -2,7 +2,8 @@
 # @author runhey
 # @author runhey
 # github https://github.com/runhey
 # github https://github.com/runhey
 from datetime import timedelta, time
 from datetime import timedelta, time
-from pydantic import BaseModel, Field
+from enum import Enum
+from pydantic import BaseModel, Field, validator
 
 
 from tasks.Component.config_scheduler import Scheduler
 from tasks.Component.config_scheduler import Scheduler
 from tasks.Component.config_base import ConfigBase, Time
 from tasks.Component.config_base import ConfigBase, Time
@@ -10,15 +11,80 @@ from tasks.Component.GeneralBattle.config_general_battle import GeneralBattleCon
 from tasks.Component.SwitchSoul.switch_soul_config import SwitchSoulConfig
 from tasks.Component.SwitchSoul.switch_soul_config import SwitchSoulConfig
 
 
 
 
-class WantedQuestsConfig(BaseModel):
-    before_end: Time = Field(default=Time(0, 0, 0), description='before_end_help')
+class CooperationType(int, Enum):
+    """
+        用于区分悬赏封印协作类型
+    """
+    Gold = 1     #金币协作
+    Jade = 2     #勾玉协作
+    Food = 4     #狗/猫粮协作   
+    Sushi = 8    #体力协作
 
 
 
 
-class WantedQuests(ConfigBase):
-    scheduler: Scheduler = Field(default_factory=Scheduler)
-    wanted_quests_config: WantedQuestsConfig = Field(default_factory=WantedQuestsConfig)
+class CooperationSelectMask(int, Enum):
+    """
+        掩码,对协作任务进行筛选
+    """
+    NoInvite = 0                #不自动邀请
+    GoldOnly = 1                #仅 金币 协作进行邀请
+    JadeOnly = 2                #仅 勾玉 协作进行邀请
+    GoldAndJade = 3
+    FoodOnly = 4                #仅 狗/猫粮 协作进行邀请
+    GoldAndFood = 5    
+    JadeAndFood = 6
+    GoldAndJadeAndFood = 7
+    SushiOnly = 8               #仅 体力 协作进行邀请
+    GoldAndSushi = 9            
+    JadeAndSushi = 10
+    GoldAndJadeAndSushi = 11
+    FoodAndSushi = 12
+    GoldAndFoodAndSushi = 13
+    JadeAndFoodAndSushi = 14
+    Any = 15                    #所有协作任务都邀请
+
 
 
+class CooperationSelectMaskDescription(str, Enum):
+    # NoInvite = '不邀请'
+    # GoldOnly = '仅金币'
+    # JadeOnly = '仅勾协'
+    # GoldAndJade = '金币和勾协'
+    # FoodOnly = '仅食协'
+    # GoldAndFood = '金币+食协'
+    # JadeAndFood = '勾协+食协'
+    # GoldAndJadeAndFood = '金币+勾协+食协'
+    # SushiOnly = '仅体协'
+    # GoldAndSushi = '金币+体协'
+    # JadeAndSushi = '勾协+体协'
+    # GoldAndJadeAndSushi = '金币+勾协+体协'
+    # FoodAndSushi = '食协+体协'
+    # GoldAndFoodAndSushi = '金币+食协+体协'
+    # JadeAndFoodAndSushi = '勾协+食协+体协'
+    # Any = '全部'
+    NoInvite = 'NoInvite'
+    GoldOnly = 'GoldOnly'
+    JadeOnly = 'JadeOnly'
+    GoldAndJade = 'GoldAndJade'
+    FoodOnly = 'FoodOnly'
+    GoldAndFood = 'GoldAndFood'
+    JadeAndFood = 'JadeAndFood'
+    GoldAndJadeAndFood = 'GoldAndJadeAndFood'
+    SushiOnly = 'SushiOnly'
+    GoldAndSushi = 'GoldAndSushi'
+    JadeAndSushi = 'JadeAndSushi'
+    GoldAndJadeAndSushi = 'GoldAndJadeAndSushi'
+    FoodAndSushi = 'FoodAndSushi'
+    GoldAndFoodAndSushi = 'GoldAndFoodAndSushi'
+    JadeAndFoodAndSushi = 'JadeAndFoodAndSushi'
+    Any = 'Any'
 
 
 
 
+class WantedQuestsConfig(BaseModel):
+    before_end: Time = Field(default=Time(0, 0, 0), description='before_end_help')
+    invite_friend_name: str = Field(default=str(""), description="invite_friend_name_help")
+    cooperation_type: CooperationSelectMaskDescription = Field(default=CooperationSelectMaskDescription.Any, description="cooperation_type_help")
+
 
 
 
 
+class WantedQuests(ConfigBase):
+    scheduler: Scheduler = Field(default_factory=Scheduler)
+    wanted_quests_config: WantedQuestsConfig = Field(default_factory=WantedQuestsConfig)

+ 200 - 20
tasks/WantedQuests/invite/image.json

@@ -27,48 +27,228 @@
     "description": "description"
     "description": "description"
   },
   },
   {
   {
-    "itemName": "wq_firend_1",
-    "imageName": "invite_wq_firend_1.png",
-    "roiFront": "245,190,175,70",
-    "roiBack": "245,190,175,70",
+    "itemName": "wq_friend_1",
+    "imageName": "invite_wq_friend_1.png",
+    "roiFront": "240,185,180,80",
+    "roiBack": "240,185,180,80",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "description"
     "description": "description"
   },
   },
   {
   {
-    "itemName": "wq_firend_2",
-    "imageName": "invite_wq_firend_2.png",
-    "roiFront": "537,190,175,70",
-    "roiBack": "537,190,175,70",
+    "itemName": "wq_friend_2",
+    "imageName": "invite_wq_friend_2.png",
+    "roiFront": "530,185,180,80",
+    "roiBack": "530,185,180,80",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "description"
     "description": "description"
   },
   },
   {
   {
-    "itemName": "wq_firend_3",
-    "imageName": "invite_wq_firend_3.png",
-    "roiFront": "245,286,175,70",
-    "roiBack": "245,286,175,70",
+    "itemName": "wq_friend_3",
+    "imageName": "invite_wq_friend_3.png",
+    "roiFront": "240,285,180,80",
+    "roiBack": "240,285,180,80",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "description"
     "description": "description"
   },
   },
   {
   {
-    "itemName": "wq_firend_4",
-    "imageName": "invite_wq_firend_4.png",
-    "roiFront": "537,286,175,70",
-    "roiBack": "537,286,175,70",
+    "itemName": "wq_friend_4",
+    "imageName": "invite_wq_friend_4.png",
+    "roiFront": "530,285,180,80",
+    "roiBack": "530,285,180,80",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "description"
     "description": "description"
   },
   },
   {
   {
-    "itemName": "wq_firend_5",
-    "imageName": "invite_wq_firend_5.png",
-    "roiFront": "245,382,175,70",
-    "roiBack": "245,382,175,70",
+    "itemName": "wq_friend_5",
+    "imageName": "invite_wq_friend_5.png",
+    "roiFront": "240,385,180,80",
+    "roiBack": "240,385,180,80",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "description"
     "description": "description"
+  },
+  {
+    "itemName": "wq_invite_ensure",
+    "imageName": "wq_invite_ensure.png",
+    "roiFront": "500,540,132,60",
+    "roiBack": "500,540,140,65",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "悬赏封印邀请确定按钮"
+  },
+  {
+    "itemName": "wq_invite_cancel",
+    "imageName": "wq_invite_cancel.png",
+    "roiFront": "230,540,132,60",
+    "roiBack": "230,540,140,65",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "悬赏封印邀请取消按钮"
+  },
+  {
+    "itemName": "wq_invite_selected",
+    "imageName": "wq_invite_selected.png",
+    "roiFront": "380,185,32,32",
+    "roiBack": "380,185,345,350",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "邀请好友被选中标记"
+  },
+  {
+    "itemName": "wq_invite_same_svr",
+    "imageName": "wq_invite_same_svr.png",
+    "roiFront": "170,90,60,35",
+    "roiBack": "170,90,105,65",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "邀请同服好友,由于选中与未选中亮度有区别,查找图片可能会出错,建议只使用位置信息"
+  },
+  {
+    "itemName": "wq_invite_diff_svr",
+    "imageName": "wq_invite_diff_svr.png",
+    "roiFront": "280,90,60,35",
+    "roiBack": "280,90,105,65",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "邀请跨服好友,由于选中与未选中亮度有区别,查找图片可能会出错,建议只使用位置信息"
+  },
+  {
+    "itemName": "wq_cooperation_type_gold_1",
+    "imageName": "wq_cooperation_type_gold.png",
+    "roiFront": "195,505,180,90",
+    "roiBack": "195,505,180,90",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "从左到右第一个协作任务的类型"
+  },
+  {
+    "itemName": "wq_cooperation_type_jade_1",
+    "imageName": "wq_cooperation_type_jade.png",
+    "roiFront": "195,505,180,90",
+    "roiBack": "195,505,180,90",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "从左到右第一个协作任务的类型"
+  },
+  {
+    "itemName": "wq_cooperation_type_dog_food_1",
+    "imageName": "wq_cooperation_type_dog_food.png",
+    "roiFront": "195,505,180,90",
+    "roiBack": "195,505,180,90",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "从左到右第一个协作任务的类型为狗粮"
+  },
+  {
+    "itemName": "wq_cooperation_type_cat_food_1",
+    "imageName": "wq_cooperation_type_cat_food.png",
+    "roiFront": "195,505,180,90",
+    "roiBack": "195,505,180,90",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "从左到右第一个协作任务的类型为猫粮"
+  },
+  {
+    "itemName": "wq_cooperation_type_sushi_1",
+    "imageName": "wq_cooperation_type_sushi.png",
+    "roiFront": "195,505,180,90",
+    "roiBack": "195,505,180,90",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "从左到右第一个协作任务的类型"
+  },
+  {
+    "itemName": "wq_cooperation_type_gold_2",
+    "imageName": "wq_cooperation_type_gold.png",
+    "roiFront": "490,505,180,90",
+    "roiBack": "490,505,180,90",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "从左到右第二个协作任务的类型"
+  },
+  {
+    "itemName": "wq_cooperation_type_jade_2",
+    "imageName": "wq_cooperation_type_jade.png",
+    "roiFront": "490,505,180,90",
+    "roiBack": "490,505,180,90",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "从左到右第二个协作任务的类型"
+  },
+  {
+    "itemName": "wq_cooperation_type_dog_food_2",
+    "imageName": "wq_cooperation_type_dog_food.png",
+    "roiFront": "490,505,180,90",
+    "roiBack": "490,505,180,90",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "从左到右第二个协作任务的类型为狗粮"
+  },
+  {
+    "itemName": "wq_cooperation_type_cat_food_2",
+    "imageName": "wq_cooperation_type_cat_food.png",
+    "roiFront": "490,505,180,90",
+    "roiBack": "490,505,180,90",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "从左到右第二个协作任务的类型为猫粮"
+  },
+  {
+    "itemName": "wq_cooperation_type_sushi_2",
+    "imageName": "wq_cooperation_type_sushi.png",
+    "roiFront": "490,505,180,90",
+    "roiBack": "490,505,180,90",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "从左到右第二个协作任务的类型"
+  },
+  {
+    "itemName": "wq_cooperation_type_gold_3",
+    "imageName": "wq_cooperation_type_gold.png",
+    "roiFront": "790,505,180,90",
+    "roiBack": "790,505,180,90",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "从左到右第三个协作任务的类型"
+  },
+  {
+    "itemName": "wq_cooperation_type_jade_3",
+    "imageName": "wq_cooperation_type_jade.png",
+    "roiFront": "790,505,180,90",
+    "roiBack": "790,505,180,90",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "从左到右第三个协作任务的类型"
+  },
+  {
+    "itemName": "wq_cooperation_type_dog_food_3",
+    "imageName": "wq_cooperation_type_dog_food.png",
+    "roiFront": "790,505,180,90",
+    "roiBack": "790,505,180,90",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "从左到右第三个协作任务的类型为狗粮"
+  },
+  {
+    "itemName": "wq_cooperation_type_cat_food_3",
+    "imageName": "wq_cooperation_type_cat_food.png",
+    "roiFront": "790,505,180,90",
+    "roiBack": "790,505,180,90",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "从左到右第三个协作任务的类型为猫粮"
+  },
+  {
+    "itemName": "wq_cooperation_type_sushi_3",
+    "imageName": "wq_cooperation_type_sushi.png",
+    "roiFront": "790,505,180,90",
+    "roiBack": "790,505,180,90",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "从左到右第三个协作任务的类型"
   }
   }
 ]
 ]

+ 20 - 0
tasks/WantedQuests/invite/ocr.json

@@ -0,0 +1,20 @@
+[
+  {
+    "itemName": "wq_invite_column_1",
+    "roiFront": "240,185,190,340",
+    "roiBack": "240,185,190,340",
+    "mode": "FULL",
+    "method": "Default",
+    "keyword": "",
+    "description": "邀请好友界面 好友列表第一列"
+  },
+  {
+    "itemName": "wq_invite_column_2",
+    "roiFront": "520,185,190,340",
+    "roiBack": "520,185,190,340",
+    "mode": "FULL",
+    "method": "Default",
+    "keyword": "",
+    "description": "邀请好友界面 好友列表第二列"
+  }
+]

BIN
tasks/WantedQuests/invite/wq_cooperation_type_cat_food.png


BIN
tasks/WantedQuests/invite/wq_cooperation_type_dog_food.png


BIN
tasks/WantedQuests/invite/wq_cooperation_type_gold.png


BIN
tasks/WantedQuests/invite/wq_cooperation_type_jade.png


Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików