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

Merge pull request #82 from runhey/dev

Dev
huangrunheng 3 лет назад
Родитель
Сommit
fea68ec619
100 измененных файлов с 2194 добавлено и 110 удалено
  1. 126 4
      config/template.json
  2. 1 0
      module/atom/image.py
  3. 12 1
      module/config/config.py
  4. 3 3
      module/config/config_manual.py
  5. 2 1
      module/config/config_menu.py
  6. 4 0
      module/config/config_model.py
  7. BIN
      module/config/i18n/zh_CN.qm
  8. 27 0
      module/config/i18n/zh_CN.ts
  9. 80 18
      module/team_flow/host.py
  10. 59 6
      module/team_flow/mqtt.py
  11. 4 4
      module/team_flow/player.py
  12. 95 2
      module/team_flow/task.py
  13. 17 0
      tasks/CollectiveMissions/assets.py
  14. 8 2
      tasks/CollectiveMissions/config.py
  15. 67 15
      tasks/CollectiveMissions/script_task.py
  16. 11 0
      tasks/CollectiveMissions/soul/image.json
  17. 9 0
      tasks/CollectiveMissions/soul/long_click.json
  18. 20 0
      tasks/CollectiveMissions/soul/ocr.json
  19. BIN
      tasks/CollectiveMissions/soul/soul_sl_submit.png
  20. 14 7
      tasks/Component/GeneralBattle/general_battle.py
  21. 6 0
      tasks/Component/GeneralBuff/config_buff.py
  22. 1 1
      tasks/Component/GeneralRoom/assets.py
  23. 2 1
      tasks/Component/GeneralRoom/general_room.py
  24. 4 0
      tasks/Component/GeneralRoom/list.json
  25. 56 1
      tasks/Delegation/assets.py
  26. 2 0
      tasks/Delegation/config.py
  27. 32 0
      tasks/Delegation/d/click.json
  28. BIN
      tasks/Delegation/d/d_d_cancel.png
  29. BIN
      tasks/Delegation/d/d_d_confirm.png
  30. BIN
      tasks/Delegation/d/d_d_select_1.png
  31. BIN
      tasks/Delegation/d/d_d_select_2.png
  32. BIN
      tasks/Delegation/d/d_d_select_3.png
  33. BIN
      tasks/Delegation/d/d_d_select_4.png
  34. BIN
      tasks/Delegation/d/d_d_select_5.png
  35. BIN
      tasks/Delegation/d/d_d_skip.png
  36. BIN
      tasks/Delegation/d/d_d_start.png
  37. 83 0
      tasks/Delegation/d/image.json
  38. 11 0
      tasks/Delegation/d/ocr.json
  39. 38 0
      tasks/Delegation/rewards/image.json
  40. 11 0
      tasks/Delegation/rewards/ocr.json
  41. BIN
      tasks/Delegation/rewards/rewards_rewards_chat.png
  42. BIN
      tasks/Delegation/rewards/rewards_rewards_done.png
  43. BIN
      tasks/Delegation/rewards/rewards_rewards_get.png
  44. BIN
      tasks/Delegation/rewards/rewards_rewards_min.png
  45. 91 1
      tasks/Delegation/script_task.py
  46. 7 3
      tasks/Duel/assets.py
  47. BIN
      tasks/Duel/duel/duel_d_celeb_honor.png
  48. BIN
      tasks/Duel/duel/duel_d_celeb_star.png
  49. 22 4
      tasks/Duel/duel/image.json
  50. 2 2
      tasks/Duel/duel/ocr.json
  51. 9 2
      tasks/Duel/script_task.py
  52. 40 0
      tasks/EternitySea/script_task.py
  53. 31 0
      tasks/ExperienceYoukai/script_task.py
  54. 1 1
      tasks/GameUi/assets.py
  55. 2 2
      tasks/GameUi/page/page_img_3.json
  56. 1 0
      tasks/GoldYoukai/script_task.py
  57. 2 1
      tasks/MysteryShop/config.py
  58. 29 5
      tasks/MysteryShop/script_task.py
  59. 1 1
      tasks/Pets/assets.py
  60. 2 2
      tasks/Pets/pet/image.json
  61. BIN
      tasks/Pets/pet/pet_pet_house.png
  62. 3 1
      tasks/Secret/assets.py
  63. 54 12
      tasks/Secret/script_task.py
  64. 2 2
      tasks/Secret/se/image.json
  65. 9 0
      tasks/Secret/se/ocr.json
  66. 1 1
      tasks/Tako/assets.py
  67. 23 0
      tasks/Tako/config.py
  68. 141 0
      tasks/Tako/script_task.py
  69. 4 0
      tasks/TrueOrochi/assets.py
  70. 2 2
      tasks/TrueOrochi/config.py
  71. 151 2
      tasks/TrueOrochi/script_task.py
  72. 18 0
      tasks/TrueOrochi/st/image.json
  73. BIN
      tasks/TrueOrochi/st/st_st_create_room.png
  74. BIN
      tasks/TrueOrochi/st/st_st_frame.png
  75. 103 0
      tasks/WantedQuests/assets.py
  76. BIN
      tasks/WantedQuests/chanllenge/chanllenge_wqc_fire.png
  77. BIN
      tasks/WantedQuests/chanllenge/chanllenge_wqc_lock.png
  78. BIN
      tasks/WantedQuests/chanllenge/chanllenge_wqc_unlock.png
  79. 29 0
      tasks/WantedQuests/chanllenge/image.json
  80. 24 0
      tasks/WantedQuests/config.py
  81. 74 0
      tasks/WantedQuests/invite/image.json
  82. BIN
      tasks/WantedQuests/invite/invite_wq_invite_1.png
  83. BIN
      tasks/WantedQuests/invite/invite_wq_invite_2.png
  84. BIN
      tasks/WantedQuests/invite/invite_wq_invite_3.png
  85. 128 0
      tasks/WantedQuests/ocr.json
  86. 262 0
      tasks/WantedQuests/script_task.py
  87. 110 0
      tasks/WantedQuests/wq/image.json
  88. 11 0
      tasks/WantedQuests/wq/se_image.json
  89. BIN
      tasks/WantedQuests/wq/wq_goto_1.png
  90. BIN
      tasks/WantedQuests/wq/wq_goto_2.png
  91. BIN
      tasks/WantedQuests/wq/wq_goto_3.png
  92. BIN
      tasks/WantedQuests/wq/wq_goto_4.png
  93. BIN
      tasks/WantedQuests/wq/wq_tarce_disenable.png
  94. BIN
      tasks/WantedQuests/wq/wq_trace_enable.png
  95. BIN
      tasks/WantedQuests/wq/wq_trace_false.png
  96. BIN
      tasks/WantedQuests/wq/wq_trace_true.png
  97. BIN
      tasks/WantedQuests/wq/wq_wq_box.png
  98. BIN
      tasks/WantedQuests/wq/wq_wq_check_task.png
  99. BIN
      tasks/WantedQuests/wq/wq_wq_done.png
  100. BIN
      tasks/WantedQuests/wq/wq_wq_seal.png

+ 126 - 4
config/template.json

@@ -50,6 +50,15 @@
       "when_network_abnormal": "wait_10s",
       "when_network_error": "restart",
       "home_client_clear": true
+    },
+    "team_flow": {
+      "enable": false,
+      "broker": "",
+      "port": 8883,
+      "transport": "TCP",
+      "ca": "",
+      "username": "",
+      "password": ""
     }
   },
   "area_boss": {
@@ -304,6 +313,7 @@
       "server_update": "09:00:00"
     },
     "delegation_config": {
+      "miyoshino_painting": false,
       "bird_feather": false,
       "find_earring": false,
       "cat_boss": false,
@@ -311,6 +321,78 @@
       "strange_trace": false
     }
   },
+  "exploration": {
+    "scheduler": {
+      "enable": false,
+      "next_run": "2023-01-01 00:00:00",
+      "priority": 5,
+      "success_interval": "01 00:00:00",
+      "failure_interval": "01 00:00:00",
+      "server_update": "09:00:00"
+    },
+    "exploration_config": {
+      "buff_gold_50_click": false,
+      "buff_gold_100_click": false,
+      "attack_number": "7",
+      "current_exploration_times": "0",
+      "exploration_level": "第二十八章",
+      "auto_rotate": "不",
+      "choose_rarity": "N卡"
+    },
+    "general_battle_config": {
+      "lock_team_enable": false,
+      "preset_enable": false,
+      "preset_group": 1,
+      "preset_team": 1,
+      "green_enable": false,
+      "green_mark": "green_left1",
+      "random_click_swipt_enable": false
+    },
+    "switch_soul_config": {
+      "enable": false,
+      "switch_group_team": "-1,-1",
+      "enable_switch_by_name": false,
+      "group_name": "",
+      "team_name": ""
+    }
+  },
+  "wanted_quests": {
+    "scheduler": {
+      "enable": false,
+      "next_run": "2023-01-01 00:00:00",
+      "priority": 5,
+      "success_interval": "01 00:00:00",
+      "failure_interval": "01 00:00:00",
+      "server_update": "09:00:00"
+    },
+    "wanted_quests_config": {
+      "before_end": "00:00:00"
+    }
+  },
+  "tako": {
+    "scheduler": {
+      "enable": false,
+      "next_run": "2023-01-01 00:00:00",
+      "priority": 5,
+      "success_interval": "01 00:00:00",
+      "failure_interval": "01 00:00:00",
+      "server_update": "09:00:00"
+    },
+    "tako_config": {
+      "enable": false,
+      "buff_gold_50_click": false,
+      "buff_gold_100_click": false,
+      "buff_exp_50_click": false,
+      "buff_exp_100_click": false
+    },
+    "switch_soul": {
+      "enable": false,
+      "switch_group_team": "-1,-1",
+      "enable_switch_by_name": false,
+      "group_name": "",
+      "team_name": ""
+    }
+  },
   "orochi": {
     "scheduler": {
       "enable": false,
@@ -374,7 +456,12 @@
     "sougenbi_config": {
       "sougenbi_class": "痴",
       "limit_time": "00:30:00",
-      "limit_count": 30
+      "limit_count": 30,
+      "buff_enable": false,
+      "buff_gold_50_click": false,
+      "buff_gold_100_click": false,
+      "buff_exp_50_click": false,
+      "buff_exp_100_click": false
     },
     "general_battle_config": {
       "lock_team_enable": false,
@@ -401,6 +488,36 @@
       "success_interval": "01 00:00:00",
       "failure_interval": "01 00:00:00",
       "server_update": "09:00:00"
+    },
+    "fallen_sun_config": {
+      "user_status": "leader",
+      "layer": "叁层",
+      "limit_time": "00:30:00",
+      "limit_count": 50
+    },
+    "invite_config": {
+      "invite_number": "one",
+      "friend_1": "",
+      "friend_2": "",
+      "find_mode": "auto_find",
+      "wait_time": "00:02:00",
+      "default_invite": true
+    },
+    "general_battle_config": {
+      "lock_team_enable": false,
+      "preset_enable": false,
+      "preset_group": 1,
+      "preset_team": 1,
+      "green_enable": false,
+      "green_mark": "green_left1",
+      "random_click_swipt_enable": false
+    },
+    "switch_soul": {
+      "enable": false,
+      "switch_group_team": "-1,-1",
+      "enable_switch_by_name": false,
+      "group_name": "",
+      "team_name": ""
     }
   },
   "eternity_sea": {
@@ -411,6 +528,12 @@
       "success_interval": "01 00:00:00",
       "failure_interval": "01 00:00:00",
       "server_update": "09:00:00"
+    },
+    "eternity_sea_config": {
+      "user_status": "leader",
+      "layer": "肆层",
+      "limit_time": "00:30:00",
+      "limit_count": 50
     }
   },
   "activity_shikigami": {
@@ -552,8 +675,6 @@
     },
     "true_orochi_config": {
       "find_true_orochi": true,
-      "green_enable": false,
-      "green_mark_type": "left_1",
       "current_success": 0
     }
   },
@@ -696,6 +817,7 @@
       "server_update": "09:00:00"
     },
     "shop_config": {
+      "time_of_mystery": "00:00:00",
       "mystery_amulet": false,
       "black_daruma_scrap": false,
       "shop_kaiko_3": false,
@@ -738,7 +860,7 @@
       "server_update": "09:00:00"
     },
     "missions_config": {
-      "missions_rule": "契灵 > 觉醒二 > 觉醒一 > 御灵二 > 御灵一 > 御魂五 > 御魂四"
+      "missions_rule": "契灵 > 觉醒三 > 觉醒二 > 觉醒一 > 御灵二 > 御灵一 > 御魂二 > 御魂一"
     }
   },
   "hunt": {

+ 1 - 0
module/atom/image.py

@@ -118,6 +118,7 @@ class RuleImage:
         mat = self.image
         res = cv2.matchTemplate(source, mat, cv2.TM_CCOEFF_NORMED)
         min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res)  # 最小匹配度,最大匹配度,最小匹配度的坐标,最大匹配度的坐标
+        # logger.attr(self.name, max_val)
         if max_val > threshold:
             self.roi_front[0] = max_loc[0] + self.roi_back[0]
             self.roi_front[1] = max_loc[1] + self.roi_back[1]

+ 12 - 1
module/config/config.py

@@ -8,6 +8,7 @@ import threading
 
 from datetime import datetime, timedelta
 from cached_property import cached_property
+from threading import Lock
 
 from module.base.filter import Filter
 from module.config.config_updater import ConfigUpdater
@@ -119,6 +120,10 @@ class Config(ConfigState, ConfigManual, ConfigWatcher, ConfigMenu):
             # logger.error(f'can not ask this variable {name}')
             return None  # 或者抛出异常,或者返回其他默认值
 
+    @cached_property
+    def lock_config(self) -> Lock:
+        return Lock()
+
     def gui_args(self, task: str) -> str:
         """
         获取给gui显示的参数
@@ -315,9 +320,15 @@ class Config(ConfigState, ConfigManual, ConfigWatcher, ConfigMenu):
         if server and scheduler.server_update != time(hour=9):
             next_run = parse_tomorrow_server(scheduler.server_update)
 
+
+        # 保证线程安全的
+        self.lock_config.acquire()
+        try:
+            scheduler.next_run = next_run
+        finally:
+            self.lock_config.release()
         # 设置
         logger.attr(f'{task}.scheduler.next_run', next_run)
-        scheduler.next_run = next_run
         self.save()
 
     @cached_property

+ 3 - 3
module/config/config_manual.py

@@ -10,10 +10,10 @@ class ConfigManual:
     SCHEDULER_PRIORITY = """
         Restart
         >KekkaiUtilize > KekkaiActivation > DemonEncounter
-        > AreaBoss > GoldYoukai > ExperienceYoukai > Nian > RealmRaid > RyouToppa > DailyTrifles > Exploration
-        > Hunt
+        > AreaBoss > GoldYoukai > ExperienceYoukai > Nian > Tako > RealmRaid > RyouToppa > DailyTrifles > Exploration
+        > Hunt 
         > Orochi > OrochiMoans > OrochiJudgement > Sougenbi > FallenSun > EternitySea
-        > ActivityShikigami
+        > ActivityShikigami > WantedQuests
         > BondlingFairyland > EvoZone > GoryouRealm
         > TrueOrochi > RichMan
         > CollectiveMissions

+ 2 - 1
module/config/config_menu.py

@@ -21,7 +21,8 @@ class ConfigMenu:
         self.menu["Soul Zones"] = ['Orochi', 'Sougenbi', 'FallenSun', 'EternitySea']
         # 日常的任务
         self.menu["Daily Task"] = ['DailyTrifles', 'AreaBoss', 'GoldYoukai', 'ExperienceYoukai', 'Nian',
-                                   'TalismanPass', 'DemonEncounter', 'Pets', 'SoulsTidy', 'Delegation']
+                                   'TalismanPass', 'DemonEncounter', 'Pets', 'SoulsTidy', 'Delegation', 'WantedQuests',
+                                   'Tako']
         # 很肝的任务
         self.menu["Liver Emperor Exclusive"] = ['BondlingFairyland', 'EvoZone', 'GoryouRealm', 'Exploration']
         # 阴阳寮

+ 4 - 0
module/config/config_model.py

@@ -29,6 +29,8 @@ from tasks.TalismanPass.config import TalismanPass
 from tasks.Pets.config import Pets
 from tasks.SoulsTidy.config import SoulsTidy
 from tasks.Delegation.config import Delegation
+from tasks.WantedQuests.config import WantedQuests
+from tasks.Tako.config import Tako
 # ----------------------------------------------------------------------------------------------------------------------
 from tasks.Orochi.config import Orochi
 from tasks.OrochiMoans.config import OrochiMoans
@@ -80,6 +82,8 @@ class ConfigModel(ConfigBase):
     souls_tidy: SoulsTidy = Field(default_factory=SoulsTidy)
     delegation: Delegation = Field(default_factory=Delegation)
     exploration: Exploration = Field(default_factory=Exploration)
+    wanted_quests: WantedQuests = Field(default_factory=WantedQuests)
+    tako: Tako = Field(default_factory=Tako)
 
     # 这些是刷御魂的
     orochi: Orochi = Field(default_factory=Orochi)

BIN
module/config/i18n/zh_CN.qm


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

@@ -173,6 +173,7 @@
 	<message><source>GlobalGame</source><translation>全局游戏设置</translation></message>
 	<message><source>RealmRaid</source><translation>个人突破</translation></message>
 	<message><source>RyouToppa</source><translation>寮突破</translation></message>
+	<message><source>Exploration</source><translation>探索</translation></message>
 	<message><source>List Rule</source><translation>列表规则</translation></message>
 	<message><source>Activity Task</source><translation>限时活动</translation></message>
 	<message><source>ActivityShikigami</source><translation>当期式神爬塔</translation></message>
@@ -198,6 +199,8 @@
 	<message><source>Hunt</source><translation>狩猎战</translation></message>
 	<message><source>MysteryShop</source><translation>神秘商店</translation></message>
 	<message><source>Duel</source><translation>斗技</translation></message>
+	<message><source>WantedQuests</source><translation>悬赏封印</translation></message>
+	<message><source>Tako</source><translation>石距</translation></message>
 </context>
 <context>
     <name>TaskList</name>
@@ -242,6 +245,8 @@
 	<message><source>Hunt</source><translation>狩猎战</translation></message>
 	<message><source>MysteryShop</source><translation>神秘商店</translation></message>
 	<message><source>Duel</source><translation>斗技</translation></message>
+	<message><source>WantedQuests</source><translation>悬赏封印</translation></message>
+	<message><source>Tako</source><translation>石距</translation></message>
 </context>
 <context>
     <name>Args</name>
@@ -704,4 +709,26 @@ Refresh:直接刷新,如果刷新操作进入CD,将标记为失败并退
 	<message><source>Greed Maneki</source><translation>贪吃鬼喂食+未升级的御魂奉纳</translation></message>	
 	<message><source>greed_maneki_help</source><translation>建议四星及一下的吃掉,五星的留给贪吃鬼</translation></message>
 </context>
+<context>
+    <name>Args</name>
+	<message><source>DelegationConfig</source><translation>委派</translation></message>	
+	<message><source>Bird Feather</source><translation>鸟之羽</translation></message>	
+	<message><source>bird_feather_help</source><translation>50体力->20片大蛇的逆鳞</translation></message>
+	<message><source>Find Earring</source><translation>寻找耳环</translation></message>	
+	<message><source>find_earring_help</source><translation>300体力->金币28万</translation></message>
+	<message><source>Cat Boss</source><translation>猫老大</translation></message>	
+	<message><source>cat_boss_help</source><translation>300体力->四星白蛋</translation></message>
+	<message><source>Miyoshino</source><translation>接送弥助</translation></message>	
+	<message><source>miyoshino_help</source><translation>100体力->三星结界卡</translation></message>
+	<message><source>Strange Trace</source><translation>奇怪的痕迹</translation></message>	
+	<message><source>strange_trace_help</source><translation>100体力->金币九万八</translation></message>
+	<message><source>Miyoshino Painting</source><translation>弥助的画</translation></message>	
+	<message><source>miyoshino_painting_help</source><translation>300体力->六星变异卡</translation></message>
+	<message><source>WantedQuestsConfig</source><translation>悬赏</translation></message>
+	<message><source>Before End</source><translation>强制设定悬赏刷新前 X 分钟执行</translation></message>
+	<message><source>before_end_help</source><translation>默认'00:00:00'表示不使用这个功能,不可取负值,建议最后一小时才执行悬赏'01:00:00'</translation></message>
+	<message><source>Time Of Mystery</source><translation>强制设定出现神秘商店当天的执行时间</translation></message>
+	<message><source>time_of_mystery_help</source><translation>限定[00:00:01-23:30:00],这将使你无视掉调度器的Interval。保持默认'00:00:00'表示不使用</translation></message>
+	<message><source>TakoConfig</source><translation>石距加成</translation></message>
+</context>
 </TS>

+ 80 - 18
module/team_flow/host.py

@@ -1,6 +1,8 @@
 # This Python file uses the following encoding: utf-8
 # @author runhey
 # github https://github.com/runhey
+import json
+from time import sleep
 from datetime import datetime, time
 from cached_property import cached_property
 
@@ -13,7 +15,17 @@ from module.team_flow.task import Task
 from module.logger import logger
 
 def on_message(client, userdata, msg):
-    userdata.match_topic[msg.topic](msg.payload)
+    try:
+        data = json.loads(msg.payload)
+    except json.JSONDecodeError:
+        logger.error(f'Get [{msg.topic}]: {msg.payload}')
+        return
+    logger.info(f'Get {msg.topic}: {data}')
+    for username, data in data.items():
+        # 反正只有一项
+        if username == userdata.username:
+            continue
+        userdata.match_topic[msg.topic](username, data)
 
 class Host(Mqtt, Player):
 
@@ -33,25 +45,45 @@ class Host(Mqtt, Player):
             'Strategy': self.on_strategy
         }
 
-    def on_first_notice(self, payload):
+    def on_first_notice(self, player: str, data: dict):
+        # 其他人上线,就广播自己的策略出去
+        if 'type' in data:
+            logger.info(f'Player {player} is online')
+            self.q_publish.put(['Strategy', self.publish_data()])
+        else:
+            # 如果是其他人像
+            pass
+
+    def on_last_will(self, player: str, data: dict):
+        if player not in self.players:
+            logger.warning(f'Player {player} is not in players')
+            return
+        self.players.remove(player)
+        logger.info(f'Player {player} is offline')
+        self._config_to_player()
+        self._update_strategy()
+        self._player_to_config()
+        self.q_publish.put(['Strategy', self.publish_data()])
+
+    def on_task_start(self, player: str, data: dict):
         pass
 
-    def on_last_will(self, payload):
+    def on_strategy(self, player: str, data: dict):
         pass
 
-    def on_task_start(self, payload):
-        pass
-
-    def on_strategy(self, payload):
-        pass
-
-    def update_multi_tasks(self):
+    def _config_to_player(self):
         """
         作为主角, 更新自身的多人任务的缓存
         也就是从  config -> multi_tasks
         :return:
         """
-        for key, value in self.config.model.items():
+        tasks = {'orochi': self.config.model.orochi,
+                 'fallen_sun': self.config.model.fallen_sun,
+                 'eternity_sea': self.config.model.eternity_sea,
+                 'evo_zone': self.config.model.evo_zone,
+                 'exploration': self.config.model.exploration
+                 }
+        for key, value in tasks.items():
             task_name: str = key
             limit_time: time = None
             limit_count: int = None
@@ -76,7 +108,7 @@ class Host(Mqtt, Player):
                 # TODO 等待探索完成
                 limit_time = time(minute=30)
                 limit_count = 50
-                role = str(value.evo_zone_config.user_status)
+                role = 'leader'
                 continue
             else:
                 continue
@@ -84,10 +116,10 @@ class Host(Mqtt, Player):
                 continue
             if task_name not in self.multi_tasks:
                 # 第一次
-                logger.info(f'First time to add {task_name} to multi_tasks')
+                logger.info(f'First time to add [{task_name}] to multi_tasks')
                 self.multi_tasks[task_name] = Task(
                     next_run=value.scheduler.next_run,
-                    target_run=value.scheduler.target_run,
+                    target_run=value.scheduler.next_run,
                     limit_time=limit_time,
                     team_task=True,
                     role=role,
@@ -96,14 +128,44 @@ class Host(Mqtt, Player):
             else:
                 # 更新
                 logger.info(f'Update {task_name} to multi_tasks')
-                self.multi_tasks[task_name].next_run = value.scheduler.next_run
-                self.multi_tasks[task_name].limit_time = limit_time
-                self.multi_tasks[task_name].role = role
-                self.multi_tasks[task_name].limit_count = limit_count
+                self.multi_tasks[task_name].update_info(next_run=value.scheduler.next_run,
+                                                        limit_time=limit_time,
+                                                        role=role,
+                                                        limit_count=limit_count)
 
+    def _player_to_config(self):
+        for key, value in self.multi_tasks.items():
+            if key == 'orochi':
+                self.config.task_delay(task='Orochi', target=value.next_run)
+            elif key == 'fallen_sun':
+                self.config.task_delay(task='FallenSun', target=value.next_run)
+            elif key == 'eternity_sea':
+                self.config.task_delay(task='EternitySea', target=value.next_run)
+            elif key == 'evo_zone':
+                self.config.task_delay(task='EvoZone', target=value.next_run)
+            elif key == 'exploration':
+                # TODO 等待探索完成
+                pass
+            else:
+                continue
+
+    def _update_strategy(self):
+        """
+        更新策略:
+        :return:
+        """
+        pass
 
 
 
 
 if __name__ == '__main__':
     host = Host(Config('oas1'))
+    sleep(20)
+    # 更新config -> multi_tasks -> publish_data
+    host._config_to_player()
+    host.q_publish.put(['Strategy' ,host.publish_data()])
+    host.q_publish.put(['Strategy' ,host.publish_data()])
+    host.q_publish.put(['Strategy' ,host.publish_data()])
+    sleep(46)
+

+ 59 - 6
module/team_flow/mqtt.py

@@ -2,18 +2,22 @@
 # @author runhey
 # github https://github.com/runhey
 from time import sleep
+
+import json
 from random import randint
 from paho.mqtt import client as mqtt_client
+from threading import Thread
+from queue import Queue
 
 from tasks.GlobalGame.config import TeamFlow, Transport
 
 from module.logger import logger
+from module.base.timer import Timer
 
 
 def on_message(client, userdata, msg):
     if msg.topic == 'FirstNotice':
         return
-
     logger.info(f"Received `{msg.payload}` from `{userdata}` ")
 # ----------------------------------------------------------------------------------------------------------------------
 # 使用MQTT是为了做广播,自己手撸的话太麻烦了
@@ -22,13 +26,31 @@ def on_message(client, userdata, msg):
 # 2. 当一个玩家退出网络后,会向服务器发送LastNotice,这个时候所有的玩家都要更新自己的策略
 # ----------------------------------------------------------------------------------------------------------------------
 class Mqtt:
+    # 队列的结构必须是一个tuple,第一个元素是topic,第二个元素是msg
+    q_publish: Queue = None
 
     def __init__(self, team_flow: TeamFlow):
         def on_connect(client, userdata, flags, rc):
             if rc == 0:
                 logger.info("Connected to MQTT Broker!")
+            elif rc == 1:
+                # 协议版本错误
+                logger.error(f"Connection refused - incorrect protocol version. return code: {rc}")
+            elif rc == 2:
+                # 无效的客户端标识
+                logger.error(f"Connection refused - invalid client identifier. return code: {rc}")
+            elif rc == 3:
+                # 服务器不可用
+                logger.error(f"Connection refused - server unavailable. return code: {rc}")
+            elif rc == 4:
+                # 错误的用户名或密码
+                logger.error(f"Connection refused - bad username or password. return code: {rc}")
+            elif rc == 5:
+                # 未授权
+                logger.error(f"Connection refused - not authorised. return code: {rc}")
             else:
                 logger.info("Failed to connect, return code %d\n", rc)
+        self.q_publish = Queue()
         self.broker = team_flow.broker
         self.port = team_flow.port
         self.protocol = team_flow.transport
@@ -43,16 +65,20 @@ class Mqtt:
         self.client.username_pw_set(self.username, self.password)
         self.client.on_connect = on_connect
         self.client.on_message = on_message
-        self.client.will_set(topic='LastWill', payload=self.username, qos=2)
+        self.client.will_set(topic='LastWill', payload=json.dumps({self.username: ""}), qos=2)
         self.client.connect(self.broker, self.port)
         # 订阅主题: FirstNotice LastWill TaskStart Strategy
         self.client.subscribe(topic='FirstNotice', qos=2)
         self.client.subscribe(topic='LastWill', qos=2)
         self.client.subscribe(topic='TaskStart', qos=0)
         self.client.subscribe(topic='Strategy', qos=0)
-        self.client.loop_start()
         # publish FirstNotice
-        self.publish('FirstNotice', {'player': self.username})
+        self.publish("FirstNotice", {"type": "join"})
+        # 开启一个线程来处理消息
+        self.mqtt_timer = Timer(30)
+        self.mqtt_timer.start()
+        self.mqtt_thread = Thread(target=self.mqtt_loop, name='mqtt_loop', daemon=True)
+        self.mqtt_thread.start()
 
 
 
@@ -69,11 +95,12 @@ class Mqtt:
         if not isinstance(msg, dict):
             logger.warning(f"Msg must be a dict, but got {type(msg)}")
             return False
-        result = self.client.publish(topic, str(msg))
+        msg = {self.username: msg}
+        result = self.client.publish(topic, json.dumps(msg))
         # result: [0, 1]
         status = result[0]
         if status == 0:
-            logger.info(f"Send `{msg}` to topic `{topic}`")
+            logger.info(f"Send `msg` to topic `{topic}`")
             return True
         else:
             logger.info(f"Failed to send message to topic {topic} {status}")
@@ -85,6 +112,32 @@ class Mqtt:
     def Strategy(self, msg):
         self.publish('Strategy', msg)
 
+    def mqtt_loop(self):
+        while True:
+            # sleep(5)
+            # 官方超级不推荐这种方式来处理消息。 但是不打算开一个线程来处理这个mqtt_timer
+            try:
+                self.client.loop(timeout=5)
+            except Exception as e:
+                logger.error(e)
+
+            if not self.mqtt_timer.reached():
+                continue
+            self.mqtt_timer.reset()
+            publish_strategy_msg = None
+            while not self.q_publish.empty():
+                try:
+                    topic, msg = self.q_publish.get(block=False)
+                except Exception as e:
+                    continue
+                if topic == 'Strategy':
+                    publish_strategy_msg = msg
+                    continue
+                self.publish(topic, msg)
+            if publish_strategy_msg:
+                # 先进先出 保证只发送一次最新的
+                self.publish('Strategy', publish_strategy_msg)
+
 
 
 

+ 4 - 4
module/team_flow/player.py

@@ -25,9 +25,9 @@ class Player:
             item = {}
             if not task.team_task:
                 continue
-            item['next_run'] = task.next_run
-            item['role'] = task.role
-            item['limit_time'] = task.limit_time
-            item['limit_count'] = task.limit_count
+            item['next_run'] = str(task.next_run)
+            item['role'] = str(task.role)
+            item['limit_time'] = str(task.limit_time)
+            item['limit_count'] = int(task.limit_count)
             result[name] = item
         return result

+ 95 - 2
module/team_flow/task.py

@@ -2,12 +2,13 @@
 # @author runhey
 # github https://github.com/runhey
 from time import sleep
-from datetime import datetime, time
+from datetime import datetime, time, timedelta
 from random import randint
 
-
 from module.config.config import Config
 
+from tasks.Component.config_base import TimeDelta
+
 
 class Task:
     def __init__(self,
@@ -25,9 +26,101 @@ class Task:
         self.role = role
         self.limit_count = limit_count
 
+    def update_info(self,
+                    next_run: datetime,
+                    limit_time: time,
+                    limit_count: int,
+                    role: str):
+        # next_run
+        if isinstance(next_run, datetime):
+            self.next_run = next_run
+        elif isinstance(next_run, str):
+            self.next_run = datetime.fromisoformat(next_run)
+        else:
+            raise TypeError(f'next_run must be datetime or str, not {type(next_run)}')
+        # limit_count
+        if isinstance(limit_count, int):
+            self.limit_count = limit_count
+        elif isinstance(limit_count, str):
+            self.limit_count = int(limit_count)
+        else:
+            raise TypeError(f'limit_count must be int or str, not {type(limit_count)}')
+        # limit_time
+        if isinstance(limit_time, time):
+            self.limit_time = limit_time
+        elif isinstance(limit_time, str):
+            self.limit_time = time.fromisoformat(limit_time)
+        else:
+            raise TypeError(f'limit_time must be time or str, not {type(limit_time)}')
+        # role
+        if isinstance(role, str):
+            self.role = role
+        else:
+            raise TypeError(f'role must be str, not {type(role)}')
+
+    # ----------------------------------------------------------------------------------------------------------------------
+    # 对于host来进行操作的函数
+    def u(self) -> float:
+        """
+        效用函数
+        :return:
+        """
+        if self.role == 'leader':
+            return self.r_leader() - self.r_leader()
+        elif self.role == 'member':
+            return self.r_member() - self.c_member()
+
+    def r_leader(self, tasks: list['Task']) -> float:
+        """
+        收益函数
+        :param tasks: 在小组内的启用的同一任务列表
+        :return:
+        """
+        result = 0
+        for task in tasks:
+            if task.role == 'leader':
+                pass
+
+        return result
+
+    def c_leader(self) -> float:
+        """
+        成本函数
+        :return:
+        """
+
+    def r_member(self) -> float:
+        """
+        收益函数
+        :return:
+        """
+
+    def c_member(self) -> float:
+        """
+        成本函数
+        :return:
+        """
 
 
+def t_diff(before: Task, after: Task) -> timedelta:
+    """
+    计算两个任务之间的时间差
+    :param before:
+    :param after:
+    :return: 单位是秒
+    """
+    return (after.next_run - before.next_run).total_seconds()
 
 
+if __name__ == '__main__':
+    host = Task(next_run=datetime.fromisoformat('2023-09-13 18:46:23'),
+                limit_time=time.fromisoformat('00:30:00'),
+                target_run=datetime.fromisoformat('2023-09-13 18:46:23'),
+                team_task=True, role='leader', limit_count=0)
 
+    test1 = Task(next_run=datetime.fromisoformat('2023-09-13 18:44:23'),
+                 limit_time=time.fromisoformat('00:30:00'),
+                 target_run=datetime.fromisoformat('2023-09-13 18:46:23'),
+                 team_task=True, role='leader', limit_count=0)
 
+    print(t_diff(host, test1))

+ 17 - 0
tasks/CollectiveMissions/assets.py

@@ -78,3 +78,20 @@ class CollectiveMissionsAssets:
 	S_CM_MATTER_4 = RuleSwipe(roi_front=(689,524,21,22), roi_back=(903,518,46,32), mode="default", name="cm_matter_4")
 
 
+	# Image Rule Assets
+	# 提交 
+	I_SL_SUBMIT = RuleImage(roi_front=(835,588,145,61), roi_back=(835,588,145,61), threshold=0.8, method="Template matching", file="./tasks/CollectiveMissions/soul/soul_sl_submit.png")
+
+
+	# Long Click Rule Assets
+	# 长按 
+	L_SL_LONG = RuleLongClick(roi_front=(178,194,58,49), roi_back=(178,194,58,49), duration=1500, name="sl_long")
+
+
+	# Ocr Rule Assets
+	# +0 级 
+	O_SL_LEVEL = RuleOcr(roi=(174,139,30,24), area=(174,139,30,24), mode="Single", method="Default", keyword="古", name="sl_level")
+	# 将提交xx次任务 
+	O_SL_NUMBER = RuleOcr(roi=(813,94,187,39), area=(813,94,187,39), mode="Single", method="Default", keyword="", name="sl_number")
+
+

+ 8 - 2
tasks/CollectiveMissions/config.py

@@ -2,7 +2,7 @@
 # @author runhey
 # github https://github.com/runhey
 from datetime import timedelta
-from pydantic import BaseModel, Field
+from pydantic import BaseModel, Field, validator
 
 from tasks.Component.config_base import MultiLine
 from tasks.Component.config_scheduler import Scheduler
@@ -14,9 +14,15 @@ from tasks.Component.SwitchSoul.switch_soul_config import SwitchSoulConfig
 
 class MissionsConfig(BaseModel):
     # 契灵 > 觉醒二 > 觉醒一 > 御灵二 > 御灵一 > 御魂五 > 御魂四
-    missions_rule: MultiLine = Field(default='契灵 > 觉醒三 > 觉醒二 > 觉醒一 > 御灵二 > 御灵一 > 御魂五 > 御魂四',
+    missions_rule: MultiLine = Field(default='契灵 > 觉醒三 > 觉醒二 > 觉醒一 > 御灵二 > 御灵一 > 御魂二 > 御魂一',
                                      description='missions_rule_help')
 
+    @validator('missions_rule', pre=True, always=True)
+    def mr_validator(cls, v):
+        if isinstance(v, str):
+            return v.replace('御魂五', '御魂二').replace('御魂四', '御魂一')
+        return v
+
 
 class CollectiveMissions(ConfigBase):
     scheduler: Scheduler = Field(default_factory=Scheduler)

+ 67 - 15
tasks/CollectiveMissions/script_task.py

@@ -2,6 +2,7 @@
 # @author runhey
 # github https://github.com/runhey
 import time
+import random
 import re
 from cached_property import cached_property
 from enum import Enum
@@ -24,8 +25,8 @@ class MC(str, Enum):
     AW3 = '觉醒三'
     GR1 = '御灵一'
     GR2 = '御灵二'
-    SO4 = '御魂四'
-    SO5 = '御魂五'
+    SO1 = '御魂一'
+    SO2 = '御魂二'
     FRIEND = '好友'
     UNKNOWN = '未知'
 
@@ -66,10 +67,9 @@ class ScriptTask(GameUi, CollectiveMissionsAssets):
         elif mission == MC.AW1 or mission == MC.AW2 or mission == MC.AW3 or mission == MC.GR1 or mission == MC.GR2:
             # 其他就捐材料
             self._donate(index)
-        elif mission == MC.SO4 or mission == MC.SO5:
+        elif mission == MC.SO1 or mission == MC.SO2:
             # 御魂就捐御魂
-            # TODO
-            logger.warning('Not support donate soul')
+            self._soul(index)
 
         # 退出
         while 1:
@@ -114,10 +114,10 @@ class ScriptTask(GameUi, CollectiveMissionsAssets):
             return MC.GR1
         elif result_2 == '御灵二':
             return MC.GR2
-        elif result_2 == '御魂四':
-            return MC.SO4
-        elif result_2 == '御魂五':
-            return MC.SO5
+        elif result_2 == '御魂一':
+            return MC.SO1
+        elif result_2 == '御魂二':
+            return MC.SO2
         return MC.UNKNOWN
 
     def detect_best(self) -> tuple:
@@ -184,7 +184,6 @@ class ScriptTask(GameUi, CollectiveMissionsAssets):
                 break
         logger.info('Finish to collect bondling rewards')
 
-
     def _donate(self, index: int):
         """
         捐赠材料
@@ -232,21 +231,30 @@ class ScriptTask(GameUi, CollectiveMissionsAssets):
             3: self.I_CM_ADD_4,
         }
         # 滑动到最多的材料
+        random_click = [self.I_CM_ADD_1, self.I_CM_ADD_2, self.I_CM_ADD_3, self.I_CM_ADD_4]
+        window_control = self.config.script.device.control_method == 'window_message'
         swipe_count = 0
+        click_count = 0
         while 1:
             self.screenshot()
             if self.appear(self.I_CM_MATTER):
                 break
-            if self.swipe(match_swipe[max_index], interval=2.5):
+            if not window_control and self.swipe(match_swipe[max_index], interval=2.5):
                 swipe_count += 1
                 time.sleep(1.5)
                 continue
-            # if self.appear_then_click(match_image[max_index], interval=1):
-            #     self.device.click_record_clear()
-            #     continue
 
             # 为什么使用window_message无法滑动
-            if swipe_count >= 5:
+            if window_control and click_count > 30:
+                logger.info('Swipe to the most matter failed')
+                logger.info('Please check your game resolution')
+                break
+            if window_control and self.click(random.choice(random_click), interval=0.7):
+                click_count += 1
+                continue
+
+
+            if not window_control and swipe_count >= 5:
                 logger.info('Swipe to the most matter failed')
                 logger.info('Please check your game resolution')
                 raise RequestHumanTakeover
@@ -268,6 +276,50 @@ class ScriptTask(GameUi, CollectiveMissionsAssets):
         logger.info('Donate finished')
         return True
 
+    def _soul(self, index: int):
+        """
+        搞收御魂的任务
+        :param index:
+        :return:
+        """
+        match_click = {
+            0: self.C_CM_1,
+            1: self.C_CM_2,
+            2: self.C_CM_3,
+        }
+        self.ui_click(match_click[index], self.I_SL_SUBMIT)
+        while 1:
+            self.screenshot()
+            number_text = self.O_SL_NUMBER.ocr(self.device.image)
+            submit_number = int(re.findall(r'\d+', number_text)[-1])
+            if submit_number > 0:
+                break
+
+            if self.ocr_appear(self.O_SL_LEVEL):
+                # 如果没有识别到这个,那就说明没有御魂可以提交了,要退出
+                logger.warning('No soul can be submit')
+                self.ui_click(self.I_UI_BACK_RED, self.I_CM_RECORDS)
+                return False
+
+            if self.click(self.L_SL_LONG, interval=2.5):
+                time.sleep(1)
+                continue
+        # 领取奖励
+        logger.info('Start to collect soul rewards')
+        check_timer = Timer(3)
+        check_timer.start()
+        while 1:
+            self.screenshot()
+            if self.ui_reward_appear_click(True):
+                check_timer.reset()
+                continue
+            if self.appear_then_click(self.I_SL_SUBMIT, interval=1):
+                check_timer.reset()
+                continue
+            if check_timer.reached():
+                break
+        logger.info('Finish to collect soul rewards')
+        self.wait_until_appear(self.I_CM_RECORDS)
 
 
 

+ 11 - 0
tasks/CollectiveMissions/soul/image.json

@@ -0,0 +1,11 @@
+[
+  {
+    "itemName": "sl_submit",
+    "imageName": "soul_sl_submit.png",
+    "roiFront": "835,588,145,61",
+    "roiBack": "835,588,145,61",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "提交"
+  }
+]

+ 9 - 0
tasks/CollectiveMissions/soul/long_click.json

@@ -0,0 +1,9 @@
+[
+  {
+    "itemName": "sl_long",
+    "roiFront": "178,194,58,49",
+    "roiBack": "178,194,58,49",
+    "duration": 1500,
+    "description": "长按"
+  }
+]

+ 20 - 0
tasks/CollectiveMissions/soul/ocr.json

@@ -0,0 +1,20 @@
+[
+  {
+    "itemName": "sl_level",
+    "roiFront": "174,139,30,24",
+    "roiBack": "174,139,30,24",
+    "mode": "Single",
+    "method": "Default",
+    "keyword": "古",
+    "description": "+0 级"
+  },
+  {
+    "itemName": "sl_number",
+    "roiFront": "813,94,187,39",
+    "roiBack": "813,94,187,39",
+    "mode": "Single",
+    "method": "Default",
+    "keyword": "",
+    "description": "将提交xx次任务"
+  }
+]

BIN
tasks/CollectiveMissions/soul/soul_sl_submit.png


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

@@ -455,15 +455,22 @@ class GeneralBattle(GeneralBuff, GeneralBattleAssets):
         if isinstance(buff, BuffClass):
             buff = [buff]
         match_method = {
-            BuffClass.AWAKE: self.awake,
-            BuffClass.SOUL: self.soul,
-            BuffClass.GOLD_50: self.gold_50,
-            BuffClass.GOLD_100: self.gold_100,
-            BuffClass.EXP_50: self.exp_50,
-            BuffClass.EXP_100: self.exp_100,
+            BuffClass.AWAKE: (self.awake, True),
+            BuffClass.SOUL: (self.soul, True),
+            BuffClass.GOLD_50: (self.gold_50, True),
+            BuffClass.GOLD_100: (self.gold_100, True),
+            BuffClass.EXP_50: (self.exp_50, True),
+            BuffClass.EXP_100: (self.exp_100, True),
+            BuffClass.AWAKE_CLOSE: (self.awake, False),
+            BuffClass.SOUL_CLOSE: (self.soul, False),
+            BuffClass.GOLD_50_CLOSE: (self.gold_50, False),
+            BuffClass.GOLD_100_CLOSE: (self.gold_100, False),
+            BuffClass.EXP_50_CLOSE: (self.exp_50, False),
+            BuffClass.EXP_100_CLOSE: (self.exp_100, False),
         }
         for b in buff:
-            match_method[b]()
+            func, is_open = match_method[b]
+            func(is_open)
             time.sleep(0.1)
         logger.info(f'Open buff success')
         while 1:

+ 6 - 0
tasks/Component/GeneralBuff/config_buff.py

@@ -14,6 +14,12 @@ class BuffClass(Enum):
     GOLD_100 = 40  # 金币100
     EXP_50 = 50  # 经验50
     EXP_100 = 60  # 经验100
+    AWAKE_CLOSE = 70  # 觉醒
+    SOUL_CLOSE = 80  # 御魂
+    GOLD_50_CLOSE = 90  # 金币50
+    GOLD_100_CLOSE = 100  # 金币100
+    EXP_50_CLOSE = 110  # 经验50
+    EXP_100_CLOSE = 120  # 经验100
 
 
 class BuffConfig(BaseModel):

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

@@ -13,7 +13,7 @@ class GeneralRoomAssets:
 	# List Rule Assets
 	# description 
 	L_TEAM_LIST = RuleList(folder="./tasks/Component/GeneralRoom", direction="vertical", mode="ocr", roi_back=(26,106,360,549), size=(216, 61), 
-					 array=["全部", "探索(困难)", "觉醒业火轮", "觉醒风转符", "觉醒火灵鲤", "觉醒天雷鼓", "御魂", "日轮之陨", "永生之海", "妖气封印", "经验妖怪", "金币妖怪", "年兽", "石距", "愤怒的石距", "结界突破", "真·八岐大蛇", "对弈社", "斗町", "连携召唤", "契灵之境"])
+					 array=["全部", "探索(困难)", "觉醒业火轮", "觉醒风转符", "觉醒火灵鲤", "觉醒天雷鼓", "御魂", "日轮之陨", "永生之海", "妖气封印", "经验妖怪", "金币妖怪", "年兽", "石距", "愤怒的石距", "喷怒的石距", "结界突破", "真·八岐大蛇", "对弈社", "斗町", "连携召唤", "契灵之境"])
 
 
 	# Ocr Rule Assets

+ 2 - 1
tasks/Component/GeneralRoom/general_room.py

@@ -123,7 +123,8 @@ class GeneralRoom(BaseTask, GeneralRoomAssets):
         pos = self.list_find(self.L_TEAM_LIST, name)
         if not pos:
             return False
-
+        if name == '愤怒的石距' or name == '喷怒的石距':
+            name = '价悠的石距'
         self.O_GR_ZONES_NAME.keyword = name
         click_timer = Timer(1.1)
         click_timer.start()

+ 4 - 0
tasks/Component/GeneralRoom/list.json

@@ -65,6 +65,10 @@
       "itemName": "愤怒的石距",
       "roiFront": "143,230,214,60"
     },
+    {
+      "itemName": "喷怒的石距",
+      "roiFront": "143,230,214,60"
+    },
     {
       "itemName": "结界突破",
       "roiFront": "147,230,215,63"

+ 56 - 1
tasks/Delegation/assets.py

@@ -8,5 +8,60 @@ from module.atom.list import RuleList
 # This file was automatically generated by ./dev_tools/assets_extract.py.
 # Don't modify it manually.
 class DelegationAssets: 
-	pass
+
+
+	# Click Rule Assets
+	# description 
+	C_D_1 = RuleClick(roi_front=(162,496,100,166), roi_back=(162,496,100,166), name="d_1")
+	# description 
+	C_D_2 = RuleClick(roi_front=(293,493,100,170), roi_back=(293,493,100,170), name="d_2")
+	# description 
+	C_D_3 = RuleClick(roi_front=(427,492,100,170), roi_back=(427,492,100,170), name="d_3")
+	# description 
+	C_D_4 = RuleClick(roi_front=(563,493,100,174), roi_back=(563,493,100,174), name="d_4")
+	# description 
+	C_D_5 = RuleClick(roi_front=(695,491,100,178), roi_back=(695,491,100,178), name="d_5")
+
+
+	# Image Rule Assets
+	# 委派式神 
+	I_D_CONFIRM = RuleImage(roi_front=(979,302,152,62), roi_back=(979,302,152,62), threshold=0.8, method="Template matching", file="./tasks/Delegation/d/d_d_confirm.png")
+	# 再考虑下 
+	I_D_CANCEL = RuleImage(roi_front=(945,413,130,56), roi_back=(945,413,130,56), threshold=0.8, method="Template matching", file="./tasks/Delegation/d/d_d_cancel.png")
+	# 出发 
+	I_D_START = RuleImage(roi_front=(1101,534,120,129), roi_back=(1101,534,120,129), threshold=0.8, method="Template matching", file="./tasks/Delegation/d/d_d_start.png")
+	# 跳过 
+	I_D_SKIP = RuleImage(roi_front=(661,518,70,39), roi_back=(661,518,70,39), threshold=0.67, method="Template matching", file="./tasks/Delegation/d/d_d_skip.png")
+	# description 
+	I_D_SELECT_1 = RuleImage(roi_front=(230,593,44,41), roi_back=(216,578,71,81), threshold=0.7, method="Template matching", file="./tasks/Delegation/d/d_d_select_1.png")
+	# description 
+	I_D_SELECT_2 = RuleImage(roi_front=(363,595,40,41), roi_back=(327,585,97,60), threshold=0.7, method="Template matching", file="./tasks/Delegation/d/d_d_select_2.png")
+	# description 
+	I_D_SELECT_3 = RuleImage(roi_front=(497,595,38,41), roi_back=(456,584,105,66), threshold=0.7, method="Template matching", file="./tasks/Delegation/d/d_d_select_3.png")
+	# description 
+	I_D_SELECT_4 = RuleImage(roi_front=(632,595,42,40), roi_back=(579,584,111,57), threshold=0.7, method="Template matching", file="./tasks/Delegation/d/d_d_select_4.png")
+	# description 
+	I_D_SELECT_5 = RuleImage(roi_front=(767,593,41,40), roi_back=(721,582,103,60), threshold=0.7, method="Template matching", file="./tasks/Delegation/d/d_d_select_5.png")
+
+
+	# Ocr Rule Assets
+	# 委派的名字 
+	O_D_NAME = RuleOcr(roi=(766,127,509,529), area=(766,127,509,529), mode="Full", method="Default", keyword="弥助的画", name="d_name")
+
+
+	# Image Rule Assets
+	# description 
+	I_REWARDS_DONE = RuleImage(roi_front=(982,303,149,60), roi_back=(982,303,149,60), threshold=0.8, method="Template matching", file="./tasks/Delegation/rewards/rewards_rewards_done.png")
+	# description 
+	I_REWARDS_CHAT = RuleImage(roi_front=(1171,124,48,65), roi_back=(1171,124,48,65), threshold=0.8, method="Template matching", file="./tasks/Delegation/rewards/rewards_rewards_chat.png")
+	# 完美达成 
+	I_REWARDS_GET = RuleImage(roi_front=(444,78,100,100), roi_back=(444,78,100,100), threshold=0.8, method="Template matching", file="./tasks/Delegation/rewards/rewards_rewards_get.png")
+	# description 
+	I_REWARDS_MIN = RuleImage(roi_front=(840,131,44,58), roi_back=(840,131,44,58), threshold=0.8, method="Template matching", file="./tasks/Delegation/rewards/rewards_rewards_min.png")
+
+
+	# Ocr Rule Assets
+	# 完成 
+	O_D_DONE = RuleOcr(roi=(675,129,441,517), area=(675,129,441,517), mode="Full", method="Default", keyword="完成", name="d_done")
+
 

+ 2 - 0
tasks/Delegation/config.py

@@ -7,6 +7,8 @@ from tasks.Component.config_scheduler import Scheduler
 from tasks.Component.config_base import ConfigBase, TimeDelta
 
 class DelegationConfig(ConfigBase):
+    # 弥助的画-300-六星变异卡
+    miyoshino_painting: bool = Field(default=False, description='miyoshino_painting_help')
     # 鸟之羽-50-20片大蛇的逆鳞
     bird_feather: bool = Field(default=False, description='bird_feather_help')
     # 寻找耳环-300-金币28万

+ 32 - 0
tasks/Delegation/d/click.json

@@ -0,0 +1,32 @@
+[
+  {
+    "itemName": "d_1",
+    "roiFront": "162,496,100,166",
+    "roiBack": "162,496,100,166",
+    "description": "description"
+  },
+  {
+    "itemName": "d_2",
+    "roiFront": "293,493,100,170",
+    "roiBack": "293,493,100,170",
+    "description": "description"
+  },
+  {
+    "itemName": "d_3",
+    "roiFront": "427,492,100,170",
+    "roiBack": "427,492,100,170",
+    "description": "description"
+  },
+  {
+    "itemName": "d_4",
+    "roiFront": "563,493,100,174",
+    "roiBack": "563,493,100,174",
+    "description": "description"
+  },
+  {
+    "itemName": "d_5",
+    "roiFront": "695,491,100,178",
+    "roiBack": "695,491,100,178",
+    "description": "description"
+  }
+]

BIN
tasks/Delegation/d/d_d_cancel.png


BIN
tasks/Delegation/d/d_d_confirm.png


BIN
tasks/Delegation/d/d_d_select_1.png


BIN
tasks/Delegation/d/d_d_select_2.png


BIN
tasks/Delegation/d/d_d_select_3.png


BIN
tasks/Delegation/d/d_d_select_4.png


BIN
tasks/Delegation/d/d_d_select_5.png


BIN
tasks/Delegation/d/d_d_skip.png


BIN
tasks/Delegation/d/d_d_start.png


+ 83 - 0
tasks/Delegation/d/image.json

@@ -0,0 +1,83 @@
+[
+  {
+    "itemName": "d_confirm",
+    "imageName": "d_d_confirm.png",
+    "roiFront": "979,302,152,62",
+    "roiBack": "979,302,152,62",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "委派式神"
+  },
+  {
+    "itemName": "d_cancel",
+    "imageName": "d_d_cancel.png",
+    "roiFront": "945,413,130,56",
+    "roiBack": "945,413,130,56",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "再考虑下"
+  },
+  {
+    "itemName": "d_start",
+    "imageName": "d_d_start.png",
+    "roiFront": "1101,534,120,129",
+    "roiBack": "1101,534,120,129",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "出发"
+  },
+  {
+    "itemName": "d_skip",
+    "imageName": "d_d_skip.png",
+    "roiFront": "661,518,70,39",
+    "roiBack": "661,518,70,39",
+    "method": "Template matching",
+    "threshold": 0.67,
+    "description": "跳过"
+  },
+  {
+    "itemName": "d_select_1",
+    "imageName": "d_d_select_1.png",
+    "roiFront": "230,593,44,41",
+    "roiBack": "216,578,71,81",
+    "method": "Template matching",
+    "threshold": 0.7,
+    "description": "description"
+  },
+  {
+    "itemName": "d_select_2",
+    "imageName": "d_d_select_2.png",
+    "roiFront": "363,595,40,41",
+    "roiBack": "327,585,97,60",
+    "method": "Template matching",
+    "threshold": 0.7,
+    "description": "description"
+  },
+  {
+    "itemName": "d_select_3",
+    "imageName": "d_d_select_3.png",
+    "roiFront": "497,595,38,41",
+    "roiBack": "456,584,105,66",
+    "method": "Template matching",
+    "threshold": 0.7,
+    "description": "description"
+  },
+  {
+    "itemName": "d_select_4",
+    "imageName": "d_d_select_4.png",
+    "roiFront": "632,595,42,40",
+    "roiBack": "579,584,111,57",
+    "method": "Template matching",
+    "threshold": 0.7,
+    "description": "description"
+  },
+  {
+    "itemName": "d_select_5",
+    "imageName": "d_d_select_5.png",
+    "roiFront": "767,593,41,40",
+    "roiBack": "721,582,103,60",
+    "method": "Template matching",
+    "threshold": 0.7,
+    "description": "description"
+  }
+]

+ 11 - 0
tasks/Delegation/d/ocr.json

@@ -0,0 +1,11 @@
+[
+  {
+    "itemName": "d_name",
+    "roiFront": "766,127,509,529",
+    "roiBack": "766,127,509,529",
+    "mode": "Full",
+    "method": "Default",
+    "keyword": "弥助的画",
+    "description": "委派的名字"
+  }
+]

+ 38 - 0
tasks/Delegation/rewards/image.json

@@ -0,0 +1,38 @@
+[
+  {
+    "itemName": "rewards_done",
+    "imageName": "rewards_rewards_done.png",
+    "roiFront": "982,303,149,60",
+    "roiBack": "982,303,149,60",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "rewards_chat",
+    "imageName": "rewards_rewards_chat.png",
+    "roiFront": "1171,124,48,65",
+    "roiBack": "1171,124,48,65",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "rewards_get",
+    "imageName": "rewards_rewards_get.png",
+    "roiFront": "444,78,100,100",
+    "roiBack": "444,78,100,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "完美达成"
+  },
+  {
+    "itemName": "rewards_min",
+    "imageName": "rewards_rewards_min.png",
+    "roiFront": "840,131,44,58",
+    "roiBack": "840,131,44,58",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  }
+]

+ 11 - 0
tasks/Delegation/rewards/ocr.json

@@ -0,0 +1,11 @@
+[
+  {
+    "itemName": "d_done",
+    "roiFront": "675,129,441,517",
+    "roiBack": "675,129,441,517",
+    "mode": "Full",
+    "method": "Default",
+    "keyword": "完成",
+    "description": "完成"
+  }
+]

BIN
tasks/Delegation/rewards/rewards_rewards_chat.png


BIN
tasks/Delegation/rewards/rewards_rewards_done.png


BIN
tasks/Delegation/rewards/rewards_rewards_get.png


BIN
tasks/Delegation/rewards/rewards_rewards_min.png


+ 91 - 1
tasks/Delegation/script_task.py

@@ -6,20 +6,109 @@ from datetime import time, datetime, timedelta
 
 from module.logger import logger
 from module.exception import TaskEnd
+from module.base.timer import Timer
 
 from tasks.GameUi.game_ui import GameUi
 from tasks.GameUi.page import page_main, page_delegation
+from tasks.Delegation.config import DelegationConfig
+from tasks.Delegation.assets import DelegationAssets
 
 
-class ScriptTask(GameUi):
+class ScriptTask(GameUi, DelegationAssets):
 
     def run(self):
         self.ui_get_current_page()
         self.ui_goto(page_delegation)
+        self.check_reward()
+        con: DelegationConfig = self.config.delegation.delegation_config
+        if con.miyoshino_painting:
+            self.delegate_one('弥助')
+        if con.bird_feather:
+            self.delegate_one('鸟羽')
+        if con.find_earring:
+            self.delegate_one('寻找耳环')
+        if con.cat_boss:
+            self.delegate_one('猫老大')
+        if con.miyoshino:
+            self.delegate_one('接送')
+        if con.strange_trace:
+            self.delegate_one('痕迹')
+
 
         self.set_next_run(task='Delegation', success=True, finish=True)
         raise TaskEnd
 
+    def delegate_one(self, name: str) -> bool:
+        """
+        委派一个任务
+        :param name:
+        :return:
+        """
+        def ui_click(click, stop):
+            while 1:
+                self.screenshot()
+                if self.appear(stop):
+                    break
+                if self.click(click, interval=1.5):
+                    continue
+        logger.hr('Delegation one', 2)
+        self.O_D_NAME.keyword = name
+        self.screenshot()
+        if not self.ocr_appear(self.O_D_NAME):
+            logger.warning(f'Delegation: {name} not found')
+            return False
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_D_START):
+                break
+            if self.appear_then_click(self.I_D_SKIP, interval=0.8):
+                continue
+            if self.appear_then_click(self.I_D_CONFIRM, interval=0.8):
+                continue
+            if self.ocr_appear_click(self.O_D_NAME, interval=1):
+                continue
+        # 进入委派  fefe e  fe
+        logger.info(f'Enter Delegation: {name}')
+        ui_click(self.C_D_1, self.I_D_SELECT_1)
+        ui_click(self.C_D_2, self.I_D_SELECT_2)
+        ui_click(self.C_D_3, self.I_D_SELECT_3)
+        ui_click(self.C_D_4, self.I_D_SELECT_4)
+        # 委派开始
+        logger.info(f'Delegation: {name} start')
+        while 1:
+            self.screenshot()
+            if not self.appear(self.I_D_START):
+                break
+            if self.click(self.C_D_5, interval=0.8):
+                continue
+            if self.appear_then_click(self.I_D_START, interval=1.8):
+                continue
+        # ui_click(self.C_D_5, self.I_D_SELECT_5)
+        # self.ui_click_until_disappear(self.I_D_START)
+
+    def check_reward(self):
+        check_timer = Timer(3)
+        check_timer.start()
+        while 1:
+            self.screenshot()
+            if self.appear_then_click(self.I_REWARDS_GET, interval=1):
+                check_timer.reset()
+                continue
+            if self.appear_then_click(self.I_REWARDS_CHAT, interval=1):
+                check_timer.reset()
+                continue
+            if self.appear_then_click(self.I_REWARDS_DONE, interval=1):
+                check_timer.reset()
+                continue
+
+
+            if not self.appear(self.I_REWARDS_MIN):
+                continue
+            if check_timer.reached():
+                break
+            if self.ocr_appear_click(self.O_D_DONE, interval=1):
+                check_timer.reset()
+                continue
 
 
 if __name__ == '__main__':
@@ -30,6 +119,7 @@ if __name__ == '__main__':
     d = Device(c)
     t = ScriptTask(c, d)
 
+    # t.delegate_one('弥助的画')
     t.run()
 
 

+ 7 - 3
tasks/Duel/assets.py

@@ -29,11 +29,11 @@ class DuelAssets:
 	# 预选点击确认 
 	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_AUTO_ENTRY = RuleImage(roi_front=(28,127,66,62), roi_back=(28,127,66,62), threshold=0.8, method="Template matching", file="./tasks/Duel/duel/duel_d_auto_entry.png")
+	I_D_AUTO_ENTRY = RuleImage(roi_front=(42,133,66,62), roi_back=(20,119,115,111), threshold=0.8, method="Template matching", file="./tasks/Duel/duel/duel_d_auto_entry.png")
 	# 手动,弃用 
 	I_D_HAND = RuleImage(roi_front=(34,635,55,55), roi_back=(34,635,55,55), threshold=0.8, method="Template matching", file="./tasks/Duel/duel/duel_d_hand.png")
 	# 主界面的感叹号 
-	I_D_HELP = RuleImage(roi_front=(715,436,32,30), roi_back=(715,436,32,30), threshold=0.8, method="Template matching", file="./tasks/Duel/duel/duel_d_help.png")
+	I_D_HELP = RuleImage(roi_front=(719,434,32,30), roi_back=(708,397,49,78), threshold=0.8, method="Template matching", file="./tasks/Duel/duel/duel_d_help.png")
 	# 准备 
 	I_D_PREPARE = RuleImage(roi_front=(1127,541,100,100), roi_back=(1127,541,100,100), threshold=0.8, method="Template matching", file="./tasks/Duel/duel/duel_d_prepare.png")
 	# 准备完毕 
@@ -46,13 +46,17 @@ class DuelAssets:
 	I_D_FAIL = RuleImage(roi_front=(422,66,100,100), roi_back=(422,66,100,100), threshold=0.8, method="Template matching", file="./tasks/Duel/duel/duel_d_fail.png")
 	# 战 
 	I_D_WORD_BATTLE = RuleImage(roi_front=(612,41,54,54), roi_back=(612,41,54,54), threshold=0.8, method="Template matching", file="./tasks/Duel/duel/duel_d_word_battle.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")
 
 
 	# Ocr Rule Assets
 	# 荣誉 
 	O_D_HONOR = RuleOcr(roi=(699,562,131,31), area=(699,562,131,31), mode="DigitCounter", method="Default", keyword="", name="d_honor")
 	# 分数 
-	O_D_SCORE = RuleOcr(roi=(699,514,65,33), area=(699,514,65,33), mode="Digit", method="Default", keyword="", name="d_score")
+	O_D_SCORE = RuleOcr(roi=(701,516,56,26), area=(701,516,56,26), mode="Digit", method="Default", keyword="", name="d_score")
 	# 手动 
 	O_D_HAND = RuleOcr(roi=(31,639,63,45), area=(31,639,63,45), mode="Single", method="Default", keyword="手动", name="d_hand")
 	# 自动 

BIN
tasks/Duel/duel/duel_d_celeb_honor.png


BIN
tasks/Duel/duel/duel_d_celeb_star.png


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

@@ -56,8 +56,8 @@
   {
     "itemName": "d_auto_entry",
     "imageName": "duel_d_auto_entry.png",
-    "roiFront": "28,127,66,62",
-    "roiBack": "28,127,66,62",
+    "roiFront": "42,133,66,62",
+    "roiBack": "20,119,115,111",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "自动上阵"
@@ -74,8 +74,8 @@
   {
     "itemName": "d_help",
     "imageName": "duel_d_help.png",
-    "roiFront": "715,436,32,30",
-    "roiBack": "715,436,32,30",
+    "roiFront": "719,434,32,30",
+    "roiBack": "708,397,49,78",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "主界面的感叹号"
@@ -133,5 +133,23 @@
     "method": "Template matching",
     "threshold": 0.8,
     "description": "战"
+  },
+  {
+    "itemName": "d_celeb_star",
+    "imageName": "duel_d_celeb_star.png",
+    "roiFront": "586,456,30,32",
+    "roiBack": "574,444,53,54",
+    "method": "Template matching",
+    "threshold": 0.75,
+    "description": "名士的星星"
+  },
+  {
+    "itemName": "d_celeb_honor",
+    "imageName": "duel_d_celeb_honor.png",
+    "roiFront": "665,531,25,30",
+    "roiBack": "652,517,52,53",
+    "method": "Template matching",
+    "threshold": 0.75,
+    "description": "名士专属"
   }
 ]

+ 2 - 2
tasks/Duel/duel/ocr.json

@@ -10,8 +10,8 @@
   },
   {
     "itemName": "d_score",
-    "roiFront": "699,514,65,33",
-    "roiBack": "699,514,65,33",
+    "roiFront": "701,516,56,26",
+    "roiBack": "701,516,56,26",
     "mode": "Digit",
     "method": "Default",
     "keyword": "",

+ 9 - 2
tasks/Duel/script_task.py

@@ -99,8 +99,15 @@ class ScriptTask(GameUi, GeneralBattle, DuelAssets):
         :param target: 目标分数
         :return:
         """
-        current_score = self.O_D_SCORE.ocr(self.device.image)
-        return current_score if current_score <= target else None
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_D_CELEB_STAR) or self.appear(self.I_D_CELEB_HONOR):
+                logger.info('You are already a celeb')
+                return None
+            current_score = self.O_D_SCORE.ocr(self.device.image)
+            if current_score < 1200 or current_score > 3000:
+                continue
+            return current_score if current_score <= target else None
 
     def duel_one(self, current_score: int, enable: bool=False,
                  mark_mode: GreenMarkType=GreenMarkType.GREEN_MAIN) -> bool:

+ 40 - 0
tasks/EternitySea/script_task.py

@@ -0,0 +1,40 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+from cached_property import cached_property
+
+from module.exception import TaskEnd
+from module.logger import logger
+from module.base.timer import Timer
+
+from tasks.GameUi.game_ui import GameUi
+from tasks.GameUi.page import page_main, page_soul_zones, page_shikigami_records
+from tasks.Component.GeneralBattle.general_battle import GeneralBattle
+from tasks.Component.GeneralBattle.config_general_battle import GeneralBattleConfig
+from tasks.Component.GeneralRoom.general_room import GeneralRoom
+from tasks.Component.GeneralInvite.general_invite import GeneralInvite
+from tasks.Component.SwitchSoul.switch_soul import SwitchSoul
+from tasks.EternitySea.assets import EternitySeaAssets
+
+class ScriptTask(GameUi, GeneralBattle, GeneralRoom, GeneralInvite, SwitchSoul, EternitySeaAssets):
+
+    def run(self):
+        con = self.config.eternity_sea.eternity_sea_config
+        self.ui_get_current_page()
+        self.ui_goto(page_soul_zones)
+
+        self.set_next_run(task='EternitySea', success=True, finish=False)
+        raise TaskEnd('EternitySea')
+
+
+
+
+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()

+ 31 - 0
tasks/ExperienceYoukai/script_task.py

@@ -16,5 +16,36 @@ from tasks.Component.GeneralInvite.general_invite import GeneralInvite
 from tasks.Component.SwitchSoul.switch_soul import SwitchSoul
 from tasks.ExperienceYoukai.assets import ExperienceYoukaiAssets
 
+class ScriptTask(GameUi, GeneralBattle, GeneralRoom, GeneralInvite, SwitchSoul, ExperienceYoukaiAssets):
 
+    def run(self):
+        con = self.config.experience_youkai
+        self.ui_get_current_page()
+        self.ui_goto(page_team)
+        self.check_zones('经验妖怪')
 
+        self.exp_exit()
+
+    def exp_exit(self, con=None):
+        self.ui_get_current_page()
+        self.ui_goto(page_main)
+        # if con.buff_gold_50_click or con.buff_gold_100_click:
+        #     self.open_buff()
+        #     if con.buff_gold_50_click:
+        #         self.gold_50(False)
+        #     if con.buff_gold_100_click:
+        #         self.gold_100(False)
+        #     self.close_buff()
+
+        self.set_next_run(task='ExperienceYoukai', success=True, finish=False)
+        raise TaskEnd('ExperienceYoukai')
+
+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()

+ 1 - 1
tasks/GameUi/assets.py

@@ -125,7 +125,7 @@ class GameUiAssets:
 	# description 
 	I_MAIN_GOTO_ONMYODO = RuleImage(roi_front=(992,614,51,60), roi_back=(992,614,51,60), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_main_goto_onmyodo.png")
 	# description 
-	I_MAIN_GOTO_FRIENDS = RuleImage(roi_front=(878,623,55,55), roi_back=(878,623,55,55), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_main_goto_friends.png")
+	I_MAIN_GOTO_FRIENDS = RuleImage(roi_front=(879,623,55,55), roi_back=(867,606,79,77), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_main_goto_friends.png")
 	# description 
 	I_MAIN_GOTO_DAILY = RuleImage(roi_front=(778,612,52,54), roi_back=(759,595,84,84), threshold=0.7, method="Template matching", file="./tasks/GameUi/page/page_main_goto_daily.png")
 	# description 

+ 2 - 2
tasks/GameUi/page/page_img_3.json

@@ -20,8 +20,8 @@
   {
     "itemName": "main_goto_friends",
     "imageName": "page_main_goto_friends.png",
-    "roiFront": "878,623,55,55",
-    "roiBack": "878,623,55,55",
+    "roiFront": "879,623,55,55",
+    "roiBack": "867,606,79,77",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"

+ 1 - 0
tasks/GoldYoukai/script_task.py

@@ -110,6 +110,7 @@ class ScriptTask(GameUi, GeneralBattle, GeneralRoom, GeneralInvite, SwitchSoul,
         self.set_next_run(task='GoldYoukai', success=True, finish=False)
         raise TaskEnd('GoldYoukai')
 
+
 if __name__ == '__main__':
     from module.config.config import Config
     from module.device.device import Device

+ 2 - 1
tasks/MysteryShop/config.py

@@ -1,13 +1,14 @@
 # This Python file uses the following encoding: utf-8
 # @author runhey
 # github https://github.com/runhey
-from datetime import timedelta
+from datetime import timedelta, datetime, time
 from pydantic import BaseModel, Field
 
 from tasks.Component.config_scheduler import Scheduler
 from tasks.Component.config_base import ConfigBase
 
 class ShopConfig(BaseModel):
+    time_of_mystery: time = Field(default=time(hour=0, minute=0, second=0), description='time_of_mystery_help')
     mystery_amulet: bool = Field(default=False)
     black_daruma_scrap: bool = Field(default=False)
     shop_kaiko_3: bool = Field(default=False)

+ 29 - 5
tasks/MysteryShop/script_task.py

@@ -24,8 +24,7 @@ class ScriptTask(FriendshipPoints, MysteryShopAssets, GeneralInvite):
         day_of_week = self.start_time.weekday()
         if day_of_week != 2 and day_of_week != 5:
             logger.warning('Today is not MysteryShop day')
-            self.set_next_run(task='MysteryShop', success=False, finish=True)
-            return
+            self.next_time(False)
         self.ui_get_current_page()
         self.ui_goto(page_mall)
         self.ui_click(self.I_ME_ENTER, self.I_MS_SHARE)
@@ -41,8 +40,7 @@ class ScriptTask(FriendshipPoints, MysteryShopAssets, GeneralInvite):
         self.back_mall()
 
 
-        self.set_next_run(task='MysteryShop', success=True, finish=True)
-        raise TaskEnd('MysteryShop')
+        self.next_time(True)
 
     def next_one(self):
         """
@@ -195,6 +193,33 @@ class ScriptTask(FriendshipPoints, MysteryShopAssets, GeneralInvite):
             sleep(0.5)
         logger.info('Shop reward done')
 
+    def next_time(self, success: bool = True):
+        """
+        重写
+        """
+        target_time: time = self.config.mystery_shop.shop_config.time_of_mystery
+        target_time: timedelta = timedelta(hours=target_time.hour, minutes=target_time.minute,
+                                           seconds=target_time.second)
+        if target_time == time(hour=0, minute=0, second=0):
+            if success:
+                self.set_next_run(task='MysteryShop', success=True, finish=True)
+            else:
+                self.set_next_run(task='MysteryShop', success=False, finish=True)
+            raise TaskEnd('MysteryShop')
+        now = datetime.now()
+        day_of_week = now.weekday()
+        now_datetime = now.replace(hour=0, minute=0, second=0, microsecond=0)
+        if 2 <= day_of_week <= 4:
+            # 如果现在是周三和周五之间,那就设定下一次为这周六(hour=0, minute=0, second=0)+ target_time
+            next_time = now_datetime + timedelta(days=5 - day_of_week) + target_time
+        elif 5 <= day_of_week <= 6 or 0 <= day_of_week <= 1:
+            # 如果现在是周六和周一之间,那就设定下一次为下周三(hour=0, minute=0, second=0)+ target_time
+            next_time = now_datetime + timedelta(days=6 - day_of_week + 3) + target_time
+        else:
+            next_time = now_datetime + timedelta(days=2 - day_of_week) + target_time
+            logger.warning('Now is not in the time of mystery shop')
+        self.set_next_run(task='MysteryShop', target=next_time)
+        raise TaskEnd('MysteryShop')
 
 
 if __name__ == '__main__':
@@ -208,4 +233,3 @@ if __name__ == '__main__':
     # t.run_shop(t.config.mystery_shop.shop_config)
     t.shop_reward()
 
-

+ 1 - 1
tasks/Pets/assets.py

@@ -12,7 +12,7 @@ class PetsAssets:
 
 	# Image Rule Assets
 	# 宠物小屋 
-	I_PET_HOUSE = RuleImage(roi_front=(1036,420,37,41), roi_back=(998,393,100,100), threshold=0.7, method="Template matching", file="./tasks/Pets/pet/pet_pet_house.png")
+	I_PET_HOUSE = RuleImage(roi_front=(1015,431,27,31), roi_back=(952,412,144,60), threshold=0.7, method="Template matching", file="./tasks/Pets/pet/pet_pet_house.png")
 	# 爪印 
 	I_PET_CLAW = RuleImage(roi_front=(1171,625,55,56), roi_back=(1171,625,55,56), threshold=0.8, method="Template matching", file="./tasks/Pets/pet/pet_pet_claw.png")
 	# 其乐融融 

+ 2 - 2
tasks/Pets/pet/image.json

@@ -2,8 +2,8 @@
   {
     "itemName": "pet_house",
     "imageName": "pet_pet_house.png",
-    "roiFront": "1036,420,37,41",
-    "roiBack": "998,393,100,100",
+    "roiFront": "1015,431,27,31",
+    "roiBack": "952,412,144,60",
     "method": "Template matching",
     "threshold": 0.7,
     "description": "宠物小屋"

BIN
tasks/Pets/pet/pet_pet_house.png


+ 3 - 1
tasks/Secret/assets.py

@@ -19,7 +19,7 @@ class SecretAssets:
 	# 进入 
 	I_SE_ENTER = RuleImage(roi_front=(1145,593,100,100), roi_back=(1145,593,100,100), threshold=0.8, method="Template matching", file="./tasks/Secret/se/se_se_enter.png")
 	# 秘闻挑战 
-	I_SE_FIRE = RuleImage(roi_front=(1108,551,100,100), roi_back=(1108,551,100,100), threshold=0.8, method="Template matching", file="./tasks/Secret/se/se_se_fire.png")
+	I_SE_FIRE = RuleImage(roi_front=(1108,551,100,100), roi_back=(1100,541,120,120), threshold=0.7, method="Template matching", file="./tasks/Secret/se/se_se_fire.png")
 	# 排行 
 	I_SE_PLACEMENT = RuleImage(roi_front=(1013,570,50,48), roi_back=(996,555,79,81), threshold=0.8, method="Template matching", file="./tasks/Secret/se/se_se_placement.png")
 	# 勾玉 
@@ -45,6 +45,8 @@ class SecretAssets:
 	O_SE_LAYER_8 = RuleOcr(roi=(212,237,34,34), area=(212,237,34,34), mode="Single", method="Default", keyword="捌", name="se_layer_8")
 	# 后面的时候识别为通关的 
 	O_SE_NO_PASS_LAST = RuleOcr(roi=(429,381,180,234), area=(429,381,180,234), mode="Full", method="Default", keyword="未通关", name="se_no_pass_last")
+	# 勾玉 
+	O_SE_JADE = RuleOcr(roi=(327,230,23,24), area=(327,230,23,24), mode="Digit", method="Default", keyword="", name="se_jade")
 
 
 	# Swipe Rule Assets

+ 54 - 12
tasks/Secret/script_task.py

@@ -90,8 +90,15 @@ class ScriptTask(GameUi, GeneralBattle, SwitchSoul, SecretAssets):
                 continue
             if not first_battle and layer == 6:
                 # 第六次关闭加成,但是发现没有这个接口。。。!!!居然没有注意到
+                buff = []
+                if con.secret_gold_50:
+                    buff.append(BuffClass.GOLD_50_CLOSE)
+                if con.secret_gold_100:
+                    buff.append(BuffClass.GOLD_100_CLOSE)
+                if buff is []:
+                    buff = None
                 self.click_battle()
-                success = self.run_general_battle(self.battle_config)
+                success = self.run_general_battle(self.battle_config, buff=buff)
                 continue
             elif not first_battle and layer == 9 and con.layer_9:
                 self.click_battle()
@@ -149,18 +156,51 @@ class ScriptTask(GameUi, GeneralBattle, SwitchSoul, SecretAssets):
                 logger.warning(f'OCR failed, try again {level}')
                 return None
 
+        def confirm_layer(ocr_target: RuleOcr, roi=None) -> int or None:
+            """
+            检查层数, 启用函数check_layer
+            :param ocr_target:
+            :param roi:
+            :return:
+            """
+            ocr_target.roi[0] = int(roi[0]) - 115
+            ocr_target.roi[1] = int(roi[1]) + 37
+            print(f'检测到的未通过ROI: {roi}')
+            print(f'检测到的勾玉数量ROI: {ocr_target.roi}')
+            jade_num = ocr_target.ocr(self.device.image)
+            if isinstance(jade_num, str):
+                logger.warning(f'OCR failed, try again {jade_num}')
+                return None
+            elif not isinstance(jade_num, int):
+                logger.warning(f'OCR failed, try again {jade_num}')
+                return None
+            if jade_num < 7:
+                logger.warning(f'OCR failed, try again {jade_num}')
+                return None
+            elif jade_num > 70:
+                logger.warning(f'OCR failed, try again {jade_num}')
+                return None
+            # 勾玉数量 = 层数 * 7
+            try:
+                lr = jade_num // 7
+                return lr
+            except TypeError:
+                logger.warning(f'OCR failed, try again {jade_num}')
+                return None
+
 
         if screenshot:
             self.screenshot()
         text_pos = self.O_SE_NO_PASS.ocr(self.device.image)
         if text_pos != (0, 0, 0, 0):
             # 如果能找得到 未通关 ,那可以挑战
-            layer = check_layer(self.O_SE_LAYER_1, None)
-            # 如果第一个文字就找得到的,就点击这个
-            if not layer:
-                layer = check_layer(self.O_SE_LAYER_8, None)
-            if not layer:
-                layer = check_layer(self.O_SE_LAYER_1, text_pos)
+            layer = confirm_layer(self.O_SE_JADE, text_pos)
+            # layer = check_layer(self.O_SE_LAYER_1, None)
+            # # 如果第一个文字就找得到的,就点击这个
+            # if not layer:
+            #     layer = check_layer(self.O_SE_LAYER_8, None)
+            # if not layer:
+            #     layer = check_layer(self.O_SE_LAYER_1, text_pos)
 
             print('识别到的层数:', layer)
             if layer:
@@ -175,11 +215,12 @@ class ScriptTask(GameUi, GeneralBattle, SwitchSoul, SecretAssets):
             last_text_pos = self.O_SE_NO_PASS_LAST.ocr(self.device.image)
             if last_text_pos != (0, 0, 0, 0):
                 # 如果是后面找得到
-                layer = check_layer(self.O_SE_LAYER_10, last_text_pos)
-                if not layer:
-                    layer = check_layer(self.O_SE_LAYER_9, None)
-                if not layer:
-                    layer = check_layer(self.O_SE_LAYER_10, None)
+                layer = confirm_layer(self.O_SE_JADE, last_text_pos)
+                # layer = check_layer(self.O_SE_LAYER_10, last_text_pos)
+                # if not layer:
+                #     layer = check_layer(self.O_SE_LAYER_9, None)
+                # if not layer:
+                #     layer = check_layer(self.O_SE_LAYER_10, None)
                 # 如果第一个文字就找得到的,就点击这个
                 if layer:
                     self.C_SE_CLICK_LAYER.roi_front = last_text_pos
@@ -236,3 +277,4 @@ if __name__ == '__main__':
     t.screenshot()
 
     t.run()
+    # t.find_battle(False)

+ 2 - 2
tasks/Secret/se/image.json

@@ -12,9 +12,9 @@
     "itemName": "se_fire",
     "imageName": "se_se_fire.png",
     "roiFront": "1108,551,100,100",
-    "roiBack": "1108,551,100,100",
+    "roiBack": "1100,541,120,120",
     "method": "Template matching",
-    "threshold": 0.8,
+    "threshold": 0.7,
     "description": "秘闻挑战"
   },
   {

+ 9 - 0
tasks/Secret/se/ocr.json

@@ -52,5 +52,14 @@
     "method": "Default",
     "keyword": "未通关",
     "description": "后面的时候识别为通关的"
+  },
+  {
+    "itemName": "se_jade",
+    "roiFront": "327,230,23,24",
+    "roiBack": "327,230,23,24",
+    "mode": "Digit",
+    "method": "Default",
+    "keyword": "",
+    "description": "勾玉"
   }
 ]

+ 1 - 1
tasks/ui/assets.py → tasks/Tako/assets.py

@@ -7,6 +7,6 @@ from module.atom.list import RuleList
 
 # This file was automatically generated by ./dev_tools/assets_extract.py.
 # Don't modify it manually.
-class uiAssets: 
+class TakoAssets: 
 	pass
 

+ 23 - 0
tasks/Tako/config.py

@@ -0,0 +1,23 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+from pydantic import BaseModel, Field
+from enum import Enum
+from datetime import datetime, time
+
+from tasks.Component.config_scheduler import Scheduler
+from tasks.Component.config_base import ConfigBase
+from tasks.Component.SwitchSoul.switch_soul_config import SwitchSoulConfig
+
+class TakoConfig(BaseModel):
+    enable: bool = Field(default=False)
+    buff_gold_50_click: bool = Field(default=False)
+    buff_gold_100_click: bool = Field(default=False)
+    buff_exp_50_click: bool = Field(default=False)
+    buff_exp_100_click: bool = Field(default=False)
+
+
+class Tako(ConfigBase):
+    scheduler: Scheduler = Field(default_factory=Scheduler)
+    tako_config: TakoConfig = Field(default_factory=TakoConfig)
+    switch_soul: SwitchSoulConfig = Field(default_factory=SwitchSoulConfig)

+ 141 - 0
tasks/Tako/script_task.py

@@ -0,0 +1,141 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+from time import sleep
+from datetime import time, datetime, timedelta
+
+from module.logger import logger
+from module.exception import TaskEnd
+from module.base.timer import Timer
+
+from tasks.GameUi.game_ui import GameUi
+from tasks.GameUi.page import page_main, page_team, page_shikigami_records
+from tasks.Component.GeneralBattle.general_battle import GeneralBattle
+from tasks.Component.GeneralRoom.general_room import GeneralRoom
+from tasks.Component.GeneralInvite.general_invite import GeneralInvite
+from tasks.Component.SwitchSoul.switch_soul import SwitchSoul
+
+
+class ScriptTask(GameUi, GeneralBattle, GeneralRoom, GeneralInvite, SwitchSoul):
+
+    def run(self):
+        conf = self.config.tako
+        if conf.switch_soul.enable:
+            self.ui_get_current_page()
+            self.ui_goto(page_shikigami_records)
+            self.run_switch_soul(conf.switch_soul.switch_group_team)
+
+        if conf.switch_soul.enable_switch_by_name:
+            self.ui_get_current_page()
+            self.ui_goto(page_shikigami_records)
+            self.run_switch_soul_by_name(conf.switch_soul.group_name,
+                                         conf.switch_soul.team_name)
+        # 加成
+        conf_buff = conf.tako_config
+        if conf_buff.enable:
+            self.ui_get_current_page()
+            self.ui_goto(page_main)
+            self.open_buff()
+            if conf_buff.buff_gold_50_click:
+                self.gold_50()
+            if conf_buff.buff_gold_100_click:
+                self.gold_100()
+            if conf_buff.buff_exp_50_click:
+                self.exp_50()
+            if conf_buff.buff_exp_100_click:
+                self.exp_100()
+            self.close_buff()
+
+        # 进入
+        self.ui_get_current_page()
+        self.ui_goto(page_team)
+        if 5 <= self.start_time.weekday() <= 6:
+            # 周末
+            self.check_zones('喷怒的石距')
+        else:
+            self.check_zones('石距')
+        if not self.create_room():
+            self.exit_task()
+        self.ensure_public()
+        self.create_ensure()
+        # 进入到了房间里面
+        wait_timer = Timer(60)
+        wait_timer.start()
+        while 1:
+            self.screenshot()
+
+            if not self.is_in_room():
+                continue
+            if wait_timer.reached():
+                logger.warning('Wait for too long, exit')
+                self.exit_room()
+                break
+            if not self.appear(self.I_ADD_1):
+                # 有人进来了,可以进行挑战
+                logger.info('There is someone in the room and start the challenge')
+                self.click_fire()
+                self.run_general_battle()
+                break
+        self.exit_task()
+
+    def exit_task(self):
+        """
+        退出任务
+        :return:
+        """
+        conf_buff = self.config.tako.tako_config
+        self.ui_get_current_page()
+        self.ui_goto(page_main)
+        if conf_buff.enable:
+            self.ui_get_current_page()
+            self.ui_goto(page_main)
+            self.open_buff()
+            if conf_buff.buff_gold_50_click:
+                self.gold_50(False)
+            if conf_buff.buff_gold_100_click:
+                self.gold_100(False)
+            if conf_buff.buff_exp_50_click:
+                self.exp_50(False)
+            if conf_buff.buff_exp_100_click:
+                self.exp_100(False)
+            self.close_buff()
+
+        self.set_next_run(task='Tako', success=True, finish=False)
+        raise TaskEnd('Tako')
+
+    def battle_wait(self, random_click_swipt_enable: bool) -> bool:
+        # 重写
+        self.device.stuck_record_add('BATTLE_STATUS_S')
+        self.device.click_record_clear()
+        # 战斗过程 随机点击和滑动 防封
+        logger.info("Start battle process")
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_WIN) or self.appear(self.I_REWARD):
+                logger.info('Win battle')
+                self.ui_click_until_disappear(self.I_WIN)
+                while 1:
+                    self.screenshot()
+                    if self.appear(self.I_CHECK_MAIN) or self.appear(self.I_CHECK_TEAM):
+                        break
+                    if self.click(self.C_REWARD_2, interval=2):
+                        continue
+                return True
+
+            if self.appear(self.I_FALSE):
+                logger.warning('False battle')
+                self.ui_click_until_disappear(self.I_FALSE)
+                return False
+
+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()
+
+
+

+ 4 - 0
tasks/TrueOrochi/assets.py

@@ -54,5 +54,9 @@ class TrueOrochiAssets:
 	I_ST_GREEN_5 = RuleImage(roi_front=(841,335,26,44), roi_back=(814,302,100,100), threshold=0.8, method="Template matching", file="./tasks/TrueOrochi/st/st_st_green_5.png")
 	# description 
 	I_ST_GREEN_6 = RuleImage(roi_front=(930,247,24,47), roi_back=(894,224,100,100), threshold=0.8, method="Template matching", file="./tasks/TrueOrochi/st/st_st_green_6.png")
+	# 60体力创建 
+	I_ST_CREATE_ROOM = RuleImage(roi_front=(528,482,223,62), roi_back=(528,482,223,62), threshold=0.8, method="Template matching", file="./tasks/TrueOrochi/st/st_st_create_room.png")
+	# 头像框 
+	I_ST_FRAME = RuleImage(roi_front=(574,441,130,63), roi_back=(574,441,130,63), threshold=0.8, method="Template matching", file="./tasks/TrueOrochi/st/st_st_frame.png")
 
 

+ 2 - 2
tasks/TrueOrochi/config.py

@@ -27,8 +27,8 @@ class TrueOrochiScheduler(Scheduler):
 
 class TrueOrochiConfig(BaseModel):
     find_true_orochi: bool = Field(default=True, description='find_true_orochi_help')
-    green_enable: bool = Field(default=False, description='green_enable_help')
-    green_mark_type: GreenMarkType = Field(default=GreenMarkType.LEFT_1, description='green_mark_type_help')
+    # green_enable: bool = Field(default=False, description='green_enable_help')
+    # green_mark_type: GreenMarkType = Field(default=GreenMarkType.LEFT_1, description='green_mark_type_help')
     current_success: int = Field(default=0, description='current_success_help')
 
 class TrueOrochi(ConfigBase):

+ 151 - 2
tasks/TrueOrochi/script_task.py

@@ -1,24 +1,135 @@
 # This Python file uses the following encoding: utf-8
 # @author runhey
 # github https://github.com/runhey
+from time import sleep
+from datetime import datetime, time
+
 from module.logger import logger
 from module.exception import TaskEnd
+from module.base.timer import Timer
 
 from tasks.GameUi.game_ui import GameUi
 from tasks.Component.GeneralBattle.general_battle import GeneralBattle
 from tasks.Component.GeneralInvite.general_invite import GeneralInvite
 from tasks.Component.GeneralRoom.general_room import GeneralRoom
 from tasks.Orochi.script_task import ScriptTask as OrochiScriptTask
+from tasks.Orochi.config import Layer
 from tasks.GameUi.page import page_main, page_soul_zones
+from tasks.TrueOrochi.assets import TrueOrochiAssets
 
 
-class ScriptTask(GameUi, OrochiScriptTask, GeneralBattle, GeneralInvite, GeneralRoom):
+class ScriptTask(OrochiScriptTask, TrueOrochiAssets):
 
     def run(self):
-        config = self.config.ture_orochi
+        conf = self.config.true_orochi.true_orochi_config
+        if conf.current_success >= 2:
+            # 超过两次就说明这周打完了没有必要再打了
+            logger.warning('This week is full')
+            self.check_times(True)
+            raise TaskEnd('TrueOrochi')
         self.ui_get_current_page()
         self.ui_goto(page_soul_zones)
         self.orochi_enter()
+        battle = self.check_true_orochi(True)
+        if not battle:
+            logger.warning('Not find true orochi')
+            logger.warning('Try to battle orochi for ten times')
+            self.check_layer(Layer.TEN)
+            self.check_lock(False)
+            count_orochi_ten = 0
+            while 1:
+                self.screenshot()
+                # 检查猫咪奖励
+                if self.appear_then_click(self.I_PET_PRESENT, action=self.C_WIN_3, interval=1):
+                    continue
+                if not self.appear(self.I_OROCHI_FIRE):
+                    continue
+                if self.check_true_orochi(False):
+                    logger.info('Find true orochi')
+                    battle = True
+                    break
+                if count_orochi_ten >= 10:
+                    logger.warning('Not find true orochi')
+                    battle = False
+                    break
+                # 否则点击挑战
+                if self.appear(self.I_OROCHI_FIRE):
+                    self.ui_click_until_disappear(self.I_OROCHI_FIRE)
+                    self.run_general_battle()
+                    count_orochi_ten += 1
+                    continue
+
+        if not battle:
+            # 如果还没有真蛇,那么就退出
+            self.check_times(battle)
+            raise TaskEnd('TrueOrochi')
+        # 如果有真蛇,那么就开始战斗
+        logger.hr('True Orochi Battle')
+        conf.current_success += 1
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_ST_CREATE_ROOM):
+                break
+            if self.appear_then_click(self.I_UI_CONFIRM, interval=1):
+                continue
+            if self.appear_then_click(self.I_ST_FIRE, interval=1):
+                continue
+            if self.appear_then_click(self.I_FIND_TS, interval=1):
+                continue
+        self.ensure_private()
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_ST_FIRE_PREPARE):
+                break
+            if self.appear_then_click(self.I_FIRE, interval=1, threshold=0.7):
+                continue
+            if self.appear_then_click(self.I_UI_CONFIRM, interval=1):
+                continue
+            if self.appear_then_click(self.I_ST_CREATE_ROOM, interval=1):
+                continue
+        # 战斗准备
+        logger.info('Battle prepare')
+        self.ui_click(self.I_ST_FIRE_PREPARE, self.I_BUFF)
+        while 1:
+            self.screenshot()
+            if not self.appear(self.I_BUFF):
+                break
+            if self.appear_then_click(self.I_ST_AUTO_FALSE, interval=0.8):
+                continue
+            if self.appear_then_click(self.I_PREPARE_HIGHLIGHT, interval=1.8):
+                continue
+        self.device.stuck_record_add('BATTLE_STATUS_S')
+        self.device.click_record_clear()
+        logger.info("Start battle process")
+        check_timer = Timer(280)
+        check_timer.start()
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_GREED_GHOST):
+                sleep(0.7)
+                self.screenshot()
+                if not self.appear(self.I_GREED_GHOST):
+                    continue
+                # 左上角的贪吃鬼
+                while 1:
+                    self.screenshot()
+                    if not self.appear(self.I_GREED_GHOST):
+                        break
+                    if self.appear_then_click(self.I_GREED_GHOST, interval=1):
+                        continue
+                    # if self.appear_then_click(self.I_GREED_GHOST, action=self.C_REWARD_1, interval=1):
+                    #     continue
+                break
+            if self.appear_then_click(self.I_ST_FRAME, interval=1):
+                continue
+            if check_timer.reached():
+                logger.warning('Battle timeout')
+                check_timer.reset()
+            sleep(0.5)
+
+        logger.info("Battle process end")
+        self.check_times(battle)
+        raise TaskEnd('TrueOrochi')
 
 
     def check_true_orochi(self, screenshot=False) -> bool:
@@ -30,6 +141,44 @@ class ScriptTask(GameUi, OrochiScriptTask, GeneralBattle, GeneralInvite, General
             self.screenshot()
         return self.appear(self.I_FIND_TS)
 
+    def check_times(self, battle: bool):
+        """
+        后续的次数和时间设置
+        :param battle:
+        :param current_success: 这周的成功次数
+        :return:
+        """
+        now = datetime.now()
+        now_year, now_week_number, now_weekday = now.isocalendar()
+        if battle:
+            next_run = now + self.config.true_orochi.scheduler.success_interval
+        else:
+            next_run = now + self.config.true_orochi.scheduler.fail_interval
+        next_run_year, next_run_week_number, next_run_weekday = next_run.isocalendar()
+        self.set_next_run(task='TrueOrochi', target=next_run)
+        # 如果下次运行的时间是下一周,那么就重置成功次数
+        if now_week_number != next_run_week_number:
+            self.config.true_orochi.true_orochi_config.current_success = 0
+        else:
+            # 如果不是下一周,那么就加一
+            self.config.true_orochi.true_orochi_config.current_success += 1
+
+
+
+
+
+
     def run_true_orochi(self) -> bool:
         pass
 
+
+if __name__ == '__main__':
+    from module.config.config import Config
+    from module.device.device import Device
+    c = Config('test')
+    d = Device(c)
+    t = ScriptTask(c, d)
+    t.screenshot()
+
+    t.run()
+

+ 18 - 0
tasks/TrueOrochi/st/image.json

@@ -106,5 +106,23 @@
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"
+  },
+  {
+    "itemName": "st_create_room",
+    "imageName": "st_st_create_room.png",
+    "roiFront": "528,482,223,62",
+    "roiBack": "528,482,223,62",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "60体力创建"
+  },
+  {
+    "itemName": "st_frame",
+    "imageName": "st_st_frame.png",
+    "roiFront": "574,441,130,63",
+    "roiBack": "574,441,130,63",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "头像框"
   }
 ]

BIN
tasks/TrueOrochi/st/st_st_create_room.png


BIN
tasks/TrueOrochi/st/st_st_frame.png


+ 103 - 0
tasks/WantedQuests/assets.py

@@ -0,0 +1,103 @@
+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 WantedQuestsAssets: 
+
+
+	# Ocr Rule Assets
+	# 挑战券的数量 
+	O_WQ_NUMBER = RuleOcr(roi=(569,13,50,32), area=(569,13,50,32), mode="Digit", method="Default", keyword="", name="wq_number")
+	# 悬赏封印 
+	O_WQ_WANTED = RuleOcr(roi=(9,145,123,381), area=(9,145,123,381), mode="Full", method="Default", keyword="", name="wq_wanted")
+	# Ocr-description 
+	O_WQ_TEXT_1 = RuleOcr(roi=(67,233,52,32), area=(67,233,52,32), mode="Single", method="Default", keyword="封印", name="wq_text_1")
+	# Ocr-description 
+	O_WQ_TEXT_2 = RuleOcr(roi=(66,377,52,32), area=(66,377,52,32), mode="Single", method="Default", keyword="封印", name="wq_text_2")
+	# Ocr-description 
+	O_WQ_NUM_1 = RuleOcr(roi=(32,260,72,27), area=(32,260,72,27), mode="DigitCounter", method="Default", keyword="", name="wq_num_1")
+	# Ocr-description 
+	O_WQ_NUM_2 = RuleOcr(roi=(34,406,65,24), area=(34,406,65,24), mode="DigitCounter", method="Default", keyword="", name="wq_num_2")
+	# Ocr-description 
+	O_WQ_TYPE_1 = RuleOcr(roi=(544,238,55,36), area=(544,238,55,36), mode="Single", method="Default", keyword="", name="wq_type_1")
+	# Ocr-description 
+	O_WQ_TYPE_2 = RuleOcr(roi=(544,311,55,30), area=(544,311,55,30), mode="Single", method="Default", keyword="", name="wq_type_2")
+	# Ocr-description 
+	O_WQ_TYPE_3 = RuleOcr(roi=(544,382,54,30), area=(544,382,54,30), mode="Single", method="Default", keyword="", name="wq_type_3")
+	# Ocr-description 
+	O_WQ_TYPE_4 = RuleOcr(roi=(545,452,52,32), area=(545,452,52,32), mode="Single", method="Default", keyword="", name="wq_type_4")
+	# Ocr-description 
+	O_WQ_INFO_1 = RuleOcr(roi=(609,236,309,45), area=(609,236,309,45), mode="Single", method="Default", keyword="", name="wq_info_1")
+	# Ocr-description 
+	O_WQ_INFO_2 = RuleOcr(roi=(612,308,298,41), area=(612,308,298,41), mode="Single", method="Default", keyword="", name="wq_info_2")
+	# Ocr-description 
+	O_WQ_INFO_3 = RuleOcr(roi=(612,376,305,44), area=(612,376,305,44), mode="Single", method="Default", keyword="", name="wq_info_3")
+	# Ocr-description 
+	O_WQ_INFO_4 = RuleOcr(roi=(613,446,315,44), area=(613,446,315,44), mode="Single", method="Default", keyword="", name="wq_info_4")
+
+
+	# Image Rule Assets
+	# description 
+	I_WQC_LOCK = RuleImage(roi_front=(620,528,27,31), roi_back=(620,528,27,31), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/chanllenge/chanllenge_wqc_lock.png")
+	# description 
+	I_WQC_UNLOCK = RuleImage(roi_front=(621,527,26,28), roi_back=(621,527,26,28), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/chanllenge/chanllenge_wqc_unlock.png")
+	# 挑战 
+	I_WQC_FIRE = RuleImage(roi_front=(893,503,123,64), roi_back=(871,485,164,91), threshold=0.7, method="Template matching", file="./tasks/WantedQuests/chanllenge/chanllenge_wqc_fire.png")
+
+
+	# Image Rule Assets
+	# description 
+	I_WQ_INVITE_1 = RuleImage(roi_front=(137,361,39,47), roi_back=(108,338,100,100), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/invite_wq_invite_1.png")
+	# description 
+	I_WQ_INVITE_2 = RuleImage(roi_front=(462,361,37,47), roi_back=(435,336,100,100), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/invite_wq_invite_2.png")
+	# 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")
+	# description 
+	I_WQ_FIREND_1 = RuleImage(roi_front=(449,191,172,70), roi_back=(449,191,172,70), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/invite_wq_firend_1.png")
+	# description 
+	I_WQ_FIREND_2 = RuleImage(roi_front=(743,192,172,69), roi_back=(743,192,172,69), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/invite_wq_firend_2.png")
+	# description 
+	I_WQ_FIREND_3 = RuleImage(roi_front=(453,281,175,71), roi_back=(453,281,175,71), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/invite_wq_firend_3.png")
+	# description 
+	I_WQ_FIREND_4 = RuleImage(roi_front=(743,280,171,76), roi_back=(743,280,171,76), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/invite_wq_firend_4.png")
+	# description 
+	I_WQ_FIREND_5 = RuleImage(roi_front=(479,376,148,56), roi_back=(479,376,148,56), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/invite/invite_wq_firend_5.png")
+
+
+	# Image Rule Assets
+	# 封印 
+	I_WQ_SEAL = RuleImage(roi_front=(244,181,40,40), roi_back=(56,152,664,396), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_wq_seal.png")
+	# 勾号 
+	I_WQ_DONE = RuleImage(roi_front=(248,183,37,39), roi_back=(107,147,570,389), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_wq_done.png")
+	# 一键追踪 
+	I_TRACE_ENABLE = RuleImage(roi_front=(1097,588,101,70), roi_back=(1097,588,101,70), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_trace_enable.png")
+	# 取消追踪 
+	I_TARCE_DISENABLE = RuleImage(roi_front=(1091,586,108,70), roi_back=(1091,586,108,70), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_tarce_disenable.png")
+	# 奖励宝箱 
+	I_WQ_BOX = RuleImage(roi_front=(48,187,43,38), roi_back=(20,137,100,397), threshold=0.7, method="Template matching", file="./tasks/WantedQuests/wq/wq_wq_box.png")
+	# 小号追踪 
+	I_TRACE_TRUE = RuleImage(roi_front=(173,187,28,29), roi_back=(173,187,28,29), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_trace_true.png")
+	# 小号不追踪 
+	I_TRACE_FALSE = RuleImage(roi_front=(170,186,31,32), roi_back=(170,186,31,32), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_trace_false.png")
+	# description 
+	I_GOTO_1 = RuleImage(roi_front=(978,234,87,45), roi_back=(978,234,87,45), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_goto_1.png")
+	# description 
+	I_GOTO_2 = RuleImage(roi_front=(979,305,88,43), roi_back=(979,305,88,43), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_goto_2.png")
+	# description 
+	I_GOTO_3 = RuleImage(roi_front=(979,373,88,47), roi_back=(979,373,88,47), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_goto_3.png")
+	# description 
+	I_GOTO_4 = RuleImage(roi_front=(979,447,87,42), roi_back=(979,447,87,42), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_goto_4.png")
+	# 判断是否还有任务 
+	I_WQ_CHECK_TASK = RuleImage(roi_front=(110,154,21,125), roi_back=(73,122,69,459), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_wq_check_task.png")
+
+
+	# Image Rule Assets
+	# 奇怪了之前的不能用 
+	I_WQSE_FIRE = RuleImage(roi_front=(1041,556,100,100), roi_back=(1016,534,147,138), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_wqse_fire.png")
+
+

BIN
tasks/WantedQuests/chanllenge/chanllenge_wqc_fire.png


BIN
tasks/WantedQuests/chanllenge/chanllenge_wqc_lock.png


BIN
tasks/WantedQuests/chanllenge/chanllenge_wqc_unlock.png


+ 29 - 0
tasks/WantedQuests/chanllenge/image.json

@@ -0,0 +1,29 @@
+[
+  {
+    "itemName": "wqc_lock",
+    "imageName": "chanllenge_wqc_lock.png",
+    "roiFront": "620,528,27,31",
+    "roiBack": "620,528,27,31",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "wqc_unlock",
+    "imageName": "chanllenge_wqc_unlock.png",
+    "roiFront": "621,527,26,28",
+    "roiBack": "621,527,26,28",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "wqc_fire",
+    "imageName": "chanllenge_wqc_fire.png",
+    "roiFront": "893,503,123,64",
+    "roiBack": "871,485,164,91",
+    "method": "Template matching",
+    "threshold": 0.7,
+    "description": "挑战"
+  }
+]

+ 24 - 0
tasks/WantedQuests/config.py

@@ -0,0 +1,24 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+from datetime import timedelta, time
+from pydantic import BaseModel, Field
+
+from tasks.Component.config_scheduler import Scheduler
+from tasks.Component.config_base import ConfigBase, TimeDelta
+from tasks.Component.GeneralBattle.config_general_battle import GeneralBattleConfig
+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 WantedQuests(ConfigBase):
+    scheduler: Scheduler = Field(default_factory=Scheduler)
+    wanted_quests_config: WantedQuestsConfig = Field(default_factory=WantedQuestsConfig)
+
+
+
+
+

+ 74 - 0
tasks/WantedQuests/invite/image.json

@@ -0,0 +1,74 @@
+[
+  {
+    "itemName": "wq_invite_1",
+    "imageName": "invite_wq_invite_1.png",
+    "roiFront": "137,361,39,47",
+    "roiBack": "108,338,100,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "wq_invite_2",
+    "imageName": "invite_wq_invite_2.png",
+    "roiFront": "462,361,37,47",
+    "roiBack": "435,336,100,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "wq_invite_3",
+    "imageName": "invite_wq_invite_3.png",
+    "roiFront": "754,366,39,42",
+    "roiBack": "728,339,100,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "wq_firend_1",
+    "imageName": "invite_wq_firend_1.png",
+    "roiFront": "449,191,172,70",
+    "roiBack": "449,191,172,70",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "wq_firend_2",
+    "imageName": "invite_wq_firend_2.png",
+    "roiFront": "743,192,172,69",
+    "roiBack": "743,192,172,69",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "wq_firend_3",
+    "imageName": "invite_wq_firend_3.png",
+    "roiFront": "453,281,175,71",
+    "roiBack": "453,281,175,71",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "wq_firend_4",
+    "imageName": "invite_wq_firend_4.png",
+    "roiFront": "743,280,171,76",
+    "roiBack": "743,280,171,76",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "wq_firend_5",
+    "imageName": "invite_wq_firend_5.png",
+    "roiFront": "479,376,148,56",
+    "roiBack": "479,376,148,56",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  }
+]

BIN
tasks/WantedQuests/invite/invite_wq_invite_1.png


BIN
tasks/WantedQuests/invite/invite_wq_invite_2.png


BIN
tasks/WantedQuests/invite/invite_wq_invite_3.png


+ 128 - 0
tasks/WantedQuests/ocr.json

@@ -0,0 +1,128 @@
+[
+  {
+    "itemName": "wq_number",
+    "roiFront": "569,13,50,32",
+    "roiBack": "569,13,50,32",
+    "mode": "Digit",
+    "method": "Default",
+    "keyword": "",
+    "description": "挑战券的数量"
+  },
+  {
+    "itemName": "wq_wanted",
+    "roiFront": "9,145,123,381",
+    "roiBack": "9,145,123,381",
+    "mode": "Full",
+    "method": "Default",
+    "keyword": "",
+    "description": "悬赏封印"
+  },
+  {
+    "itemName": "wq_text_1",
+    "roiFront": "67,233,52,32",
+    "roiBack": "67,233,52,32",
+    "mode": "Single",
+    "method": "Default",
+    "keyword": "封印",
+    "description": "Ocr-description"
+  },
+  {
+    "itemName": "wq_text_2",
+    "roiFront": "66,377,52,32",
+    "roiBack": "66,377,52,32",
+    "mode": "Single",
+    "method": "Default",
+    "keyword": "封印",
+    "description": "Ocr-description"
+  },
+  {
+    "itemName": "wq_num_1",
+    "roiFront": "32,260,72,27",
+    "roiBack": "32,260,72,27",
+    "mode": "DigitCounter",
+    "method": "Default",
+    "keyword": "",
+    "description": "Ocr-description"
+  },
+  {
+    "itemName": "wq_num_2",
+    "roiFront": "34,406,65,24",
+    "roiBack": "34,406,65,24",
+    "mode": "DigitCounter",
+    "method": "Default",
+    "keyword": "",
+    "description": "Ocr-description"
+  },
+  {
+    "itemName": "wq_type_1",
+    "roiFront": "544,238,55,36",
+    "roiBack": "544,238,55,36",
+    "mode": "Single",
+    "method": "Default",
+    "keyword": "",
+    "description": "Ocr-description"
+  },
+  {
+    "itemName": "wq_type_2",
+    "roiFront": "544,311,55,30",
+    "roiBack": "544,311,55,30",
+    "mode": "Single",
+    "method": "Default",
+    "keyword": "",
+    "description": "Ocr-description"
+  },
+  {
+    "itemName": "wq_type_3",
+    "roiFront": "544,382,54,30",
+    "roiBack": "544,382,54,30",
+    "mode": "Single",
+    "method": "Default",
+    "keyword": "",
+    "description": "Ocr-description"
+  },
+  {
+    "itemName": "wq_type_4",
+    "roiFront": "545,452,52,32",
+    "roiBack": "545,452,52,32",
+    "mode": "Single",
+    "method": "Default",
+    "keyword": "",
+    "description": "Ocr-description"
+  },
+  {
+    "itemName": "wq_info_1",
+    "roiFront": "609,236,309,45",
+    "roiBack": "609,236,309,45",
+    "mode": "Single",
+    "method": "Default",
+    "keyword": "",
+    "description": "Ocr-description"
+  },
+  {
+    "itemName": "wq_info_2",
+    "roiFront": "612,308,298,41",
+    "roiBack": "612,308,298,41",
+    "mode": "Single",
+    "method": "Default",
+    "keyword": "",
+    "description": "Ocr-description"
+  },
+  {
+    "itemName": "wq_info_3",
+    "roiFront": "612,376,305,44",
+    "roiBack": "612,376,305,44",
+    "mode": "Single",
+    "method": "Default",
+    "keyword": "",
+    "description": "Ocr-description"
+  },
+  {
+    "itemName": "wq_info_4",
+    "roiFront": "613,446,315,44",
+    "roiBack": "613,446,315,44",
+    "mode": "Single",
+    "method": "Default",
+    "keyword": "",
+    "description": "Ocr-description"
+  }
+]

+ 262 - 0
tasks/WantedQuests/script_task.py

@@ -0,0 +1,262 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+import re
+import copy
+from time import sleep
+from datetime import timedelta, time, datetime
+from cached_property import cached_property
+
+from module.exception import TaskEnd
+from module.logger import logger
+from module.base.timer import Timer
+
+from tasks.GameUi.game_ui import GameUi
+from tasks.GameUi.page import page_main, page_exploration
+from tasks.Component.GeneralBattle.general_battle import GeneralBattle
+from tasks.Component.GeneralBattle.config_general_battle import GeneralBattleConfig
+from tasks.Component.GeneralInvite.general_invite import GeneralInvite
+from tasks.Secret.script_task import ScriptTask as SecretScriptTask
+from tasks.WantedQuests.config import WantedQuestsConfig
+from tasks.WantedQuests.assets import WantedQuestsAssets
+
+class ScriptTask(SecretScriptTask, GeneralInvite, WantedQuestsAssets):
+
+    def run(self):
+        con = self.config
+        self.pre_work()
+        self.screenshot()
+        number_challenge = self.O_WQ_NUMBER.ocr(self.device.image)
+        O_TEXT_COPY_1 = copy.deepcopy(self.O_WQ_TEXT_1)
+        O_TEXT_COPY_2 = copy.deepcopy(self.O_WQ_TEXT_2)
+        O_TEXT_COPY_1.keyword = '封印'
+        O_TEXT_COPY_2.keyword = '封印'
+        ocr_error_count = 0
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_WQ_BOX):
+                self.ui_get_reward(self.I_WQ_BOX)
+                continue
+            if ocr_error_count > 10:
+                logger.warning('OCR failed too many times, exit')
+                break
+            if self.ocr_appear(self.O_WQ_TEXT_1, interval=0.7) or self.ocr_appear(O_TEXT_COPY_1, interval=0.7):
+                cu, re, total = self.O_WQ_NUM_1.ocr(self.device.image)
+                if cu == re == total == 0:
+                    logger.warning('OCR failed and skip this round')
+                    ocr_error_count += 1
+                if cu > total:
+                    logger.warning('Current number of wanted quests is greater than total number')
+                    cu = cu % 10
+                if cu < total and re != 0:
+                    self.execute_mission(self.O_WQ_TEXT_1, total, number_challenge)
+                continue
+            if self.ocr_appear(self.O_WQ_TEXT_2, interval=0.7) or self.ocr_appear(O_TEXT_COPY_1, interval=0.7):
+                cu, re, total = self.O_WQ_NUM_2.ocr(self.device.image)
+                if cu == re == total == 0:
+                    logger.warning('OCR failed and skip this round')
+                    ocr_error_count += 1
+                if cu > total:
+                    logger.warning('Current number of wanted quests is greater than total number')
+                    cu = cu % 10
+                if cu < total and re != 0:
+                    self.execute_mission(self.O_WQ_TEXT_2, total, number_challenge)
+                continue
+
+            if self.appear(self.I_WQ_CHECK_TASK):
+                continue
+            sleep(1.5)
+            self.screenshot()
+            if not self.appear(self.I_WQ_CHECK_TASK):
+                logger.info('No wanted quests')
+                break
+
+
+        self.next_run()
+        raise TaskEnd('WantedQuests')
+
+    def next_run(self):
+        before_end: time = self.config.wanted_quests.wanted_quests_config.before_end
+        if before_end == time(hour=0, minute=0, second=0):
+            self.set_next_run(task='WantedQuests', success=True, finish=True)
+            return
+        time_delta = timedelta(hours=-before_end.hour, minutes=-before_end.minute, seconds=-before_end.second)
+        now_datetime = datetime.now()
+        now_time = now_datetime.time()
+        if time(hour=6) <= now_time < time(hour=18):
+            # 如果是在6点到18点之间,那就设定下一次运行的时间为第二天的6点 + before_end
+            next_run_datetime = datetime.combine(now_datetime.date() + timedelta(days=1), time(hour=6))
+            next_run_datetime = next_run_datetime + time_delta
+        elif time(hour=18) <= now_time < time(hour=23, minute=59, second=59):
+            # 如果是在18点到23点59分59秒之间,那就设定下一次运行的时间为第二天的18点 + before_end
+            next_run_datetime = datetime.combine(now_datetime.date() + timedelta(days=1), time(hour=18))
+            next_run_datetime = next_run_datetime + time_delta
+        else:
+            # 如果是在0点到6点之间,那就设定下一次运行的时间为今天的18点 + before_end
+            next_run_datetime = datetime.combine(now_datetime.date(), time(hour=18))
+            next_run_datetime = next_run_datetime + time_delta
+        self.set_next_run(task='WantedQuests', target=next_run_datetime)
+
+    def pre_work(self):
+        """
+        前置工作,
+        :return:
+        """
+        self.ui_get_current_page()
+        self.ui_goto(page_main)
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_TARCE_DISENABLE):
+                break
+            if self.appear_then_click(self.I_WQ_SEAL, interval=1):
+                continue
+            if self.appear_then_click(self.I_WQ_DONE, interval=1):
+                continue
+            if self.appear_then_click(self.I_TRACE_ENABLE, interval=1):
+                continue
+        # 已追踪所有任务
+        logger.info('All wanted quests are traced')
+        self.invite_five()
+        self.ui_click_until_disappear(self.I_UI_BACK_RED)
+        self.ui_goto(page_exploration)
+
+    def execute_mission(self, ocr, num_want: int, num_challenge: int):
+        """
+
+        :param ocr: 要点击的 文字
+        :param num_want: 一共要打败的怪物数量
+        :param num_challenge: 现在有的挑战卷数量
+        :return:
+        """
+        logger.hr('Start wanted quests')
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_TRACE_TRUE):
+                break
+            if self.click(ocr, interval=1):
+                continue
+        if not self.appear(self.I_GOTO_1):
+            # 如果没有出现 '前往'按钮, 那就是这个可能是神秘任务但是没有解锁
+            logger.warning('This is a secret mission but not unlock')
+            self.ui_click(self.I_TRACE_TRUE, self.I_TRACE_FALSE)
+            return
+        # 找到一个最优的关卡来挑战
+        challenge = True if num_challenge >= 10 else False
+        def check_battle(cha: bool, wq_type, wq_info) -> tuple:
+            battle = False
+            self.screenshot()
+            type_wq = wq_type.ocr(self.device.image)
+            if cha and type_wq == '挑战':
+                battle = 'CHALLENGE'
+            if type_wq == '秘闻':
+                battle = 'SECRET'
+            if not battle:
+                return None, None
+            info = wq_info.ocr(self.device.image)
+            try:
+                # 匹配: 第九章(数量:5)
+                one_number = int(re.findall(r'(\d+)', info)[-1])
+                # one_number = int(re.findall(r'\*\(\数量:\s*(\d+)\)', info)[0])
+            except IndexError:
+                # 匹配: 第九章
+                one_number = 3
+            # num_want / one_number = 一共要打几次
+            if one_number > num_want:
+                return battle, 1
+            else:
+                return battle, num_want // one_number + 1
+
+        battle, num, goto = None, None, None
+        if not battle:
+            battle, num = check_battle(challenge, self.O_WQ_TYPE_1, self.O_WQ_INFO_1)
+            goto = self.I_GOTO_1
+        if not battle:
+            battle, num = check_battle(challenge, self.O_WQ_TYPE_2, self.O_WQ_INFO_2)
+            goto = self.I_GOTO_2
+        if not battle:
+            battle, num = check_battle(challenge, self.O_WQ_TYPE_3, self.O_WQ_INFO_3)
+            goto = self.I_GOTO_3
+        if not battle:
+            battle, num = check_battle(challenge, self.O_WQ_TYPE_4, self.O_WQ_INFO_4)
+            goto = self.I_GOTO_4
+        if battle == 'CHALLENGE':
+            self.challenge(goto, num)
+        elif battle == 'SECRET':
+            self.secret(goto, num)
+        else:
+            # 没有找到可以挑战的关卡 那就关闭
+            logger.warning('No wanted quests can be challenged')
+            return False
+
+
+    def challenge(self, goto, num):
+        self.ui_click(goto, self.I_WQC_FIRE)
+        self.ui_click(self.I_WQC_LOCK, self.I_WQC_UNLOCK)
+        self.ui_click_until_disappear(self.I_WQC_FIRE)
+        self.run_general_battle()
+        self.wait_until_appear(self.I_WQC_FIRE, wait_time=4)
+        self.ui_click_until_disappear(self.I_UI_BACK_RED)
+        # 我忘记了打完后是否需要关闭 挑战界面
+
+    def secret(self, goto, num=1):
+        self.ui_click(goto, self.I_WQSE_FIRE)
+        for i in range(num):
+            self.wait_until_appear(self.I_WQSE_FIRE)
+            self.ui_click_until_disappear(self.I_WQSE_FIRE)
+            success = self.run_general_battle(self.battle_config)
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_CHECK_EXPLORATION):
+                break
+            if self.appear_then_click(self.I_UI_BACK_RED, interval=1):
+                continue
+            if self.appear_then_click(self.I_UI_BACK_BLUE, interval=1.5):
+                continue
+        logger.info('Secret mission finished')
+
+    def invite_five(self):
+        """
+        邀请好友,默认点五个
+        :return:
+        """
+        def invite(add_button):
+            self.screenshot()
+            if not self.appear(add_button):
+                return False
+            self.ui_click(add_button, self.I_INVITE_ENSURE)
+            sleep(1)
+            self.click(self.I_WQ_FIREND_1)
+            sleep(0.4)
+            self.click(self.I_WQ_FIREND_2)
+            sleep(0.4)
+            self.click(self.I_WQ_FIREND_3)
+            sleep(0.4)
+            self.click(self.I_WQ_FIREND_4)
+            sleep(0.4)
+            self.click(self.I_WQ_FIREND_5)
+            sleep(0.2)
+            self.screenshot()
+            if not self.appear(self.I_SELECTED):
+                logger.warning('No friend selected')
+                return False
+            self.ui_click_until_disappear(self.I_INVITE_ENSURE)
+            sleep(0.5)
+
+        logger.hr('Invite friends')
+        invite(self.I_WQ_INVITE_1)
+        invite(self.I_WQ_INVITE_2)
+        invite(self.I_WQ_INVITE_3)
+
+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()
+    # print(t.appear(t.I_WQ_CHECK_TASK))
+
+
+

+ 110 - 0
tasks/WantedQuests/wq/image.json

@@ -0,0 +1,110 @@
+[
+  {
+    "itemName": "wq_seal",
+    "imageName": "wq_wq_seal.png",
+    "roiFront": "244,181,40,40",
+    "roiBack": "56,152,664,396",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "封印"
+  },
+  {
+    "itemName": "wq_done",
+    "imageName": "wq_wq_done.png",
+    "roiFront": "248,183,37,39",
+    "roiBack": "107,147,570,389",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "勾号"
+  },
+  {
+    "itemName": "trace_enable",
+    "imageName": "wq_trace_enable.png",
+    "roiFront": "1097,588,101,70",
+    "roiBack": "1097,588,101,70",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "一键追踪"
+  },
+  {
+    "itemName": "tarce_disenable",
+    "imageName": "wq_tarce_disenable.png",
+    "roiFront": "1091,586,108,70",
+    "roiBack": "1091,586,108,70",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "取消追踪"
+  },
+  {
+    "itemName": "wq_box",
+    "imageName": "wq_wq_box.png",
+    "roiFront": "48,187,43,38",
+    "roiBack": "20,137,100,397",
+    "method": "Template matching",
+    "threshold": 0.7,
+    "description": "奖励宝箱"
+  },
+  {
+    "itemName": "trace_true",
+    "imageName": "wq_trace_true.png",
+    "roiFront": "173,187,28,29",
+    "roiBack": "173,187,28,29",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "小号追踪"
+  },
+  {
+    "itemName": "trace_false",
+    "imageName": "wq_trace_false.png",
+    "roiFront": "170,186,31,32",
+    "roiBack": "170,186,31,32",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "小号不追踪"
+  },
+  {
+    "itemName": "goto_1",
+    "imageName": "wq_goto_1.png",
+    "roiFront": "978,234,87,45",
+    "roiBack": "978,234,87,45",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "goto_2",
+    "imageName": "wq_goto_2.png",
+    "roiFront": "979,305,88,43",
+    "roiBack": "979,305,88,43",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "goto_3",
+    "imageName": "wq_goto_3.png",
+    "roiFront": "979,373,88,47",
+    "roiBack": "979,373,88,47",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "goto_4",
+    "imageName": "wq_goto_4.png",
+    "roiFront": "979,447,87,42",
+    "roiBack": "979,447,87,42",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "wq_check_task",
+    "imageName": "wq_wq_check_task.png",
+    "roiFront": "110,154,21,125",
+    "roiBack": "73,122,69,459",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "判断是否还有任务"
+  }
+]

+ 11 - 0
tasks/WantedQuests/wq/se_image.json

@@ -0,0 +1,11 @@
+[
+  {
+    "itemName": "wqse_fire",
+    "imageName": "wq_wqse_fire.png",
+    "roiFront": "1041,556,100,100",
+    "roiBack": "1016,534,147,138",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "奇怪了之前的不能用"
+  }
+]

BIN
tasks/WantedQuests/wq/wq_goto_1.png


BIN
tasks/WantedQuests/wq/wq_goto_2.png


BIN
tasks/WantedQuests/wq/wq_goto_3.png


BIN
tasks/WantedQuests/wq/wq_goto_4.png


BIN
tasks/WantedQuests/wq/wq_tarce_disenable.png


BIN
tasks/WantedQuests/wq/wq_trace_enable.png


BIN
tasks/WantedQuests/wq/wq_trace_false.png


BIN
tasks/WantedQuests/wq/wq_trace_true.png


BIN
tasks/WantedQuests/wq/wq_wq_box.png


BIN
tasks/WantedQuests/wq/wq_wq_check_task.png


BIN
tasks/WantedQuests/wq/wq_wq_done.png


BIN
tasks/WantedQuests/wq/wq_wq_seal.png


Некоторые файлы не были показаны из-за большого количества измененных файлов