Ver Fonte

update ryotoppa

endlesswxk há 3 anos atrás
pai
commit
4f2ee77fd0

+ 1 - 1
tasks/RyouToppa/assets.py

@@ -21,7 +21,7 @@ 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=(812,497,171,55), roi_back=(812,497,171,55), threshold=0.8, method="Template matching", file="./tasks/RyouToppa/res/res_start_toppa_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_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")
 	# 勋章奖励标题 

+ 2 - 0
tasks/RyouToppa/config.py

@@ -1,6 +1,7 @@
 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
 
@@ -31,3 +32,4 @@ class RyouToppa(ConfigBase):
     scheduler: Scheduler = Field(default_factory=Scheduler)
     raid_config: RaidConfig = Field(default_factory=RaidConfig)
     general_battle_config: GeneralBattleConfig = Field(default_factory=GeneralBattleConfig)
+    switch_soul_config: SwitchSoulConfig = Field(default_factory=SwitchSoulConfig)

+ 2 - 2
tasks/RyouToppa/res/image.json

@@ -20,8 +20,8 @@
   {
     "itemName": "start_toppa_button",
     "imageName": "res_start_toppa_button.png",
-    "roiFront": "812,497,171,55",
-    "roiBack": "812,497,171,55",
+    "roiFront": "834,504,127,38",
+    "roiBack": "4,3,1056,716",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "开始寮突按钮"

BIN
tasks/RyouToppa/res/res_start_toppa_button.png


+ 22 - 13
tasks/RyouToppa/script_task.py

@@ -3,10 +3,11 @@
 # github https://github.com/runhey
 import time
 
+from tasks.Component.SwitchSoul.switch_soul import SwitchSoul
 from tasks.RyouToppa.assets import RyouToppaAssets
 from tasks.Component.GeneralBattle.general_battle import GeneralBattle
 from tasks.GameUi.game_ui import GameUi
-from tasks.GameUi.page import page_realm_raid, page_main, page_kekkai_toppa
+from tasks.GameUi.page import page_realm_raid, page_main, page_kekkai_toppa, page_shikigami_records
 from tasks.RealmRaid.assets import RealmRaidAssets
 from module.logger import logger
 from module.exception import TaskEnd
@@ -15,7 +16,8 @@ from module.base.timer import Timer
 from module.exception import GamePageUnknownError
 from tasks.RyouToppa.config import RaidMode, AttackNumber, HaveManageAccess, RaidConfig, RyouToppa
 
-class ScriptTask(GeneralBattle, GameUi, RyouToppaAssets):
+
+class ScriptTask(GeneralBattle, GameUi, SwitchSoul, RyouToppaAssets):
     medal_grid: ImageGrid = None
 
     def run(self):
@@ -26,6 +28,12 @@ class ScriptTask(GeneralBattle, GameUi, RyouToppaAssets):
         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:
+            self.ui_get_current_page()
+            self.ui_goto(page_shikigami_records)
+            self.run_switch_soul(config.switch_soul_config.switch_group_team)
+
         self.ui_get_current_page()
         self.ui_goto(page_kekkai_toppa)
         ryou_toppa_start_flag = True
@@ -66,12 +74,11 @@ class ScriptTask(GeneralBattle, GameUi, RyouToppaAssets):
             else:
                 break
 
-
         # 回 page_main 失败
         # self.ui_current = page_ryou_toppa
         # self.ui_goto(page_main)
 
-        self.set_next_run(task='RyouToppa', success=True)
+        self.set_next_run(task='RyouToppa', finish=True, success=True)
         raise TaskEnd
 
     def start_ryou_toppa(self):
@@ -83,20 +90,13 @@ class ScriptTask(GeneralBattle, GameUi, RyouToppaAssets):
         while 1:
             self.screenshot()
             if self.appear_then_click(self.I_SELECT_RYOU_BUTTON, interval=1):
-                continue
-            # 出现勋章奖励标题,说明已进入,则退出
-            if self.appear(self.I_GUILD_ORDERS_REWARDS, threshold=0.8):
                 break
         logger.info(f'Click {self.I_SELECT_RYOU_BUTTON.name}')
 
         # 选择第一个寮
         while 1:
             self.screenshot()
-            if self.appear(self.I_RYOU_TOPPA, interval=1):
-                self.click(self.C_SELECT_FIRST_RYOU)
-                continue
-            # 出现突入开始,则退出
-            if self.appear(self.I_START_TOPPA_BUTTON, threshold=0.8):
+            if self.appear_then_click(self.I_GUILD_ORDERS_REWARDS, action=self.C_SELECT_FIRST_RYOU, interval=1):
                 break
         logger.info(f'Click {self.C_SELECT_FIRST_RYOU.name}')
 
@@ -119,7 +119,7 @@ class ScriptTask(GeneralBattle, GameUi, RyouToppaAssets):
         self.screenshot()
         cu, res, total = self.O_NUMBER.ocr(self.device.image)
         logger.info(f"cu = {cu}, res = {res}, total = {total}")
-        if cu == 0 and cu+res == total:
+        if cu == 0 and cu + res == total:
             logger.warning(f'Execute round failed, no chance to attack')
             return False
         return True
@@ -220,3 +220,12 @@ class ScriptTask(GeneralBattle, GameUi, RyouToppaAssets):
         else:
             raise GamePageUnknownError
 
+
+if __name__ == "__main__":
+    from module.config.config import Config
+    from module.device.device import Device
+
+    config = Config('oas1')
+    device = Device(config)
+    t = ScriptTask(config, device)
+    t.run()