Sfoglia il codice sorgente

Merge pull request #81 from runhey/dev

Dev
huangrunheng 3 anni fa
parent
commit
b3201482bd
82 ha cambiato i file con 1822 aggiunte e 87 eliminazioni
  1. 2 0
      .gitignore
  2. 1 1
      README.md
  3. 2 2
      module/config/config_manual.py
  4. 1 1
      module/config/config_menu.py
  5. 2 1
      module/config/config_model.py
  6. 1 1
      module/logger.py
  7. 109 0
      module/team_flow/host.py
  8. 103 0
      module/team_flow/mqtt.py
  9. 65 0
      module/team_flow/mqtt_test.py
  10. 33 0
      module/team_flow/player.py
  11. 33 0
      module/team_flow/task.py
  12. 2 1
      requirements-in.txt
  13. 1 0
      requirements.txt
  14. 2 0
      tasks/CollectiveMissions/assets.py
  15. BIN
      tasks/CollectiveMissions/cm/cm_cm_rewards.png
  16. 9 0
      tasks/CollectiveMissions/cm/image.json
  17. 34 11
      tasks/CollectiveMissions/script_task.py
  18. 1 1
      tasks/Component/GeneralBattle/general_battle.py
  19. 2 0
      tasks/Component/Summon/assets.py
  20. 9 0
      tasks/Component/Summon/sm/image.json
  21. BIN
      tasks/Component/Summon/sm/sm_sm_confirm_2.png
  22. 5 8
      tasks/Component/Summon/summon.py
  23. 9 0
      tasks/DemonEncounter/assets.py
  24. 11 0
      tasks/DemonEncounter/boss/ocr.json
  25. BIN
      tasks/DemonEncounter/demon/demon_de_realm.png
  26. BIN
      tasks/DemonEncounter/demon/demon_de_realm_fire.png
  27. 18 0
      tasks/DemonEncounter/demon/image_side.json
  28. 59 2
      tasks/DemonEncounter/script_task.py
  29. 5 0
      tasks/Duel/script_task.py
  30. 22 1
      tasks/EternitySea/config.py
  31. 86 0
      tasks/Exploration/assets.py
  32. 90 0
      tasks/Exploration/config.py
  33. 50 0
      tasks/Exploration/res/click.json
  34. 137 0
      tasks/Exploration/res/image.json
  35. 20 0
      tasks/Exploration/res/ocr.json
  36. BIN
      tasks/Exploration/res/res_battle_reward.png
  37. BIN
      tasks/Exploration/res/res_boss_battle_button.png
  38. BIN
      tasks/Exploration/res/res_e_auto_rotate_off.png
  39. BIN
      tasks/Exploration/res/res_e_auto_rotate_on.png
  40. BIN
      tasks/Exploration/res/res_e_enter_choose_rarity.png
  41. BIN
      tasks/Exploration/res/res_e_exploration_click.png
  42. BIN
      tasks/Exploration/res/res_e_exploration_open.png
  43. BIN
      tasks/Exploration/res/res_e_n_rarity.png
  44. BIN
      tasks/Exploration/res/res_e_open_settings.png
  45. BIN
      tasks/Exploration/res/res_e_ratate_exsit.png
  46. BIN
      tasks/Exploration/res/res_e_s_rarity.png
  47. BIN
      tasks/Exploration/res/res_e_settings_button.png
  48. BIN
      tasks/Exploration/res/res_e_sure_button.png
  49. BIN
      tasks/Exploration/res/res_exploration_title.png
  50. BIN
      tasks/Exploration/res/res_normal_battle_button.png
  51. 44 0
      tasks/Exploration/res/swipe.json
  52. 249 0
      tasks/Exploration/script_task.py
  53. 29 1
      tasks/FallenSun/assets.py
  54. 35 4
      tasks/FallenSun/config.py
  55. BIN
      tasks/FallenSun/f/f_fallen_sun.png
  56. BIN
      tasks/FallenSun/f/f_fallen_sun_fire.png
  57. BIN
      tasks/FallenSun/f/f_fallen_sun_lock.png
  58. BIN
      tasks/FallenSun/f/f_fallen_sun_matching.png
  59. BIN
      tasks/FallenSun/f/f_fallen_sun_unlock.png
  60. BIN
      tasks/FallenSun/f/f_form_team.png
  61. BIN
      tasks/FallenSun/f/f_pet_present.png
  62. 65 0
      tasks/FallenSun/f/image.json
  63. 21 0
      tasks/FallenSun/res/list.json
  64. 11 0
      tasks/FallenSun/res/ocr.json
  65. 345 0
      tasks/FallenSun/script_task.py
  66. BIN
      tasks/GameUi/additional/additional_ad_disappear.png
  67. BIN
      tasks/GameUi/additional/additional_records_close.png
  68. 2 2
      tasks/GameUi/additional/records.json
  69. 2 2
      tasks/GameUi/assets.py
  70. 19 14
      tasks/GameUi/game_ui.py
  71. 17 0
      tasks/GlobalGame/config.py
  72. 4 0
      tasks/Restart/assets.py
  73. BIN
      tasks/Restart/harvest/harvest_harvest_sign_3.png
  74. BIN
      tasks/Restart/harvest/harvest_harvest_sign_4.png
  75. 18 0
      tasks/Restart/harvest/image.json
  76. 7 1
      tasks/Restart/login.py
  77. 4 2
      tasks/RyouToppa/assets.py
  78. 13 4
      tasks/RyouToppa/res/image.json
  79. BIN
      tasks/RyouToppa/res/res_ryou_reward_90.png
  80. BIN
      tasks/RyouToppa/res/res_start_toppa_button.png
  81. BIN
      tasks/RyouToppa/res/res_success_penetration.png
  82. 13 27
      tasks/RyouToppa/script_task.py

+ 2 - 0
.gitignore

@@ -8,6 +8,7 @@ config/*.yaml
 config/*.json
 config/tmp*
 !config/template*.json
+config/*.crt
 *.pyw
 dev_tools/debug_tools
 .idea
@@ -44,6 +45,7 @@ module/config/argument/setting.json
 
 
 
+
 # Created by .ignore support plugin (hsz.mobi)
 
 ### JetBrains template

+ 1 - 1
README.md

@@ -61,7 +61,7 @@ This project is licensed under the GNU General Public License v3.0.
 
 为此保持较高的入群门槛:  
 - 你的QQ等级必须大于32级(🌞🌞),注册时间超过一年,低等级账号成分复杂,还请见谅。
-- 你必须拥有一个 Github 账户来点一个 **Star**(这并不影响你入群后取消Star),同样的要求注册时间过半年。
+- 你必须拥有一个 Github 账户来点一个 **Star** (这并不影响你入群后取消Star),同样的要求注册时间过半年。
 - 入群验证填入你的 Github 账号名,无需在意问题是什么。
 
 #### 技术/开发群: 207613181

+ 2 - 2
module/config/config_manual.py

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

+ 1 - 1
module/config/config_menu.py

@@ -23,7 +23,7 @@ class ConfigMenu:
         self.menu["Daily Task"] = ['DailyTrifles', 'AreaBoss', 'GoldYoukai', 'ExperienceYoukai', 'Nian',
                                    'TalismanPass', 'DemonEncounter', 'Pets', 'SoulsTidy', 'Delegation']
         # 很肝的任务
-        self.menu["Liver Emperor Exclusive"] = ['BondlingFairyland', 'EvoZone', 'GoryouRealm']
+        self.menu["Liver Emperor Exclusive"] = ['BondlingFairyland', 'EvoZone', 'GoryouRealm', 'Exploration']
         # 阴阳寮
         self.menu["Guild"] = ['KekkaiUtilize', 'KekkaiActivation', 'RealmRaid', 'RyouToppa', 'CollectiveMissions',
                               'Hunt']

+ 2 - 1
module/config/config_model.py

@@ -11,6 +11,7 @@ from module.logger import logger
 
 # 导入配置的Python文件
 from tasks.Component.config_base import ConfigBase
+from tasks.Exploration.config import Exploration
 from tasks.RyouToppa.config import RyouToppa
 from tasks.Script.config import Script
 from tasks.Restart.config import Restart
@@ -78,6 +79,7 @@ class ConfigModel(ConfigBase):
     pets: Pets = Field(default_factory=Pets)
     souls_tidy: SoulsTidy = Field(default_factory=SoulsTidy)
     delegation: Delegation = Field(default_factory=Delegation)
+    exploration: Exploration = Field(default_factory=Exploration)
 
     # 这些是刷御魂的
     orochi: Orochi = Field(default_factory=Orochi)
@@ -94,7 +96,6 @@ class ConfigModel(ConfigBase):
     evo_zone: EvoZone = Field(default_factory=EvoZone)
     goryou_realm: GoryouRealm = Field(default_factory=GoryouRealm)
 
-
     # 这些是每周任务
     true_orochi: TrueOrochi = Field(default_factory=TrueOrochi)
     rich_man: RichMan = Field(default_factory=RichMan)

+ 1 - 1
module/logger.py

@@ -360,7 +360,7 @@ def hr(title, level=3):
         logger.info(f"[bold]<<< {title} >>>[/bold]", extra={"markup": True})
     if level == 0:
         logger.rule(characters='═')
-        logger.rule(title, characters='-')
+        logger.rule(title, characters='─')
         logger.rule(characters='═')
 
 

+ 109 - 0
module/team_flow/host.py

@@ -0,0 +1,109 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+from datetime import datetime, time
+from cached_property import cached_property
+
+from tasks.GlobalGame.config import TeamFlow, Transport
+
+from module.team_flow.mqtt import Mqtt
+from module.config.config import Config
+from module.team_flow.player import Player
+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)
+
+class Host(Mqtt, Player):
+
+    def __init__(self, config: Config):
+        Player.__init__(self, config.global_game.team_flow.username)
+        Mqtt.__init__(self, config.global_game.team_flow)
+        self.config = config
+        self.players: list[Player] = []
+        self.set_on_message(on_message)
+
+    @cached_property
+    def match_topic(self):
+        return {
+            'FirstNotice': self.on_first_notice,
+            'LastWill': self.on_last_will,
+            'TaskStart': self.on_task_start,
+            'Strategy': self.on_strategy
+        }
+
+    def on_first_notice(self, payload):
+        pass
+
+    def on_last_will(self, payload):
+        pass
+
+    def on_task_start(self, payload):
+        pass
+
+    def on_strategy(self, payload):
+        pass
+
+    def update_multi_tasks(self):
+        """
+        作为主角, 更新自身的多人任务的缓存
+        也就是从  config -> multi_tasks
+        :return:
+        """
+        for key, value in self.config.model.items():
+            task_name: str = key
+            limit_time: time = None
+            limit_count: int = None
+            role: str = None
+            if key == 'orochi':
+                limit_time = value.orochi_config.limit_time
+                limit_count = value.orochi_config.limit_count
+                role = str(value.orochi_config.user_status)
+            elif key == 'fallen_sun':
+                limit_time = value.fallen_sun_config.limit_time
+                limit_count = value.fallen_sun_config.limit_count
+                role = str(value.fallen_sun_config.user_status)
+            elif key == 'eternity_sea':
+                limit_time = value.eternity_sea_config.limit_time
+                limit_count = value.eternity_sea_config.limit_count
+                role = str(value.eternity_sea_config.user_status)
+            elif key == 'evo_zone':
+                limit_time = value.evo_zone_config.limit_time
+                limit_count = value.evo_zone_config.limit_count
+                role = str(value.evo_zone_config.user_status)
+            elif key == 'exploration':
+                # TODO 等待探索完成
+                limit_time = time(minute=30)
+                limit_count = 50
+                role = str(value.evo_zone_config.user_status)
+                continue
+            else:
+                continue
+            if not value.scheduler.enable:
+                continue
+            if task_name not in self.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,
+                    limit_time=limit_time,
+                    team_task=True,
+                    role=role,
+                    limit_count=limit_count,
+                )
+            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
+
+
+
+
+
+if __name__ == '__main__':
+    host = Host(Config('oas1'))

+ 103 - 0
module/team_flow/mqtt.py

@@ -0,0 +1,103 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+from time import sleep
+from random import randint
+from paho.mqtt import client as mqtt_client
+
+from tasks.GlobalGame.config import TeamFlow, Transport
+
+from module.logger import logger
+
+
+def on_message(client, userdata, msg):
+    if msg.topic == 'FirstNotice':
+        return
+
+    logger.info(f"Received `{msg.payload}` from `{userdata}` ")
+# ----------------------------------------------------------------------------------------------------------------------
+# 使用MQTT是为了做广播,自己手撸的话太麻烦了
+# 0. 所有玩家更新自己的策略后必须广播出去, 可以延迟一下
+# 1. 当一个玩家启动接入网络后,会向服务器发送FirstNotice,这个时候所有的玩家都要发送一次自己的策略来给新加入的玩家来优化自己的策略
+# 2. 当一个玩家退出网络后,会向服务器发送LastNotice,这个时候所有的玩家都要更新自己的策略
+# ----------------------------------------------------------------------------------------------------------------------
+class Mqtt:
+
+    def __init__(self, team_flow: TeamFlow):
+        def on_connect(client, userdata, flags, rc):
+            if rc == 0:
+                logger.info("Connected to MQTT Broker!")
+            else:
+                logger.info("Failed to connect, return code %d\n", rc)
+        self.broker = team_flow.broker
+        self.port = team_flow.port
+        self.protocol = team_flow.transport
+        self.ca = team_flow.ca
+        self.username = team_flow.username
+        self.password = team_flow.password
+        self.client_id = f'{self.username}-{randint(0, 1000)}'
+        # 连接服务器
+        self.client = mqtt_client.Client(self.client_id, clean_session=True, userdata=self)
+        if self.protocol == Transport.SSL_TLS:
+            self.client.tls_set(ca_certs=self.ca)
+        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.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})
+
+
+
+    def set_on_message(self, on_msg):
+        self.client.on_message = on_msg
+
+    def publish(self, topic: str, msg: dict) -> bool:
+        """
+
+        :param topic:
+        :param msg: 必须是一个字典
+        :return:
+        """
+        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))
+        # result: [0, 1]
+        status = result[0]
+        if status == 0:
+            logger.info(f"Send `{msg}` to topic `{topic}`")
+            return True
+        else:
+            logger.info(f"Failed to send message to topic {topic} {status}")
+            return False
+
+    def TaskStart(self, msg):
+        self.publish('TaskStart', msg)
+
+    def Strategy(self, msg):
+        self.publish('Strategy', msg)
+
+
+
+
+
+if __name__ == '__main__':
+    team_flow = TeamFlow()
+    team_flow.broker = 'v96bb091.ala.cn-hangzhou.emqxsl.cn'
+    team_flow.port = 8883
+    team_flow.transport = Transport.SSL_TLS
+    team_flow.ca = './config/emqxsl-ca.crt'
+    team_flow.username = 'test-publish'
+    team_flow.password = '12345678'
+    mqtt = Mqtt(team_flow)
+    sleep(20)
+
+

+ 65 - 0
module/team_flow/mqtt_test.py

@@ -0,0 +1,65 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+from time import sleep
+from random import randint
+from paho.mqtt import client as mqtt_client
+
+broker = 'v96bb091.ala.cn-hangzhou.emqxsl.cn'
+port = 8883
+topic = 'python/mqtt'
+client_id = f'python-mqtt-{randint(0, 1000)}'
+# 如果 broker 需要鉴权,设置用户名密码
+username = 'test-publish'
+password = '12345678'
+
+def connect_mqtt():
+    def on_connect(client, userdata, flags, rc):
+        if rc == 0:
+            print("Connected to MQTT Broker!")
+        else:
+            print("Failed to connect, return code %d\n", rc)
+
+    # Set Connecting Client ID
+    client = mqtt_client.Client(client_id)
+    client.tls_set(ca_certs='./emqxsl-ca.crt')
+    client.username_pw_set(username, password)
+    client.on_connect = on_connect
+    client.connect(broker, port)
+    return client
+
+def subscribe(client: mqtt_client):
+    def on_message(client, userdata, msg):
+        print(f"Received `{msg.payload.decode()}` from `{msg.topic}` topic")
+
+    client.subscribe(topic=topic, qos=0)
+    client.on_message = on_message
+
+
+def publish(client):
+    msg_count = 0
+    while True:
+        sleep(1)
+        msg = f"messages: {msg_count}"
+        result = client.publish(topic, msg)
+        # result: [0, 1]
+        status = result[0]
+        if status == 0:
+            print(f"Send `{msg}` to topic `{topic}`")
+        else:
+            print(f"Failed to send message to topic {topic} {status}")
+        msg_count += 1
+
+def on_message(client, userdata, msg):
+    print(f"Received `{msg.payload.decode()}` from `{msg.topic}` topic")
+
+def run():
+    client = connect_mqtt()
+    client.loop_start()
+    publish(client)
+
+
+
+if __name__ == '__main__':
+    run()
+

+ 33 - 0
module/team_flow/player.py

@@ -0,0 +1,33 @@
+# 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 random import randint
+
+
+from module.config.config import Config
+from module.team_flow.task import Task
+
+class Player:
+    def __init__(self, username: str):
+        self.username = username
+        self.multi_tasks: dict[str: Task] = {}  # 缓存多人任务的列表
+
+
+    def publish_data(self) -> dict:
+        """
+        提取要 发布的数据
+        :return:
+        """
+        result = {}
+        for name, task in self.multi_tasks.items():
+            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
+            result[name] = item
+        return result

+ 33 - 0
module/team_flow/task.py

@@ -0,0 +1,33 @@
+# 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 random import randint
+
+
+from module.config.config import Config
+
+
+class Task:
+    def __init__(self,
+                 next_run: datetime,
+                 limit_time: time,
+                 target_run: datetime = None,
+                 team_task: bool = False,
+                 role: str = 'leader',
+                 limit_count: int = 0,
+                 ):
+        self.next_run = next_run
+        self.target_run = target_run
+        self.limit_time = limit_time
+        self.team_task = team_task
+        self.role = role
+        self.limit_count = limit_count
+
+
+
+
+
+
+

+ 2 - 1
requirements-in.txt

@@ -16,4 +16,5 @@ pydantic==1.10.7
 inflection==0.5.1
 tqdm==4.65.0
 ppocr-onnx==0.0.3.9
-onepush==1.2.0
+onepush==1.2.0
+paho-mqtt==1.6.1

+ 1 - 0
requirements.txt

@@ -37,6 +37,7 @@ onepush==1.2.0            # via -r requirements-in.txt
 onnxruntime==1.15.0       # via ppocr-onnx
 opencv-python==4.7.0.72   # via -r requirements-in.txt, ppocr-onnx
 packaging==20.9           # via deprecation, onnxruntime, uiautomator2
+paho-mqtt==1.6.1          # via -r requirements-in.txt
 pillow==9.5.0             # via ppocr-onnx, uiautomator2
 ppocr-onnx==0.0.3.9       # via -r requirements-in.txt
 progress==1.6             # via uiautomator2

+ 2 - 0
tasks/CollectiveMissions/assets.py

@@ -38,6 +38,8 @@ class CollectiveMissionsAssets:
 	I_CM_ADD_3 = RuleImage(roi_front=(904,389,48,45), roi_back=(904,389,48,45), threshold=0.8, method="Template matching", file="./tasks/CollectiveMissions/cm/cm_cm_add_3.png")
 	# description 
 	I_CM_ADD_4 = RuleImage(roi_front=(904,510,47,47), roi_back=(904,510,47,47), threshold=0.8, method="Template matching", file="./tasks/CollectiveMissions/cm/cm_cm_add_4.png")
+	# 领取奖励 
+	I_CM_REWARDS = RuleImage(roi_front=(567,463,145,60), roi_back=(200,458,914,88), threshold=0.8, method="Template matching", file="./tasks/CollectiveMissions/cm/cm_cm_rewards.png")
 
 
 	# Ocr Rule Assets

BIN
tasks/CollectiveMissions/cm/cm_cm_rewards.png


+ 9 - 0
tasks/CollectiveMissions/cm/image.json

@@ -79,5 +79,14 @@
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"
+  },
+  {
+    "itemName": "cm_rewards",
+    "imageName": "cm_cm_rewards.png",
+    "roiFront": "567,463,145,60",
+    "roiBack": "200,458,914,88",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "领取奖励"
   }
 ]

+ 34 - 11
tasks/CollectiveMissions/script_task.py

@@ -62,7 +62,7 @@ class ScriptTask(GameUi, CollectiveMissionsAssets):
         logger.info(f'Best mission index is {index}')
         if mission == MC.BL:
             # 契灵单独处理
-            self._bondling_fairyland()
+            self._bondling_fairyland(index)
         elif mission == MC.AW1 or mission == MC.AW2 or mission == MC.AW3 or mission == MC.GR1 or mission == MC.GR2:
             # 其他就捐材料
             self._donate(index)
@@ -123,7 +123,7 @@ class ScriptTask(GameUi, CollectiveMissionsAssets):
     def detect_best(self) -> tuple:
         """
         自动寻找最好的任务并返回,期间记录三个任务的类型
-        :return:
+        :return: 任务类型, 0/1/2
         """
         best_index = 0
         best_class = self.detect_one(self.O_CM_1, self.O_CM_2)
@@ -149,18 +149,41 @@ class ScriptTask(GameUi, CollectiveMissionsAssets):
             best_class = now_class
         return best_class, best_index
 
-    def _bondling_fairyland(self):
+    def _bondling_fairyland(self, index: int):
         """
-        将契灵之境的任务设置为当前,同时两个小时后继续执行当前的任务收菜
+        如果御灵已经做了那么就领取奖励
+        否则将契灵之境的任务设置为当前,同时两个小时后继续执行当前的任务收菜
         :return:
         """
-        self.config.bondling_fairyland.scheduler.next_run = self.start_time
-        if not self.config.bondling_fairyland.scheduler.enable:
-            logger.error('The scheduler of bondling_fairyland is not enable')
-            logger.error('Please enable it in config file')
-            raise RequestHumanTakeover
-        self.set_next_run(task='CollectiveMissions', success=True, finish=True, target=self.start_time+ timedelta(hours=2))
-        return True
+        def bondling_finish():
+            self.screenshot()
+            if self.appear(self.I_CM_REWARDS):
+                return True
+            return False
+        if not bondling_finish():
+            self.config.bondling_fairyland.scheduler.next_run = self.start_time
+            if not self.config.bondling_fairyland.scheduler.enable:
+                logger.error('The scheduler of bondling_fairyland is not enable')
+                logger.error('Please enable it in config file')
+                raise RequestHumanTakeover
+            self.set_next_run(task='CollectiveMissions', success=True, finish=True, target=self.start_time+ timedelta(hours=2))
+            return True
+        # 领取奖励
+        logger.info('Start to collect bondling 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_CM_REWARDS, interval=1):
+                check_timer.reset()
+                continue
+            if check_timer.reached():
+                break
+        logger.info('Finish to collect bondling rewards')
+
 
     def _donate(self, index: int):
         """

+ 1 - 1
tasks/Component/GeneralBattle/general_battle.py

@@ -345,7 +345,6 @@ class GeneralBattle(GeneralBuff, GeneralBattleAssets):
         logger.info("Click preset ensure")
 
     def random_click_swipt(self):
-        time.sleep(0.4)  # 这样的好像不对
         if 0 <= random.randint(0, 500) <= 3:  # 百分之4的概率
             rand_type = random.randint(0, 2)
             match rand_type:
@@ -357,6 +356,7 @@ class GeneralBattle(GeneralBuff, GeneralBattleAssets):
                     self.swipe(self.S_BATTLE_RANDOM_RIGHT, interval=20)
             # 重新设置为长战斗
             self.device.stuck_record_add('BATTLE_STATUS_S')
+        time.sleep(0.4)  # 这样的好像不对
 
     # 判断是否在战斗中
     def is_in_battle(self, is_screenshot: bool = True) -> bool:

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

@@ -19,6 +19,8 @@ class SummonAssets:
 	I_ONE_TICKET = RuleImage(roi_front=(396,599,76,76), roi_back=(396,599,76,76), threshold=0.8, method="Template matching", file="./tasks/Component/Summon/sm/sm_one_ticket.png")
 	# description 
 	I_SM_CONFIRM = RuleImage(roi_front=(419,617,174,61), roi_back=(419,617,174,61), threshold=0.8, method="Template matching", file="./tasks/Component/Summon/sm/sm_sm_confirm.png")
+	# 抽到的时候出现的 
+	I_SM_CONFIRM_2 = RuleImage(roi_front=(377,630,206,62), roi_back=(377,630,206,62), threshold=0.8, method="Template matching", file="./tasks/Component/Summon/sm/sm_sm_confirm_2.png")
 
 
 	# Ocr Rule Assets

+ 9 - 0
tasks/Component/Summon/sm/image.json

@@ -34,5 +34,14 @@
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"
+  },
+  {
+    "itemName": "sm_confirm_2",
+    "imageName": "sm_sm_confirm_2.png",
+    "roiFront": "377,630,206,62",
+    "roiBack": "377,630,206,62",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "抽到的时候出现的"
   }
 ]

BIN
tasks/Component/Summon/sm/sm_sm_confirm_2.png


+ 5 - 8
tasks/Component/Summon/summon.py

@@ -60,18 +60,15 @@ class Summon(BaseTask, SummonAssets):
         while 1:
             self.screenshot()
             if self.appear(self.I_SM_CONFIRM):
-                logger.info('Summon one success')
+                self.ui_click_until_disappear(self.I_SM_CONFIRM)
+                break
+            if self.appear(self.I_SM_CONFIRM_2):
+                self.ui_click_until_disappear(self.I_SM_CONFIRM_2)
                 break
             if self.appear(self.I_ONE_TICKET, interval=1):
                 self.summon()
                 continue
-
-        while 1:
-            self.screenshot()
-            if not self.appear(self.I_SM_CONFIRM):
-                break
-            if self.appear_then_click(self.I_SM_CONFIRM):
-                continue
+        logger.info('Summon one success')
 
 
     def back_summon_main(self):

+ 9 - 0
tasks/DemonEncounter/assets.py

@@ -44,6 +44,11 @@ class DemonEncounterAssets:
 	I_BOSS_BACK_WHITE = RuleImage(roi_front=(16,12,39,40), roi_back=(16,12,39,40), threshold=0.8, method="Template matching", file="./tasks/DemonEncounter/boss/boss_boss_back_white.png")
 
 
+	# Ocr Rule Assets
+	# 人数 
+	O_DE_BOSS_PEOPLE = RuleOcr(roi=(880,591,100,35), area=(880,591,100,35), mode="DigitCounter", method="Default", keyword="", name="de_boss_people")
+
+
 	# Click Rule Assets
 	# 从下开始数第一个 
 	C_DE_1 = RuleClick(roi_front=(1211,478,61,58), roi_back=(1211,478,61,58), name="de_1")
@@ -93,6 +98,10 @@ class DemonEncounterAssets:
 	I_DE_SMALL_FIRE = RuleImage(roi_front=(1064,549,100,100), roi_back=(1064,549,100,100), threshold=0.8, method="Template matching", file="./tasks/DemonEncounter/demon/demon_de_small_fire.png")
 	# 神秘任务 
 	I_DE_MYSTERY = RuleImage(roi_front=(1216,296,27,29), roi_back=(1192,278,85,261), threshold=0.8, method="Template matching", file="./tasks/DemonEncounter/demon/demon_de_mystery.png")
+	# 打结界的 
+	I_DE_REALM = RuleImage(roi_front=(1209,431,30,22), roi_back=(1190,274,88,273), threshold=0.75, method="Template matching", file="./tasks/DemonEncounter/demon/demon_de_realm.png")
+	# 结界-进攻 
+	I_DE_REALM_FIRE = RuleImage(roi_front=(696,421,129,63), roi_back=(162,99,1106,610), threshold=0.8, method="Template matching", file="./tasks/DemonEncounter/demon/demon_de_realm_fire.png")
 
 
 	# Ocr Rule Assets

+ 11 - 0
tasks/DemonEncounter/boss/ocr.json

@@ -0,0 +1,11 @@
+[
+  {
+    "itemName": "de_boss_people",
+    "roiFront": "880,591,100,35",
+    "roiBack": "880,591,100,35",
+    "mode": "DigitCounter",
+    "method": "Default",
+    "keyword": "",
+    "description": "人数"
+  }
+]

BIN
tasks/DemonEncounter/demon/demon_de_realm.png


BIN
tasks/DemonEncounter/demon/demon_de_realm_fire.png


+ 18 - 0
tasks/DemonEncounter/demon/image_side.json

@@ -97,5 +97,23 @@
     "method": "Template matching",
     "threshold": 0.8,
     "description": "神秘任务"
+  },
+  {
+    "itemName": "de_realm",
+    "imageName": "demon_de_realm.png",
+    "roiFront": "1209,431,30,22",
+    "roiBack": "1190,274,88,273",
+    "method": "Template matching",
+    "threshold": 0.75,
+    "description": "打结界的"
+  },
+  {
+    "itemName": "de_realm_fire",
+    "imageName": "demon_de_realm_fire.png",
+    "roiFront": "696,421,129,63",
+    "roiBack": "162,99,1106,610",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "结界-进攻"
   }
 ]

+ 59 - 2
tasks/DemonEncounter/script_task.py

@@ -5,6 +5,7 @@ import time
 
 from enum import Enum
 from cached_property import cached_property
+from datetime import datetime
 
 from module.logger import logger
 from module.exception import TaskEnd
@@ -29,6 +30,9 @@ class LanternClass(Enum):
 class ScriptTask(GameUi, GeneralBattle, DemonEncounterAssets):
 
     def run(self):
+        if not self.check_time():
+            logger.warning('Time is not right')
+            raise TaskEnd('DemonEncounter')
         self.ui_get_current_page()
         self.ui_goto(page_demon_encounter)
         self.execute_lantern()
@@ -47,7 +51,19 @@ class ScriptTask(GameUi, GeneralBattle, DemonEncounterAssets):
         while 1:
             self.screenshot()
             if self.appear(self.I_BOSS_FIRE):
-                break
+                current, remain, total = self.O_DE_BOSS_PEOPLE.ocr(self.device.image)
+                if total == 300 and current >= 290:
+                    logger.info('Boss battle people is full')
+                    if not self.appear(self.I_UI_BACK_RED):
+                        logger.warning('Boss battle people is full but no red back')
+                        continue
+                    self.ui_click_until_disappear(self.I_UI_BACK_RED)
+                    # 退出重新选一个没人慢的boss
+                    logger.info('Exit and reselect')
+                    continue
+                else:
+                    logger.info('Boss battle people is not full')
+                    break
 
             if self.appear_then_click(self.I_BOSS_NAMAZU, interval=1):
                 continue
@@ -181,9 +197,11 @@ class ScriptTask(GameUi, GeneralBattle, DemonEncounterAssets):
         self.I_DE_BOX.roi_back = match_roi[index]
         self.I_DE_LETTER.roi_back = match_roi[index]
         self.I_DE_MYSTERY.roi_back = match_roi[index]
+        self.I_DE_REALM.roi_back = match_roi[index]
         target_box = self.I_DE_BOX
         target_letter = self.I_DE_LETTER
         target_mystery = self.I_DE_MYSTERY
+        target_realm = self.I_DE_REALM
         target_empty = match_empty[index]
 
         # 开始判断
@@ -197,6 +215,9 @@ class ScriptTask(GameUi, GeneralBattle, DemonEncounterAssets):
         elif self.appear(target_mystery):
             logger.info(f'Lantern {index} is mystery task')
             return LanternClass.MYSTERY
+        elif self.appear(target_realm):
+            logger.info(f'Lantern {index} is realm')
+            return LanternClass.REALM
         elif self.appear(target_empty):
             logger.info(f'Lantern {index} is empty')
             return LanternClass.EMPTY
@@ -300,12 +321,48 @@ class ScriptTask(GameUi, GeneralBattle, DemonEncounterAssets):
 
     def _realm(self, target_click):
         # 结界
-        self._battle(target_click)
+        config = self.con
+        while 1:
+            self.screenshot()
+            if not self.appear(self.I_DE_LOCATION):
+                logger.info('Battle Start')
+                break
+            if self.appear_then_click(self.I_DE_REALM_FIRE, interval=0.7):
+                continue
+
+            if self.click(target_click, interval=1):
+                continue
+        if self.run_general_battle(config):
+            logger.info('Battle End')
 
     def _mystery(self, target_click):
         # 神秘任务, 不做
         pass
 
+    def check_time(self):
+        """
+        检查时间是否正确,
+        如果正确就继续
+        如果不在17:00到22:00之间,就推迟到下一个 17:30
+        :return:
+        """
+        now = datetime.now()
+        if now.hour < 17:
+            # 17点之前,推迟到当天的17点半
+            logger.info('Before 17:00, wait to 17:30')
+            target_time = datetime(now.year, now.month, now.day, 17, 30, 0)
+            self.set_next_run(task='DemonEncounter', success=False, finish=False, target=target_time)
+            return False
+        elif now.hour >= 22:
+            # 22点之后,推迟到第二天的17:30
+            logger.info('After 22:00, wait to 17:30')
+            target_time = datetime(now.year, now.month, now.day, 17, 30, 0) + datetime.timedelta(days=1)
+            self.set_next_run(task='DemonEncounter', success=False, finish=False, target=target_time)
+            return False
+        else:
+            return True
+
+
 if __name__ == '__main__':
     from module.config.config import Config
     from module.device.device import Device

+ 5 - 0
tasks/Duel/script_task.py

@@ -145,6 +145,11 @@ class ScriptTask(GameUi, GeneralBattle, DuelAssets):
                 break
             if self.ocr_appear_click(self.O_D_HAND, interval=1):
                 continue
+            # 如果对方直接秒退,那自己就是赢的
+            if self.appear(self.I_D_VICTORY):
+                logger.info('Duel battle win')
+                self.ui_click_until_disappear(self.I_D_VICTORY)
+                return True
         # 绿标
         self.green_mark(enable, mark_mode)
         # 等待结果

+ 22 - 1
tasks/EternitySea/config.py

@@ -2,10 +2,31 @@
 # @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.Orochi.config import UserStatus
 
 
+class Layer(str, Enum):
+    ONE = '壹层'
+    TWO = '贰层'
+    THREE = '叁层'
+    FOUR = '肆层'
+
+class EternitySeaConfig(ConfigBase):
+    # 身份
+    user_status: UserStatus = Field(default=UserStatus.LEADER, description='user_status_help')
+    # 层数
+    layer: Layer = Field(default=Layer.FOUR, description='layer_help')
+    # 限制时间
+    limit_time: time = Field(default=time(minute=30), description='limit_time_help')
+    # 限制次数
+    limit_count: int = Field(default=50, description='limit_count_help')
+
 class EternitySea(ConfigBase):
-    scheduler: Scheduler = Field(default_factory=Scheduler)
+    scheduler: Scheduler = Field(default_factory=Scheduler)
+    eternity_sea_config: EternitySeaConfig = Field(default_factory=EternitySeaConfig)
+

+ 86 - 0
tasks/Exploration/assets.py

@@ -0,0 +1,86 @@
+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 ExplorationAssets: 
+
+
+	# Click Rule Assets
+	# 点击设置按钮 
+	C_CLICK_SETTINGS = RuleClick(roi_front=(55,662,21,21), roi_back=(55,662,21,21), name="click_settings")
+	# 选中候补出战 
+	C_CLICK_STANDBY_TEAM = RuleClick(roi_front=(545,222,506,100), roi_back=(545,222,506,100), name="click_standby_team")
+	# 点击全部式神按钮 
+	C_CLICK_ALL_SHIKI = RuleClick(roi_front=(31,623,65,58), roi_back=(31,623,65,58), name="click_all_shiki")
+	# 选中n阶式神 
+	C_CLICK_N_SHIKI = RuleClick(roi_front=(146,301,45,54), roi_back=(146,301,45,54), name="click_n_shiki")
+	# 位置1 
+	C_CLICK_ROTATE_1 = RuleClick(roi_front=(516,582,22,21), roi_back=(516,582,22,21), name="click_rotate_1")
+	# 位置2 
+	C_CLICK_ROTATE_2 = RuleClick(roi_front=(650,587,21,21), roi_back=(650,587,21,21), name="click_rotate_2")
+	# 位置3 
+	C_CLICK_ROTATE_3 = RuleClick(roi_front=(785,587,21,21), roi_back=(785,587,21,21), name="click_rotate_3")
+	# 位置4 
+	C_CLICK_ROTATE_4 = RuleClick(roi_front=(921,590,21,21), roi_back=(921,590,21,21), name="click_rotate_4")
+
+
+	# Image Rule Assets
+	# 进入难度选择界面 
+	I_E_EXPLORATION_OPEN = RuleImage(roi_front=(1077,248,37,80), roi_back=(1072,242,47,92), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_e_exploration_open.png")
+	# 探索按钮 
+	I_E_EXPLORATION_CLICK = RuleImage(roi_front=(898,518,96,42), roi_back=(898,518,96,42), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_e_exploration_click.png")
+	# 自动轮换开着 
+	I_E_AUTO_ROTATE_ON = RuleImage(roi_front=(104,649,153,44), roi_back=(104,649,153,44), threshold=0.9, method="Template matching", file="./tasks/Exploration/res/res_e_auto_rotate_on.png")
+	# 自动轮换关闭 
+	I_E_AUTO_ROTATE_OFF = RuleImage(roi_front=(108,650,150,46), roi_back=(108,650,150,46), threshold=0.85, method="Template matching", file="./tasks/Exploration/res/res_e_auto_rotate_off.png")
+	# 成功打开设置 
+	I_E_OPEN_SETTINGS = RuleImage(roi_front=(466,110,170,50), roi_back=(466,110,170,50), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_e_open_settings.png")
+	# 选择式神稀有度 
+	I_E_ENTER_CHOOSE_RARITY = RuleImage(roi_front=(34,288,62,47), roi_back=(34,288,62,47), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_e_enter_choose_rarity.png")
+	# 候补N卡 
+	I_E_N_RARITY = RuleImage(roi_front=(42,625,46,49), roi_back=(42,625,46,49), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_e_n_rarity.png")
+	# 候补素材 
+	I_E_S_RARITY = RuleImage(roi_front=(33,620,63,59), roi_back=(33,620,63,59), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_e_s_rarity.png")
+	# 已候补出战的狗粮 
+	I_E_RATATE_EXSIT = RuleImage(roi_front=(108,580,995,32), roi_back=(108,580,995,32), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_e_ratate_exsit.png")
+	# 确定按钮 
+	I_E_SURE_BUTTON = RuleImage(roi_front=(1135,426,43,37), roi_back=(1135,426,43,37), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_e_sure_button.png")
+	# 设置按钮 
+	I_E_SETTINGS_BUTTON = RuleImage(roi_front=(37,692,53,26), roi_back=(37,692,53,26), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_e_settings_button.png")
+	# 普通怪 
+	I_NORMAL_BATTLE_BUTTON = RuleImage(roi_front=(636,263,42,39), roi_back=(0,0,1279,719), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_normal_battle_button.png")
+	# boss 
+	I_BOSS_BATTLE_BUTTON = RuleImage(roi_front=(683,256,38,34), roi_back=(0,0,1276,719), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_boss_battle_button.png")
+	# 战后奖励 
+	I_BATTLE_REWARD = RuleImage(roi_front=(647,395,31,21), roi_back=(1,1,1278,718), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_battle_reward.png")
+	# 妖 
+	I_EXPLORATION_TITLE = RuleImage(roi_front=(1133,124,47,43), roi_back=(1133,124,47,43), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_exploration_title.png")
+
+
+	# Ocr Rule Assets
+	# 识别当前显示的章节 
+	O_E_EXPLORATION_LEVEL_NUMBER = RuleOcr(roi=(1079,193,147,467), area=(1079,193,147,467), mode="Full", method="Default", keyword="", name="e_exploration_level_number")
+	# 候补出战的数量 
+	O_E_ALTERNATE_NUMBER = RuleOcr(roi=(1092,122,69,32), area=(1092,122,69,32), mode="DigitCounter", method="Default", keyword="", name="e_alternate_number")
+
+
+	# Swipe Rule Assets
+	# 向上滑动章节 
+	S_SWIPE_LEVEL_UP = RuleSwipe(roi_front=(1142,328,21,21), roi_back=(1143,444,21,21), mode="default", name="swipe_level_up")
+	# 向下滑动章节 
+	S_SWIPE_LEVEL_DOWN = RuleSwipe(roi_front=(1143,486,21,21), roi_back=(1143,367,21,23), mode="default", name="swipe_level_down")
+	# 往左滑动 
+	S_SWIPE_BACKGROUND_RIGHT = RuleSwipe(roi_front=(1093,148,21,21), roi_back=(397,140,21,21), mode="default", name="swipe_background_right")
+	# 往右滑动 
+	S_SWIPE_BACKGROUND_LEFT = RuleSwipe(roi_front=(420,142,21,21), roi_back=(1183,146,21,21), mode="default", name="swipe_background_left")
+	# 滑动狗粮选择界面 
+	S_SWIPE_SHIKI_TO_LEFT = RuleSwipe(roi_front=(890,587,21,21), roi_back=(351,584,21,21), mode="default", name="swipe_shiki_to_left")
+	# 滑动一个式神的宽度 
+	S_SWIPE_SHIKI_TO_LEFT_ONE = RuleSwipe(roi_front=(977,582,21,21), roi_back=(889,584,21,22), mode="default", name="swipe_shiki_to_left_one")
+
+

+ 90 - 0
tasks/Exploration/config.py

@@ -0,0 +1,90 @@
+from pydantic import BaseModel, Field
+from enum import Enum
+from tasks.Component.GeneralBattle.config_general_battle import GeneralBattleConfig
+from tasks.Component.SwitchSoul.switch_soul_config import SwitchSoulConfig
+from tasks.Component.config_base import ConfigBase
+from tasks.Component.config_scheduler import Scheduler
+
+
+class ExplorationLevel(str, Enum):
+    EXPLORATION_1 = '第一章'
+    EXPLORATION_2 = '第二章'
+    EXPLORATION_3 = '第三章'
+    EXPLORATION_4 = '第四章'
+    EXPLORATION_5 = '第五章'
+    EXPLORATION_6 = '第六章'
+    EXPLORATION_7 = '第七章'
+    EXPLORATION_8 = '第八章'
+    EXPLORATION_9 = '第九章'
+    EXPLORATION_10 = '第十章'
+    EXPLORATION_11 = '第十一章'
+    EXPLORATION_12 = '第十二章'
+    EXPLORATION_13 = '第十三章'
+    EXPLORATION_14 = '第十四章'
+    EXPLORATION_15 = '第十五章'
+    EXPLORATION_16 = '第十六章'
+    EXPLORATION_17 = '第十七章'
+    EXPLORATION_18 = '第十八章'
+    EXPLORATION_19 = '第十九章'
+    EXPLORATION_20 = '第二十章'
+    EXPLORATION_21 = '第二十一章'
+    EXPLORATION_22 = '第二十二章'
+    EXPLORATION_23 = '第二十三章'
+    EXPLORATION_24 = '第二十四章'
+    EXPLORATION_25 = '第二十五章'
+    EXPLORATION_26 = '第二十六章'
+    EXPLORATION_27 = '第二十七章'
+    EXPLORATION_28 = '第二十八章'
+
+
+class AttackNumber(str, Enum):
+    SEVEN = '7'
+    ALL = 'all'
+
+
+# class AttackRole(str, Enum):
+#     exp = '经验'
+#     gold = '金币'
+#     box = '奖励'
+#     ALL = '无所谓'
+
+
+# 是否自动添加候补式神
+class AutoRotate(str, Enum):
+    no = '不'
+    yes = '是'
+
+
+class ChooseRarity(str, Enum):
+    N = 'N卡'
+    S = '素材'
+
+
+class ExplorationConfig(BaseModel):
+    buff_gold_50_click: bool = Field(default=False)
+    buff_gold_100_click: bool = Field(default=False)
+
+    attack_number: AttackNumber = Field(title='探索次数', default=AttackNumber.SEVEN,
+                                        description='默认探索7次')
+
+    current_exploration_times: str = Field(default='0', description='探索次数')
+
+    exploration_level: ExplorationLevel = Field(title='探索等级', default=ExplorationLevel.EXPLORATION_28,
+                                                description='探索等级 默认二十八')
+
+    auto_rotate: AutoRotate = Field(title='自动添加候补式神', default=AutoRotate.no,
+                                    description='自动添加候补式神 默认 否')
+
+    # attack_role: AttackRole = Field(title='进攻的类型',
+    #                                 default=AttackRole.ALL, description='攻击的类型')
+
+    choose_rarity: ChooseRarity = Field(title='选择狗粮稀有度', default=ChooseRarity.N, description='N')
+
+
+class Exploration(ConfigBase):
+    scheduler: Scheduler = Field(default_factory=Scheduler)
+    exploration_config: ExplorationConfig = Field(default_factory=ExplorationConfig)
+    general_battle_config: GeneralBattleConfig = Field(default_factory=GeneralBattleConfig)
+    switch_soul_config: SwitchSoulConfig = Field(default_factory=SwitchSoulConfig)
+    # auto_rotate_after_times: str = Field(default='30', description='探索30次后, 检测是否需要添加候补式神')
+    # go_to_realm_after_times: str = Field(default='5', description='探索5次后, 检测是否需要进行结界突破')

+ 50 - 0
tasks/Exploration/res/click.json

@@ -0,0 +1,50 @@
+[
+  {
+    "itemName": "click_settings",
+    "roiFront": "55,662,21,21",
+    "roiBack": "55,662,21,21",
+    "description": "点击设置按钮"
+  },
+  {
+    "itemName": "click_standby_team",
+    "roiFront": "545,222,506,100",
+    "roiBack": "545,222,506,100",
+    "description": "选中候补出战"
+  },
+  {
+    "itemName": "click_all_shiki",
+    "roiFront": "31,623,65,58",
+    "roiBack": "31,623,65,58",
+    "description": "点击全部式神按钮"
+  },
+  {
+    "itemName": "click_n_shiki",
+    "roiFront": "146,301,45,54",
+    "roiBack": "146,301,45,54",
+    "description": "选中n阶式神"
+  },
+  {
+    "itemName": "click_rotate_1",
+    "roiFront": "516,582,22,21",
+    "roiBack": "516,582,22,21",
+    "description": "位置1"
+  },
+  {
+    "itemName": "click_rotate_2",
+    "roiFront": "650,587,21,21",
+    "roiBack": "650,587,21,21",
+    "description": "位置2"
+  },
+  {
+    "itemName": "click_rotate_3",
+    "roiFront": "785,587,21,21",
+    "roiBack": "785,587,21,21",
+    "description": "位置3"
+  },
+  {
+    "itemName": "click_rotate_4",
+    "roiFront": "921,590,21,21",
+    "roiBack": "921,590,21,21",
+    "description": "位置4"
+  }
+]

+ 137 - 0
tasks/Exploration/res/image.json

@@ -0,0 +1,137 @@
+[
+  {
+    "itemName": "e_exploration_open",
+    "imageName": "res_e_exploration_open.png",
+    "roiFront": "1077,248,37,80",
+    "roiBack": "1072,242,47,92",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "进入难度选择界面"
+  },
+  {
+    "itemName": "e_exploration_click",
+    "imageName": "res_e_exploration_click.png",
+    "roiFront": "898,518,96,42",
+    "roiBack": "898,518,96,42",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "探索按钮"
+  },
+  {
+    "itemName": "e_auto_rotate_on",
+    "imageName": "res_e_auto_rotate_on.png",
+    "roiFront": "104,649,153,44",
+    "roiBack": "104,649,153,44",
+    "method": "Template matching",
+    "threshold": 0.9,
+    "description": "自动轮换开着"
+  },
+  {
+    "itemName": "e_auto_rotate_off",
+    "imageName": "res_e_auto_rotate_off.png",
+    "roiFront": "108,650,150,46",
+    "roiBack": "108,650,150,46",
+    "method": "Template matching",
+    "threshold": 0.85,
+    "description": "自动轮换关闭"
+  },
+  {
+    "itemName": "e_open_settings",
+    "imageName": "res_e_open_settings.png",
+    "roiFront": "466,110,170,50",
+    "roiBack": "466,110,170,50",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "成功打开设置"
+  },
+  {
+    "itemName": "e_enter_choose_rarity",
+    "imageName": "res_e_enter_choose_rarity.png",
+    "roiFront": "34,288,62,47",
+    "roiBack": "34,288,62,47",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "选择式神稀有度"
+  },
+  {
+    "itemName": "e_n_rarity",
+    "imageName": "res_e_n_rarity.png",
+    "roiFront": "42,625,46,49",
+    "roiBack": "42,625,46,49",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "候补N卡"
+  },
+  {
+    "itemName": "e_s_rarity",
+    "imageName": "res_e_s_rarity.png",
+    "roiFront": "33,620,63,59",
+    "roiBack": "33,620,63,59",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "候补素材"
+  },
+  {
+    "itemName": "e_ratate_exsit",
+    "imageName": "res_e_ratate_exsit.png",
+    "roiFront": "108,580,995,32",
+    "roiBack": "108,580,995,32",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "已候补出战的狗粮"
+  },
+  {
+    "itemName": "e_sure_button",
+    "imageName": "res_e_sure_button.png",
+    "roiFront": "1135,426,43,37",
+    "roiBack": "1135,426,43,37",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "确定按钮"
+  },
+  {
+    "itemName": "e_settings_button",
+    "imageName": "res_e_settings_button.png",
+    "roiFront": "37,692,53,26",
+    "roiBack": "37,692,53,26",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "设置按钮"
+  },
+  {
+    "itemName": "normal_battle_button",
+    "imageName": "res_normal_battle_button.png",
+    "roiFront": "636,263,42,39",
+    "roiBack": "0,0,1279,719",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "普通怪"
+  },
+  {
+    "itemName": "boss_battle_button",
+    "imageName": "res_boss_battle_button.png",
+    "roiFront": "683,256,38,34",
+    "roiBack": "0,0,1276,719",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "boss"
+  },
+  {
+    "itemName": "battle_reward",
+    "imageName": "res_battle_reward.png",
+    "roiFront": "647,395,31,21",
+    "roiBack": "1,1,1278,718",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "战后奖励"
+  },
+  {
+    "itemName": "exploration_title",
+    "imageName": "res_exploration_title.png",
+    "roiFront": "1133,124,47,43",
+    "roiBack": "1133,124,47,43",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "妖"
+  }
+]

+ 20 - 0
tasks/Exploration/res/ocr.json

@@ -0,0 +1,20 @@
+[
+  {
+    "itemName": "e_exploration_level_number",
+    "roiFront": "1079,193,147,467",
+    "roiBack": "1079,193,147,467",
+    "mode": "Full",
+    "method": "Default",
+    "keyword": "",
+    "description": "识别当前显示的章节"
+  },
+  {
+    "itemName": "e_alternate_number",
+    "roiFront": "1092,122,69,32",
+    "roiBack": "1092,122,69,32",
+    "mode": "DigitCounter",
+    "method": "Default",
+    "keyword": "",
+    "description": "候补出战的数量"
+  }
+]

BIN
tasks/Exploration/res/res_battle_reward.png


BIN
tasks/Exploration/res/res_boss_battle_button.png


BIN
tasks/Exploration/res/res_e_auto_rotate_off.png


BIN
tasks/Exploration/res/res_e_auto_rotate_on.png


BIN
tasks/Exploration/res/res_e_enter_choose_rarity.png


BIN
tasks/Exploration/res/res_e_exploration_click.png


BIN
tasks/Exploration/res/res_e_exploration_open.png


BIN
tasks/Exploration/res/res_e_n_rarity.png


BIN
tasks/Exploration/res/res_e_open_settings.png


BIN
tasks/Exploration/res/res_e_ratate_exsit.png


BIN
tasks/Exploration/res/res_e_s_rarity.png


BIN
tasks/Exploration/res/res_e_settings_button.png


BIN
tasks/Exploration/res/res_e_sure_button.png


BIN
tasks/Exploration/res/res_exploration_title.png


BIN
tasks/Exploration/res/res_normal_battle_button.png


+ 44 - 0
tasks/Exploration/res/swipe.json

@@ -0,0 +1,44 @@
+[
+  {
+    "itemName": "swipe_level_up",
+    "roiFront": "1142,328,21,21",
+    "roiBack": "1143,444,21,21",
+    "mode": "default",
+    "description": "向上滑动章节"
+  },
+  {
+    "itemName": "swipe_level_down",
+    "roiFront": "1143,486,21,21",
+    "roiBack": "1143,367,21,23",
+    "mode": "default",
+    "description": "向下滑动章节"
+  },
+  {
+    "itemName": "swipe_background_right",
+    "roiFront": "1093,148,21,21",
+    "roiBack": "397,140,21,21",
+    "mode": "default",
+    "description": "往左滑动"
+  },
+  {
+    "itemName": "swipe_background_left",
+    "roiFront": "420,142,21,21",
+    "roiBack": "1183,146,21,21",
+    "mode": "default",
+    "description": "往右滑动"
+  },
+  {
+    "itemName": "swipe_shiki_to_left",
+    "roiFront": "890,587,21,21",
+    "roiBack": "351,584,21,21",
+    "mode": "default",
+    "description": "滑动狗粮选择界面"
+  },
+  {
+    "itemName": "swipe_shiki_to_left_one",
+    "roiFront": "977,582,21,21",
+    "roiBack": "889,584,21,22",
+    "mode": "default",
+    "description": "滑动一个式神的宽度"
+  }
+]

+ 249 - 0
tasks/Exploration/script_task.py

@@ -0,0 +1,249 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+import time
+
+from tasks.Component.SwitchSoul.switch_soul import SwitchSoul
+from tasks.Exploration.assets import ExplorationAssets
+from tasks.Exploration.config import ChooseRarity, AutoRotate, AttackNumber
+from tasks.Component.GeneralBattle.general_battle import GeneralBattle
+from tasks.GameUi.game_ui import GameUi
+from tasks.GameUi.page import page_exploration, page_shikigami_records, page_main
+
+from module.logger import logger
+from module.exception import RequestHumanTakeover
+from module.atom.image_grid import ImageGrid
+
+
+class ScriptTask(GeneralBattle, GameUi, SwitchSoul, ExplorationAssets):
+    medal_grid: ImageGrid = None
+
+    def run(self):
+        """
+        执行
+        :return:
+        """
+        # 探索的 config
+        explorationConfig = self.config.exploration
+
+        # 切换御魂
+        if explorationConfig.switch_soul_config.enable:
+            self.ui_get_current_page()
+            self.ui_goto(page_shikigami_records)
+            self.run_switch_soul(explorationConfig.switch_soul_config.switch_group_team)
+
+        if explorationConfig.switch_soul_config.enable_switch_by_name:
+            self.ui_get_current_page()
+            self.ui_goto(page_shikigami_records)
+            self.run_switch_soul_by_name(explorationConfig.switch_soul_config.group_name, explorationConfig.switch_soul_config.team_name)
+
+        # 开启加成
+        con = self.config.exploration.exploration_config
+        if con.buff_gold_50_click or con.buff_gold_100_click:
+            self.ui_get_current_page()
+            self.ui_goto(page_main)
+            self.open_buff()
+            if con.buff_gold_50_click:
+                self.gold_50()
+            if con.buff_gold_100_click:
+                self.gold_100()
+            self.close_buff()
+
+        self.ui_get_current_page()
+        # 探索页面
+        self.ui_goto(page_exploration)
+
+        # ************************* 跳转至对应指定章节并进入 *******************
+        # 默认全部解锁, 当前处于第二十八章
+        # 查找指定的章节:
+        if not self.open_expect_level():
+            logger.critical(f'Not find {explorationConfig.exploration_config.exploration_level} or'
+                            f' Enter {explorationConfig.exploration_config.exploration_level} failed!')
+            raise RequestHumanTakeover
+
+        # 只探索7次
+        if explorationConfig.exploration_config.attack_number == AttackNumber.SEVEN:
+            count = 0
+            while count < 7:
+                self.screenshot()
+                if self.appear_then_click(self.I_E_EXPLORATION_CLICK):
+                    count += 1
+                    # 进入战斗环节
+                    self.battle_process()
+                if self.appear_then_click(self.I_EXPLORATION_TITLE):
+                    self.open_expect_level()
+
+    # 查找指定的章节:
+    def open_expect_level(self):
+        swipeCount = 0
+        while 1:
+            # 探索的 config
+            explorationConfig = self.config.exploration
+
+            # 判断有无目标章节
+            self.screenshot()
+            # 获取当前章节名
+            results = self.O_E_EXPLORATION_LEVEL_NUMBER.detect_and_ocr(self.device.image)
+            text1 = [result.ocr_text for result in results]
+            # 判断当前章节有无目标章节
+            result = set(text1).intersection({explorationConfig.exploration_config.exploration_level})
+            # 有则跳出检测
+            if result and len(result) > 0:
+                break
+            self.device.click_record_clear()
+            self.swipe(self.S_SWIPE_LEVEL_UP)
+            swipeCount += 1
+            if swipeCount >= 25:
+                return False
+
+        # 选中对应章节
+        while 1:
+            self.screenshot()
+            self.O_E_EXPLORATION_LEVEL_NUMBER.keyword = explorationConfig.exploration_config.exploration_level
+            if self.ocr_appear_click(self.O_E_EXPLORATION_LEVEL_NUMBER):
+                self.wait_until_appear(self.I_E_EXPLORATION_CLICK)
+            if self.appear(self.I_E_EXPLORATION_CLICK):
+                break
+
+        return True
+
+    # 候补:
+    def enter_settings_and_do_operations(self):
+        # 打开设置
+        self.click(self.C_CLICK_SETTINGS)
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_E_OPEN_SETTINGS):
+                break
+            else:
+                self.click(self.C_CLICK_SETTINGS)
+                if self.wait_until_appear(self.I_E_OPEN_SETTINGS):
+                    break
+        # 候补出战数量识别
+        self.screenshot()
+        cu, res, total = self.O_E_ALTERNATE_NUMBER.ocr(self.device.image)
+        if cu >= 40:
+            self.appear_then_click(self.I_E_SURE_BUTTON)
+            return
+        else:
+            self.add_shiki()
+
+    # 添加式神
+    def add_shiki(self):
+        self.screenshot()
+        # 点击展开式神稀有度选择界面
+        self.click(self.C_CLICK_ALL_SHIKI)
+        while 1:
+            self.screenshot()
+            # 成功进入稀有度选择界面
+            if self.appear(self.I_E_ENTER_CHOOSE_RARITY):
+                if self.config.exploration.exploration_config.choose_rarity == ChooseRarity.N:
+                    # N 卡
+                    self.click(self.C_CLICK_N_SHIKI)
+                else:
+                    # 素材卡
+                    self.appear_then_click(self.I_E_ENTER_CHOOSE_RARITY)
+            self.screenshot()
+            if self.appear(self.I_E_N_RARITY):
+                # 进入N卡添加界面  退出
+                break
+            if self.appear(self.I_E_S_RARITY):
+                # 进入素材添加界面 退出
+                break
+        # 选中候补出战框
+        self.click(self.C_CLICK_STANDBY_TEAM)
+        # 移动至未候补的狗粮
+        while 1:
+            # 慢一点
+            time.sleep(0.5)
+            self.screenshot()
+            if self.appear(self.I_E_RATATE_EXSIT):
+                self.swipe(self.S_SWIPE_SHIKI_TO_LEFT)
+            else:
+                break
+        while 1:
+            # 候补出战数量识别
+            self.screenshot()
+            cu, res, total = self.O_E_ALTERNATE_NUMBER.ocr(self.device.image)
+            if cu >= 40:
+                break
+            self.swipe(self.S_SWIPE_SHIKI_TO_LEFT_ONE)
+            # 慢一点
+            time.sleep(0.5)
+            self.screenshot()
+            self.click(self.C_CLICK_ROTATE_1)
+            self.device.click_record_clear()
+
+        self.appear_then_click(self.I_E_SURE_BUTTON)
+
+    # 探索战斗流程
+    def do_battle(self):
+        while 1:
+            self.screenshot()
+            # boss 战
+            if self.appear_then_click(self.I_BOSS_BATTLE_BUTTON):
+                self.run_general_battle(self.config.exploration.general_battle_config)
+                self.screenshot()
+                if self.wait_until_appear(self.I_E_SETTINGS_BUTTON):
+                    while 1:
+                        self.screenshot()
+                        if self.appear_then_click(self.I_BATTLE_REWARD):
+                            self.screenshot()
+                            self.click(self.C_CLICK_ROTATE_1)
+                            time.sleep(0.5)
+                        if self.appear(self.I_EXPLORATION_TITLE):
+                            break
+                        if self.appear(self.I_E_EXPLORATION_CLICK):
+                            break
+                if self.appear(self.I_E_EXPLORATION_CLICK) or self.appear(self.I_EXPLORATION_TITLE):
+                    break
+            # 小怪 战
+            if self.appear_then_click(self.I_NORMAL_BATTLE_BUTTON):
+                self.run_general_battle(self.config.exploration.general_battle_config)
+                self.screenshot()
+                while self.appear(self.I_BATTLE_REWARD):
+                    self.screenshot()
+                    self.appear_then_click(self.I_BATTLE_REWARD)
+                    self.screenshot()
+            else:
+                self.swipe(self.S_SWIPE_BACKGROUND_RIGHT)
+
+    # 战斗流程
+    def battle_process(self):
+        # 进入指定章节
+        self.screenshot()
+        if self.appear_then_click(self.I_E_EXPLORATION_CLICK):
+            self.appear_then_click(self.I_E_SETTINGS_BUTTON)
+
+        # ************************* 进入设置并操作 *******************
+        # 候补以及自动轮换打开:
+        # 自动轮换功能打开
+        while 1:
+            self.screenshot()
+            # 自动轮换开着 则跳过
+            if self.appear(self.I_E_AUTO_ROTATE_ON):
+                break
+            # 自动轮换关着 则打开
+            if self.appear_then_click(self.I_E_AUTO_ROTATE_OFF):
+                if self.appear(self.I_E_AUTO_ROTATE_ON):
+                    break
+
+        # 自动添加候补式神
+        if self.config.exploration.exploration_config.auto_rotate == AutoRotate.yes:
+            self.enter_settings_and_do_operations()
+
+        # 进入战斗环节
+        self.do_battle()
+
+
+if __name__ == "__main__":
+    from module.config.config import Config
+    from module.device.device import Device
+
+    config = Config('oas1')
+    device = Device(config)
+    t = ScriptTask(config, device)
+    t.config.exploration.exploration_config.exploration_level = '第二十八章'
+    t.run()
+    # t.battle_process()
+    # t.enter_settings_and_do_operations()

+ 29 - 1
tasks/FallenSun/assets.py

@@ -8,5 +8,33 @@ from module.atom.list import RuleList
 # This file was automatically generated by ./dev_tools/assets_extract.py.
 # Don't modify it manually.
 class FallenSunAssets: 
-	pass
+
+
+	# Image Rule Assets
+	# 选择日轮 
+	I_FALLEN_SUN = RuleImage(roi_front=(784,113,290,396), roi_back=(784,113,290,396), threshold=0.8, method="Template matching", file="./tasks/FallenSun/f/f_fallen_sun.png")
+	# 组队 
+	I_FORM_TEAM = RuleImage(roi_front=(939,594,96,90), roi_back=(939,594,96,90), threshold=0.8, method="Template matching", file="./tasks/FallenSun/f/f_form_team.png")
+	# description 
+	I_FALLEN_SUN_FIRE = RuleImage(roi_front=(1108,592,96,93), roi_back=(1108,592,96,93), threshold=0.8, method="Template matching", file="./tasks/FallenSun/f/f_fallen_sun_fire.png")
+	# description 
+	I_FALLEN_SUN_UNLOCK = RuleImage(roi_front=(557,560,31,38), roi_back=(557,560,31,38), threshold=0.8, method="Template matching", file="./tasks/FallenSun/f/f_fallen_sun_unlock.png")
+	# description 
+	I_FALLEN_SUN_LOCK = RuleImage(roi_front=(557,561,31,37), roi_back=(557,561,31,37), threshold=0.8, method="Template matching", file="./tasks/FallenSun/f/f_fallen_sun_lock.png")
+	# description 
+	I_FALLEN_SUN_MATCHING = RuleImage(roi_front=(62,568,44,114), roi_back=(62,568,44,114), threshold=0.8, method="Template matching", file="./tasks/FallenSun/f/f_fallen_sun_matching.png")
+	# 小小宠物,发现宝藏 
+	I_PET_PRESENT = RuleImage(roi_front=(873,184,62,147), roi_back=(873,184,62,147), threshold=0.8, method="Template matching", file="./tasks/FallenSun/f/f_pet_present.png")
+
+
+	# List Rule Assets
+	# 这个是御魂界面选择不同层数的 
+	L_LAYER_LIST = RuleList(folder="./tasks/FallenSun/res", direction="vertical", mode="ocr", roi_back=(138,130,359,500), size=(40, 93), 
+					 array=["壹", "贰", "叁"])
+
+
+	# Ocr Rule Assets
+	# Ocr-description 
+	O_O_TEST_OCR = RuleOcr(roi=(126,136,360,491), area=(126,136,360,491), mode="Full", method="Default", keyword="", name="o_test_ocr")
+
 

+ 35 - 4
tasks/FallenSun/config.py

@@ -1,11 +1,42 @@
 # This Python file uses the following encoding: utf-8
-# @author runhey
-# github https://github.com/runhey
+# @author TripleEarth
+# github https://github.com/TripleEarth
 from pydantic import BaseModel, Field
+from enum import Enum
+from datetime import datetime, time
 
+from tasks.Component.SwitchSoul.switch_soul_config import SwitchSoulConfig
 from tasks.Component.config_scheduler import Scheduler
-from tasks.Component.config_base import ConfigBase
+from tasks.Component.config_base import ConfigBase, TimeDelta
+from tasks.Component.GeneralInvite.config_invite import InviteConfig
+from tasks.Component.GeneralBattle.config_general_battle import GeneralBattleConfig
+
+
+class UserStatus(str, Enum):
+    LEADER = 'leader'
+    MEMBER = 'member'
+    ALONE = 'alone'
+    WILD = 'wild'  # 还不打算实现
+
+class Layer(str, Enum):
+    ONE = '壹层'
+    TWO = '贰层'
+    THREE = '叁层'
+
+class FallenSunConfig(ConfigBase):
+    # 身份
+    user_status: UserStatus = Field(default=UserStatus.LEADER, description='user_status_help')
+    # 层数
+    layer: Layer = Field(default=Layer.THREE, description='layer_help')
+    # 限制时间
+    limit_time: time = Field(default=time(minute=30), description='limit_time_help')
+    # 限制次数
+    limit_count: int = Field(default=50, description='limit_count_help')
+
 
 class FallenSun(ConfigBase):
     scheduler: Scheduler = Field(default_factory=Scheduler)
-
+    fallen_sun_config: FallenSunConfig = Field(default_factory=FallenSunConfig)
+    invite_config: InviteConfig = Field(default_factory=InviteConfig)
+    general_battle_config: GeneralBattleConfig = Field(default_factory=GeneralBattleConfig)
+    switch_soul: SwitchSoulConfig = Field(default_factory=SwitchSoulConfig)

BIN
tasks/FallenSun/f/f_fallen_sun.png


BIN
tasks/FallenSun/f/f_fallen_sun_fire.png


BIN
tasks/FallenSun/f/f_fallen_sun_lock.png


BIN
tasks/FallenSun/f/f_fallen_sun_matching.png


BIN
tasks/FallenSun/f/f_fallen_sun_unlock.png


BIN
tasks/FallenSun/f/f_form_team.png


BIN
tasks/FallenSun/f/f_pet_present.png


+ 65 - 0
tasks/FallenSun/f/image.json

@@ -0,0 +1,65 @@
+[
+  {
+    "itemName": "fallen_sun",
+    "imageName": "f_fallen_sun.png",
+    "roiFront": "784,113,290,396",
+    "roiBack": "784,113,290,396",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "选择日轮"
+  },
+  {
+    "itemName": "form_team",
+    "imageName": "f_form_team.png",
+    "roiFront": "939,594,96,90",
+    "roiBack": "939,594,96,90",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "组队"
+  },
+  {
+    "itemName": "fallen_sun_fire",
+    "imageName": "f_fallen_sun_fire.png",
+    "roiFront": "1108,592,96,93",
+    "roiBack": "1108,592,96,93",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "fallen_sun_unlock",
+    "imageName": "f_fallen_sun_unlock.png",
+    "roiFront": "557,560,31,38",
+    "roiBack": "557,560,31,38",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "fallen_sun_lock",
+    "imageName": "f_fallen_sun_lock.png",
+    "roiFront": "557,561,31,37",
+    "roiBack": "557,561,31,37",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "fallen_sun_matching",
+    "imageName": "f_fallen_sun_matching.png",
+    "roiFront": "62,568,44,114",
+    "roiBack": "62,568,44,114",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "pet_present",
+    "imageName": "f_pet_present.png",
+    "roiFront": "873,184,62,147",
+    "roiBack": "873,184,62,147",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "小小宠物,发现宝藏"
+  }
+]

+ 21 - 0
tasks/FallenSun/res/list.json

@@ -0,0 +1,21 @@
+{
+  "name": "layer_list",
+  "direction": "vertical",
+  "type": "ocr",
+  "roiBack": "138,130,359,500",
+  "description": "这个是御魂界面选择不同层数的",
+  "list": [
+    {
+      "itemName": "壹",
+      "roiFront": "281,135,39,102"
+    },
+    {
+      "itemName": "贰",
+      "roiFront": "283,293,39,85"
+    },
+    {
+      "itemName": "叁",
+      "roiFront": "281,439,43,93"
+    }
+  ]
+}

+ 11 - 0
tasks/FallenSun/res/ocr.json

@@ -0,0 +1,11 @@
+[
+  {
+    "itemName": "o_test_ocr",
+    "roiFront": "126,136,360,491",
+    "roiBack": "126,136,360,491",
+    "mode": "Full",
+    "method": "Default",
+    "keyword": "",
+    "description": "Ocr-description"
+  }
+]

+ 345 - 0
tasks/FallenSun/script_task.py

@@ -0,0 +1,345 @@
+# 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 tasks.Component.GeneralBattle.general_battle import GeneralBattle
+from tasks.Component.GeneralInvite.general_invite import GeneralInvite
+from tasks.Component.GeneralBuff.general_buff import GeneralBuff
+from tasks.Component.GeneralRoom.general_room import GeneralRoom
+from tasks.Component.SwitchSoul.switch_soul import SwitchSoul
+from tasks.GameUi.game_ui import GameUi
+from tasks.GameUi.page import page_main, page_soul_zones, page_shikigami_records
+from tasks.FallenSun.assets import FallenSunAssets
+from tasks.FallenSun.config import FallenSun, UserStatus
+from module.logger import logger
+from module.exception import TaskEnd
+
+class ScriptTask(GeneralBattle, GeneralInvite, GeneralBuff, GeneralRoom, GameUi, SwitchSoul, FallenSunAssets):
+
+    def run(self) -> bool:
+        # 御魂切换方式一
+        if self.config.fallen_sun.switch_soul.enable:
+            self.ui_get_current_page()
+            self.ui_goto(page_shikigami_records)
+            self.run_switch_soul(self.config.fallen_sun.switch_soul.switch_group_team)
+
+        # 御魂切换方式二
+        if self.config.fallen_sun.switch_soul.enable_switch_by_name:
+            self.ui_get_current_page()
+            self.ui_goto(page_shikigami_records)
+            self.run_switch_soul_by_name(self.config.fallen_sun.switch_soul.group_name,
+                                         self.config.fallen_sun.switch_soul.team_name)
+
+        limit_count = self.config.fallen_sun.fallen_sun_config.limit_count
+        limit_time = self.config.fallen_sun.fallen_sun_config.limit_time
+        self.current_count = 0
+        self.limit_count: int = limit_count
+        self.limit_time: timedelta = timedelta(hours=limit_time.hour, minutes=limit_time.minute, seconds=limit_time.second)
+
+        self.ui_get_current_page()
+        self.ui_goto(page_main)
+        config: FallenSun = self.config.fallen_sun
+
+        success = True
+        match config.fallen_sun_config.user_status:
+            case UserStatus.LEADER: success = self.run_leader()
+            case UserStatus.MEMBER: success = self.run_member()
+            case UserStatus.ALONE: self.run_alone()
+            case UserStatus.WILD: self.run_wild()
+            case _: logger.error('Unknown user status')
+
+        # 下一次运行时间
+        if success:
+            self.set_next_run('FallenSun', finish=True, success=True)
+        else:
+            self.set_next_run('FallenSun', finish=False, success=False)
+
+        raise TaskEnd
+
+
+
+    def fallen_sun_enter(self) -> bool:
+        logger.info('Enter fallen_sun')
+        while True:
+            self.screenshot()
+            if self.appear(self.I_FORM_TEAM):
+                return True
+            if self.appear_then_click(self.I_FALLEN_SUN, interval=1):
+                continue
+
+    def check_layer(self, layer: str) -> bool:
+        """
+        检查挑战的层数, 并选中挑战的层
+        :return:
+        """
+        pos = self.list_find(self.L_LAYER_LIST, layer)
+        if pos:
+            self.device.click(x=pos[0], y=pos[1])
+            return True
+
+    def check_lock(self, lock: bool = True) -> bool:
+        """
+        检查是否锁定阵容, 要求在八岐大蛇界面
+        :param lock:
+        :return:
+        """
+        logger.info('Check lock: %s', lock)
+        if lock:
+            while 1:
+                self.screenshot()
+                if self.appear(self.I_FALLEN_SUN_LOCK):
+                    return True
+                if self.appear_then_click(self.I_FALLEN_SUN_UNLOCK, interval=1):
+                    continue
+        else:
+            while 1:
+                self.screenshot()
+                if self.appear(self.I_FALLEN_SUN_UNLOCK):
+                    return True
+                if self.appear_then_click(self.I_FALLEN_SUN_LOCK, interval=1):
+                    continue
+
+
+    def run_leader(self):
+        logger.info('Start run leader')
+        self.ui_get_current_page()
+        self.ui_goto(page_soul_zones)
+        self.fallen_sun_enter()
+        layer = self.config.fallen_sun.fallen_sun_config.layer
+        self.check_layer(layer)
+        self.check_lock(self.config.fallen_sun.general_battle_config.lock_team_enable)
+        # 创建队伍
+        logger.info('Create team')
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_FALLEN_SUN_MATCHING):
+                break
+            if self.appear_then_click(self.I_FORM_TEAM, interval=1):
+                continue
+        # 创建房间
+        self.create_room()
+        self.ensure_private()
+        self.create_ensure()
+
+        # 邀请队友
+        success = True
+        is_first = True
+        # 这个时候我已经进入房间了哦
+        while 1:
+            self.screenshot()
+            # 无论胜利与否, 都会出现是否邀请一次队友
+            # 区别在于,失败的话不会出现那个勾选默认邀请的框
+            if self.check_and_invite(self.config.fallen_sun.invite_config.default_invite):
+                continue
+
+            # 检查猫咪奖励
+            if self.appear_then_click(self.I_PET_PRESENT, action=self.C_WIN_3, interval=1):
+                continue
+
+            if self.current_count >= self.limit_count:
+                if self.is_in_room():
+                    logger.info('FallenSun count limit out')
+                    break
+
+            if datetime.now() - self.start_time >= self.limit_time:
+                if self.is_in_room():
+                    logger.info('FallenSun time limit out')
+                    break
+
+
+
+            # 如果没有进入房间那就不需要后面的邀请
+            if not self.is_in_room():
+                # 如果在探索界面或者是出现在组队界面, 那就是可能房间死了
+                # 要结束任务
+                sleep(0.5)
+                if self.appear(self.I_MATCHING) or self.appear(self.I_CHECK_EXPLORATION):
+                    sleep(0.5)
+                    if self.appear(self.I_MATCHING) or self.appear(self.I_CHECK_EXPLORATION):
+                        logger.warning('FallenSun task failed')
+                        success = False
+                        break
+                continue
+
+            # 点击挑战
+            if not is_first:
+                if self.run_invite(config=self.config.fallen_sun.invite_config):
+                    self.run_general_battle(config=self.config.fallen_sun.general_battle_config)
+                else:
+                    # 邀请失败,退出任务
+                    logger.warning('Invite failed and exit this fallen_sun task')
+                    success = False
+                    break
+
+            # 第一次会邀请队友
+            if is_first:
+                if not self.run_invite(config=self.config.fallen_sun.invite_config, is_first=True):
+                    logger.warning('Invite failed and exit this fallen_sun task')
+                    success = False
+                    break
+                else:
+                    is_first = False
+                    self.run_general_battle(config=self.config.fallen_sun.general_battle_config)
+
+        # 当结束或者是失败退出循环的时候只有两个UI的可能,在房间或者是在组队界面
+        # 如果在房间就退出
+        if self.exit_room():
+            pass
+        # 如果在组队界面就退出
+        if self.exit_team():
+            pass
+
+        self.ui_get_current_page()
+        self.ui_goto(page_main)
+
+        if not success:
+            return False
+        return True
+
+    def run_member(self):
+        logger.info('Start run member')
+        self.ui_get_current_page()
+        # self.ui_goto(page_soul_zones)
+        # self.fallen_sun_enter()
+        # self.check_lock(self.config.fallen_sun.general_battle_config.lock_team_enable)
+
+        # 进入战斗流程
+        self.device.stuck_record_add('BATTLE_STATUS_S')
+        while 1:
+            self.screenshot()
+
+            # 检查猫咪奖励
+            if self.appear_then_click(self.I_PET_PRESENT, action=self.C_WIN_3, interval=1):
+                continue
+
+            if self.current_count >= self.limit_count:
+                logger.info('FallenSun count limit out')
+                break
+            if datetime.now() - self.start_time >= self.limit_time:
+                logger.info('FallenSun time limit out')
+                break
+
+            if self.check_then_accept():
+                continue
+
+            if self.is_in_room():
+                self.device.stuck_record_clear()
+                if self.wait_battle(wait_time=self.config.fallen_sun.invite_config.wait_time):
+                    self.run_general_battle(config=self.config.fallen_sun.general_battle_config)
+                else:
+                    break
+            # 队长秒开的时候,检测是否进入到战斗中
+            elif self.check_take_over_battle(False, config=self.config.fallen_sun.general_battle_config):
+                continue
+
+        while 1:
+            # 有一种情况是本来要退出的,但是队长邀请了进入的战斗的加载界面
+            if self.appear(self.I_GI_HOME) or self.appear(self.I_GI_EXPLORE):
+                break
+            # 如果可能在房间就退出
+            if self.exit_room():
+                pass
+            # 如果还在战斗中,就退出战斗
+            if self.exit_battle():
+                pass
+
+
+        self.ui_get_current_page()
+        self.ui_goto(page_main)
+        return True
+
+    def run_alone(self):
+        logger.info('Start run alone')
+        self.ui_get_current_page()
+        self.ui_goto(page_soul_zones)
+        self.fallen_sun_enter()
+        layer = self.config.fallen_sun.fallen_sun_config.layer
+        self.check_layer(layer)
+        self.check_lock(self.config.fallen_sun.general_battle_config.lock_team_enable)
+
+        def is_in_fallen_sun(screenshot=False) -> bool:
+            if screenshot:
+                self.screenshot()
+            return self.appear(self.I_FALLEN_SUN_FIRE)
+
+        while 1:
+            self.screenshot()
+
+            # 检查猫咪奖励
+            if self.appear_then_click(self.I_PET_PRESENT, action=self.C_WIN_3, interval=1):
+                continue
+
+            if not is_in_fallen_sun():
+                continue
+
+            if self.current_count >= self.limit_count:
+                logger.info('FallenSun count limit out')
+                break
+            if datetime.now() - self.start_time >= self.limit_time:
+                logger.info('FallenSun time limit out')
+                break
+
+            # 点击挑战
+            while 1:
+                self.screenshot()
+                if self.appear_then_click(self.I_FALLEN_SUN_FIRE, interval=1):
+                    pass
+
+                if not self.appear(self.I_FALLEN_SUN_FIRE):
+                    self.run_general_battle(config=self.config.fallen_sun.general_battle_config)
+                    break
+
+        # 回去
+        while 1:
+            self.screenshot()
+            if not self.appear(self.I_FORM_TEAM):
+                break
+            if self.appear_then_click(self.I_BACK_BL, interval=1):
+                continue
+
+        self.ui_current = page_soul_zones
+        self.ui_goto(page_main)
+
+
+
+    def run_wild(self):
+        logger.error('Wild mode is not implemented')
+        pass
+
+
+
+
+
+
+if __name__ == '__main__':
+    from module.config.config import Config
+    from module.device.device import Device
+    from memory_profiler import profile
+    c = Config('oas1')
+    d = Device(c)
+    t = ScriptTask(c, d)
+
+    # t.run()
+
+    # t.check_layer('悲')
+
+    from module.base.timer import timer
+
+    @timer
+    @profile
+    def test_memory():
+        t.screenshot()
+        print(t.ocr_appear(t.O_O_TEST_OCR))
+        print(t.L_LAYER_LIST.image_appear(t.device.image, '叁'))
+    for i in range(4):
+        test_memory()
+        print('=====================')
+
+
+
+
+
+
+

BIN
tasks/GameUi/additional/additional_ad_disappear.png


BIN
tasks/GameUi/additional/additional_records_close.png


+ 2 - 2
tasks/GameUi/additional/records.json

@@ -5,7 +5,7 @@
     "roiFront": "412,405,37,40",
     "roiBack": "412,405,37,40",
     "method": "Template matching",
-    "threshold": 0.9,
+    "threshold": 0.75,
     "description": "description"
   },
   {
@@ -14,7 +14,7 @@
     "roiFront": "914,143,30,30",
     "roiBack": "914,143,30,30",
     "method": "Template matching",
-    "threshold": 0.8,
+    "threshold": 0.7,
     "description": "description"
   }
 ]

+ 2 - 2
tasks/GameUi/assets.py

@@ -24,9 +24,9 @@ class GameUiAssets:
 
 	# Image Rule Assets
 	# description 
-	I_AD_DISAPPEAR = RuleImage(roi_front=(412,405,37,40), roi_back=(412,405,37,40), threshold=0.9, method="Template matching", file="./tasks/GameUi/additional/additional_ad_disappear.png")
+	I_AD_DISAPPEAR = RuleImage(roi_front=(412,405,37,40), roi_back=(412,405,37,40), threshold=0.75, method="Template matching", file="./tasks/GameUi/additional/additional_ad_disappear.png")
 	# description 
-	I_RECORDS_CLOSE = RuleImage(roi_front=(914,143,30,30), roi_back=(914,143,30,30), threshold=0.8, method="Template matching", file="./tasks/GameUi/additional/additional_records_close.png")
+	I_RECORDS_CLOSE = RuleImage(roi_front=(914,143,30,30), roi_back=(914,143,30,30), threshold=0.7, method="Template matching", file="./tasks/GameUi/additional/additional_records_close.png")
 
 
 	# Image Rule Assets

+ 19 - 14
tasks/GameUi/game_ui.py

@@ -195,6 +195,16 @@ class GameUi(BaseTask, GameUiAssets):
             else:
                 self.screenshot()
 
+            # Destination additional button
+            if destination.additional and isinstance(destination.additional, list):
+                appear = False
+                for button in destination.additional:
+                    if self.appear_then_click(button, interval=0.6):
+                        appear = True
+                        logger.info(f'Page {destination} AB {button} clicked')
+                if appear:
+                    continue
+
             # Destination page
             if self.appear(destination.check_button):
                 if confirm_timer.reached():
@@ -209,16 +219,15 @@ class GameUi(BaseTask, GameUiAssets):
                 if page.parent is None or page.check_button is None:
                     continue
                 # 如果当前页面不出现可以检测当前按键的按钮,那可能是有一些弹窗,广告,这个时候额外处理
-                if page.additional:
-                    if not isinstance(page.additional, list):
-                        page.additional = [page.additional]
-                    for button in page.additional:
-                        if isinstance(button, RuleImage) and self.appear_then_click(button, interval=1):
-                            sleep(0.4)
-                            logger.info(f'Page {page} AB {button} clicked')
-                        if isinstance(button, RuleOcr) and self.ocr_appear_click(button, interval=1):
-                            sleep(0.4)
-                            logger.info(f'Page {page} AB {button} clicked')
+                # if page.additional:
+                #     if not isinstance(page.additional, list):
+                #         page.additional = [page.additional]
+                #     for button in page.additional:
+                #         logger.info(f'Page {page} AB {button} checking')
+                #         if self.appear_then_click(button, interval=1):
+                #             sleep(0.2)
+                #             logger.info(f'Page {page} AB {button} clicked')
+
 
                 # 获取当前页面的要点击的按钮
                 if self.appear(page.check_button, interval=4):
@@ -233,10 +242,6 @@ class GameUi(BaseTask, GameUiAssets):
             if clicked:
                 continue
 
-            # # Additional
-            # if self.ui_additional():
-            #     continue
-
         # Reset connection
         for page in self.ui_pages:
             page.parent = None

+ 17 - 0
tasks/GlobalGame/config.py

@@ -1,11 +1,28 @@
 # This Python file uses the following encoding: utf-8
 # @author runhey
 # github https://github.com/runhey
+from enum import Enum
 from pydantic import BaseModel, Field
 
 from tasks.GlobalGame.config_emergency import Emergency
 from tasks.Component.config_base import ConfigBase
 
+class Transport(str, Enum):
+    TCP = 'TCP'
+    SSL_TLS = 'SSL/TLS'
+
+
+class TeamFlow(BaseModel):
+    enable: bool = Field(default=False, description='enable_help')
+    broker: str = Field(default='', description='broker_help')
+    port: int = Field(default=8883, description='port_help')
+    transport: Transport = Field(default=Transport.TCP, description='transport_help')
+    ca: str = Field(default='', description='ca_help')
+    username: str = Field(default='', description='username_help')
+    password: str = Field(default='', description='password_help')
+
+
 class GlobalGame(BaseModel):
     emergency: Emergency = Field(default_factory=Emergency)
+    team_flow: TeamFlow = Field(default_factory=TeamFlow)
 

+ 4 - 0
tasks/Restart/assets.py

@@ -35,6 +35,10 @@ class RestartAssets:
 	I_HARVEST_AP = RuleImage(roi_front=(721,486,31,38), roi_back=(206,462,999,81), threshold=0.8, method="Template matching", file="./tasks/Restart/harvest/harvest_harvest_ap.png")
 	# 打开聊天频道会自动关闭 
 	I_HARVEST_CHAT_CLOSE = RuleImage(roi_front=(639,309,35,100), roi_back=(639,309,35,100), threshold=0.8, method="Template matching", file="./tasks/Restart/harvest/harvest_harvest_chat_close.png")
+	# 签到 
+	I_HARVEST_SIGN_3 = RuleImage(roi_front=(291,495,33,36), roi_back=(100,473,1014,70), threshold=0.8, method="Template matching", file="./tasks/Restart/harvest/harvest_harvest_sign_3.png")
+	# description 
+	I_HARVEST_SIGN_4 = RuleImage(roi_front=(587,151,100,228), roi_back=(547,123,185,281), threshold=0.8, method="Template matching", file="./tasks/Restart/harvest/harvest_harvest_sign_4.png")
 
 
 	# Image Rule Assets

BIN
tasks/Restart/harvest/harvest_harvest_sign_3.png


BIN
tasks/Restart/harvest/harvest_harvest_sign_4.png


+ 18 - 0
tasks/Restart/harvest/image.json

@@ -106,5 +106,23 @@
     "method": "Template matching",
     "threshold": 0.8,
     "description": "打开聊天频道会自动关闭"
+  },
+  {
+    "itemName": "harvest_sign_3",
+    "imageName": "harvest_harvest_sign_3.png",
+    "roiFront": "291,495,33,36",
+    "roiBack": "100,473,1014,70",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "签到"
+  },
+  {
+    "itemName": "harvest_sign_4",
+    "imageName": "harvest_harvest_sign_4.png",
+    "roiFront": "587,151,100,228",
+    "roiBack": "547,123,185,281",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
   }
 ]

+ 7 - 1
tasks/Restart/login.py

@@ -138,6 +138,12 @@ class LoginHandler(BaseTask, RestartAssets):
             if self.appear_then_click(self.I_HARVEST_SIGN, interval=1):
                 timer_harvest.reset()
                 continue
+            # 某些活动的特殊签到,有空看到就删掉
+            if self.appear_then_click(self.I_HARVEST_SIGN_3, interval=0.7):
+                continue
+            if self.appear_then_click(self.I_HARVEST_SIGN_4, interval=1):
+                timer_harvest.reset()
+                continue
             if self.appear_then_click(self.I_HARVEST_SIGN_2, interval=1):
                 timer_harvest.reset()
                 continue
@@ -170,7 +176,7 @@ class LoginHandler(BaseTask, RestartAssets):
                         timer_harvest.reset()
                         continue
             # 体力
-            if self.appear_then_click(self.I_HARVEST_AP, interval=1):
+            if self.appear_then_click(self.I_HARVEST_AP, interval=1, threshold=0.7):
                 timer_harvest.reset()
                 continue
             # 御魂觉醒加成

+ 4 - 2
tasks/RyouToppa/assets.py

@@ -21,15 +21,17 @@ class RyouToppaAssets:
 	# 寮突选择阴阳寮按钮 
 	I_SELECT_RYOU_BUTTON = RuleImage(roi_front=(560,577,156,46), roi_back=(560,577,156,46), threshold=0.8, method="Template matching", file="./tasks/RyouToppa/res/res_select_ryou_button.png")
 	# 开始寮突按钮 
-	I_START_TOPPA_BUTTON = RuleImage(roi_front=(834,504,127,38), roi_back=(4,3,1056,716), threshold=0.8, method="Template matching", file="./tasks/RyouToppa/res/res_start_toppa_button.png")
+	I_START_TOPPA_BUTTON = RuleImage(roi_front=(832,279,130,43), roi_back=(1,1,1055,718), threshold=0.8, method="Template matching", file="./tasks/RyouToppa/res/res_start_toppa_button.png")
 	# 寮击破奖励 
 	I_RYOU_REWARD = RuleImage(roi_front=(134,417,241,40), roi_back=(134,417,241,40), threshold=0.8, method="Template matching", file="./tasks/RyouToppa/res/res_ryou_reward.png")
 	# 勋章奖励标题 
 	I_GUILD_ORDERS_REWARDS = RuleImage(roi_front=(1123,31,115,56), roi_back=(1123,31,115,56), threshold=0.8, method="Template matching", file="./tasks/RyouToppa/res/res_guild_orders_rewards.png")
 	# 攻破阴阳寮 
-	I_SUCCESS_PENETRATION = RuleImage(roi_front=(206,149,100,100), roi_back=(206,149,100,100), threshold=0.8, method="Template matching", file="./tasks/RyouToppa/res/res_success_penetration.png")
+	I_SUCCESS_PENETRATION = RuleImage(roi_front=(141,374,234,37), roi_back=(141,374,234,37), threshold=0.8, method="Template matching", file="./tasks/RyouToppa/res/res_success_penetration.png")
 	# 个人突破刷新按钮 
 	I_REAL_RAID_REFRESH = RuleImage(roi_front=(963,569,174,60), roi_back=(963,569,174,60), threshold=0.8, method="Template matching", file="./tasks/RyouToppa/res/res_real_raid_refresh.png")
+	# 击破后的寮奖励 
+	I_RYOU_REWARD_90 = RuleImage(roi_front=(134,415,232,38), roi_back=(134,415,232,38), threshold=0.8, method="Template matching", file="./tasks/RyouToppa/res/res_ryou_reward_90.png")
 
 
 	# Ocr Rule Assets

+ 13 - 4
tasks/RyouToppa/res/image.json

@@ -20,8 +20,8 @@
   {
     "itemName": "start_toppa_button",
     "imageName": "res_start_toppa_button.png",
-    "roiFront": "834,504,127,38",
-    "roiBack": "4,3,1056,716",
+    "roiFront": "832,279,130,43",
+    "roiBack": "1,1,1055,718",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "开始寮突按钮"
@@ -47,8 +47,8 @@
   {
     "itemName": "success_penetration",
     "imageName": "res_success_penetration.png",
-    "roiFront": "206,149,100,100",
-    "roiBack": "206,149,100,100",
+    "roiFront": "141,374,234,37",
+    "roiBack": "141,374,234,37",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "攻破阴阳寮"
@@ -61,5 +61,14 @@
     "method": "Template matching",
     "threshold": 0.8,
     "description": "个人突破刷新按钮"
+  },
+  {
+    "itemName": "ryou_reward_90",
+    "imageName": "res_ryou_reward_90.png",
+    "roiFront": "134,415,232,38",
+    "roiBack": "134,415,232,38",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "击破后的寮奖励"
   }
 ]

BIN
tasks/RyouToppa/res/res_ryou_reward_90.png


BIN
tasks/RyouToppa/res/res_start_toppa_button.png


BIN
tasks/RyouToppa/res/res_success_penetration.png


+ 13 - 27
tasks/RyouToppa/script_task.py

@@ -25,19 +25,19 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, RyouToppaAssets):
         执行
         :return:
         """
-        config = self.config.ryou_toppa
+        ryou_config = self.config.ryou_toppa
         self.medal_grid = ImageGrid([RealmRaidAssets.I_MEDAL_5, RealmRaidAssets.I_MEDAL_4, RealmRaidAssets.I_MEDAL_3,
                                      RealmRaidAssets.I_MEDAL_2, RealmRaidAssets.I_MEDAL_1, RealmRaidAssets.I_MEDAL_0])
 
-        if config.switch_soul_config.enable:
+        if ryou_config.switch_soul_config.enable:
             self.ui_get_current_page()
             self.ui_goto(page_shikigami_records)
-            self.run_switch_soul(config.switch_soul_config.switch_group_team)
+            self.run_switch_soul(ryou_config.switch_soul_config.switch_group_team)
 
-        if config.switch_soul_config.enable_switch_by_name:
+        if ryou_config.switch_soul_config.enable_switch_by_name:
             self.ui_get_current_page()
             self.ui_goto(page_shikigami_records)
-            self.run_switch_soul_by_name(config.switch_soul_config.group_name, config.switch_soul_config.team_name)
+            self.run_switch_soul_by_name(ryou_config.switch_soul_config.group_name, ryou_config.switch_soul_config.team_name)
 
         self.ui_get_current_page()
         self.ui_goto(page_kekkai_toppa)
@@ -61,20 +61,18 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, RyouToppaAssets):
                 ryou_toppa_start_flag = False
                 break
             # 出现寮奖励, 说明寮突已开
-            elif self.appear(self.I_RYOU_REWARD, threshold=0.8):
+            elif self.appear(self.I_RYOU_REWARD, threshold=0.8) or self.appear(self.I_RYOU_REWARD_90, threshold=0.8):
                 ryou_toppa_start_flag = True
                 break
 
         # 寮突未开 并且有权限, 开开寮突
-        if not ryou_toppa_start_flag and config.raid_config.ryou_access == 'yes':
+        if not ryou_toppa_start_flag and ryou_config.raid_config.ryou_access == 'yes':
             # 开寮突
             self.start_ryou_toppa()
 
-        # 切换阵容 待实现
-
         # 开始突破
         while 1:
-            if self.execute_round(config):
+            if self.execute_round():
                 continue
             else:
                 break
@@ -129,7 +127,7 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, RyouToppaAssets):
             return False
         return True
 
-    def medal_fire(self) -> bool:
+    def medal_fire(self):
         """
         点击勋章
         :return:
@@ -170,30 +168,18 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, RyouToppaAssets):
                 break
         logger.info(f'Click {RealmRaidAssets.I_FIRE.name}')
 
-    def execute_round(self, config: RaidMode) -> bool:
+    def execute_round(self) -> bool:
         """
         执行一轮 除非票不够,一直到到九次
         :return:
         """
+        ryou_config = self.config.ryou_toppa
         # 如果没有票了,就退出
         if not self.is_ticket():
             return False
         if not self.is_target_available():
             return False
-        # # 判断是退四打九还是全部打
-        # if config.raid_config.raid_mode == RaidMode.NORMAL:
-        #     logger.info(f'Execute round, retreat four attack nine')
-        #     self.medal_fire()
-        #     self.run_general_battle_back(config.general_battle_config)
-        #
-        #     self.medal_fire()
-        #     self.run_general_battle_back(config.general_battle_config)
-        #
-        #     self.medal_fire()
-        #     self.run_general_battle_back(config.general_battle_config)
-        #
-        #     self.medal_fire()
-        #     self.run_general_battle_back(config.general_battle_config)
+
 
         # 打20次
         for i in range(30):
@@ -202,7 +188,7 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, RyouToppaAssets):
             if not self.is_target_available():
                 return False
             self.medal_fire()
-            self.run_general_battle(config.general_battle_config)
+            self.run_general_battle(ryou_config.general_battle_config)
             self.wait_until_appear(RealmRaidAssets.I_BACK_RED)
 
         return True