Przeglądaj źródła

feat[exploration]:add 增加捡宝箱,绘卷模式

ljxun 2 lat temu
rodzic
commit
bc72157f27

+ 2 - 1
module/config/config.py

@@ -346,7 +346,8 @@ class Config(ConfigState, ConfigManual, ConfigWatcher, ConfigMenu):
 
 
         # 强制设定下一次的运行时间
         # 强制设定下一次的运行时间
         if server and hasattr(scheduler, 'server_update') and scheduler.server_update != time(hour=9):
         if server and hasattr(scheduler, 'server_update') and scheduler.server_update != time(hour=9):
-            next_run = parse_tomorrow_server(scheduler.server_update)
+            if target is None:
+                next_run = parse_tomorrow_server(scheduler.server_update)
 
 
 
 
         # 保证线程安全的
         # 保证线程安全的

+ 6 - 0
tasks/Exploration/assets.py

@@ -68,6 +68,8 @@ class ExplorationAssets:
 	I_RED_CLOSE = RuleImage(roi_front=(1027,129,41,42), roi_back=(1021,121,54,55), threshold=0.6, method="Template matching", file="./tasks/Exploration/res/res_red_close.png")
 	I_RED_CLOSE = RuleImage(roi_front=(1027,129,41,42), roi_back=(1021,121,54,55), threshold=0.6, method="Template matching", file="./tasks/Exploration/res/res_red_close.png")
 	# description 
 	# description 
 	I_E_EXIT_CONFIRM = RuleImage(roi_front=(694,380,163,49), roi_back=(694,380,163,49), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_e_exit_confirm.png")
 	I_E_EXIT_CONFIRM = RuleImage(roi_front=(694,380,163,49), roi_back=(694,380,163,49), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_e_exit_confirm.png")
+	# 宝箱 
+	I_TREASURE_BOX_CLICK = RuleImage(roi_front=(33,476,70,49), roi_back=(2,130,135,406), threshold=0.7, method="Template matching", file="./tasks/Exploration/res/res_treasure_box_click.png")
 
 
 
 
 	# Ocr Rule Assets
 	# Ocr Rule Assets
@@ -75,6 +77,10 @@ class ExplorationAssets:
 	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_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")
 	O_E_ALTERNATE_NUMBER = RuleOcr(roi=(1092,122,69,32), area=(1092,122,69,32), mode="DigitCounter", method="Default", keyword="", name="e_alternate_number")
+	# 探索右上角 突破卷的数量 
+	O_REALM_RAID_NUMBER = RuleOcr(roi=(739,11,78,37), area=(739,11,78,37), mode="DigitCounter", method="Default", keyword="", name="realm_raid_number")
+	# (点出困难28时候)探索右上角 突破卷的数量 
+	O_REALM_RAID_NUMBER1 = RuleOcr(roi=(936,10,82,36), area=(936,10,82,36), mode="DigitCounter", method="Default", keyword="", name="realm_raid_number1")
 
 
 
 
 	# Swipe Rule Assets
 	# Swipe Rule Assets

+ 12 - 3
tasks/Exploration/config.py

@@ -60,16 +60,24 @@ class ChooseRarity(str, Enum):
     S = '素材'
     S = '素材'
 
 
 
 
+class Scrolls(BaseModel):
+    # 绘卷模式
+    scrolls_on: bool = Field(title='绘卷模式', default=False, description='绘卷模式(探索->突破)循环')
+    scrolls_cd: int = Field(title='探索间隔时间', default='5',
+                                     description='探索间隔时间(从检测到突破票超量算起)探索->突破(绘卷模式)')
+    scrolls_number: int = Field(title='突破票数量', default='25', description='设置突破票数量,超过去打突破')
+
+
 class ExplorationConfig(BaseModel):
 class ExplorationConfig(BaseModel):
     buff_gold_50_click: bool = Field(default=False)
     buff_gold_50_click: bool = Field(default=False)
     buff_gold_100_click: bool = Field(default=False)
     buff_gold_100_click: bool = Field(default=False)
     buff_exp_50_click: bool = Field(default=False)
     buff_exp_50_click: bool = Field(default=False)
     buff_exp_100_click: bool = Field(default=False)
     buff_exp_100_click: bool = Field(default=False)
 
 
-    attack_number: AttackNumber = Field(title='探索次数', default=AttackNumber.SEVEN,
-                                        description='默认探索7次')
+    # attack_number: AttackNumber = Field(title='探索次数', default=AttackNumber.SEVEN,
+    #                                     description='默认探索7次')
 
 
-    current_exploration_times: str = Field(default='0', description='探索次数')
+    current_exploration_count: int = Field(title='探索次数', default='7', description='默认探索7次')
 
 
     exploration_level: ExplorationLevel = Field(title='探索等级', default=ExplorationLevel.EXPLORATION_28,
     exploration_level: ExplorationLevel = Field(title='探索等级', default=ExplorationLevel.EXPLORATION_28,
                                                 description='探索等级 默认二十八')
                                                 description='探索等级 默认二十八')
@@ -86,6 +94,7 @@ class ExplorationConfig(BaseModel):
 class Exploration(ConfigBase):
 class Exploration(ConfigBase):
     scheduler: Scheduler = Field(default_factory=Scheduler)
     scheduler: Scheduler = Field(default_factory=Scheduler)
     exploration_config: ExplorationConfig = Field(default_factory=ExplorationConfig)
     exploration_config: ExplorationConfig = Field(default_factory=ExplorationConfig)
+    scrolls: Scrolls = Field(default_factory=Scrolls)
     general_battle_config: GeneralBattleConfig = Field(default_factory=GeneralBattleConfig)
     general_battle_config: GeneralBattleConfig = Field(default_factory=GeneralBattleConfig)
     switch_soul_config: SwitchSoulConfig = Field(default_factory=SwitchSoulConfig)
     switch_soul_config: SwitchSoulConfig = Field(default_factory=SwitchSoulConfig)
     # auto_rotate_after_times: str = Field(default='30', description='探索30次后, 检测是否需要添加候补式神')
     # auto_rotate_after_times: str = Field(default='30', description='探索30次后, 检测是否需要添加候补式神')

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

@@ -169,5 +169,14 @@
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "description"
     "description": "description"
+  },
+  {
+    "itemName": "treasure_box_click",
+    "imageName": "res_treasure_box_click.png",
+    "roiFront": "33,476,70,49",
+    "roiBack": "2,130,135,406",
+    "method": "Template matching",
+    "threshold": 0.7,
+    "description": "宝箱"
   }
   }
 ]
 ]

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

@@ -16,5 +16,23 @@
     "method": "Default",
     "method": "Default",
     "keyword": "",
     "keyword": "",
     "description": "候补出战的数量"
     "description": "候补出战的数量"
+  },
+  {
+    "itemName": "realm_raid_number",
+    "roiFront": "739,11,78,37",
+    "roiBack": "739,11,78,37",
+    "mode": "DigitCounter",
+    "method": "Default",
+    "keyword": "",
+    "description": "探索右上角 突破卷的数量"
+  },
+  {
+    "itemName": "realm_raid_number1",
+    "roiFront": "936,10,82,36",
+    "roiBack": "936,10,82,36",
+    "mode": "DigitCounter",
+    "method": "Default",
+    "keyword": "",
+    "description": "(点出困难28时候)探索右上角 突破卷的数量"
   }
   }
 ]
 ]

BIN
tasks/Exploration/res/res_treasure_box_click.png


+ 39 - 4
tasks/Exploration/script_task.py

@@ -2,6 +2,7 @@
 # @author runhey
 # @author runhey
 # github https://github.com/runhey
 # github https://github.com/runhey
 import time
 import time
+from datetime import timedelta, datetime
 
 
 from tasks.Component.SwitchSoul.switch_soul import SwitchSoul
 from tasks.Component.SwitchSoul.switch_soul import SwitchSoul
 from tasks.Exploration.assets import ExplorationAssets
 from tasks.Exploration.assets import ExplorationAssets
@@ -9,6 +10,7 @@ from tasks.Exploration.config import ChooseRarity, AutoRotate, AttackNumber
 from tasks.Component.GeneralBattle.general_battle import GeneralBattle
 from tasks.Component.GeneralBattle.general_battle import GeneralBattle
 from tasks.GameUi.game_ui import GameUi
 from tasks.GameUi.game_ui import GameUi
 from tasks.GameUi.page import page_exploration, page_shikigami_records, page_main
 from tasks.GameUi.page import page_exploration, page_shikigami_records, page_main
+from tasks.RealmRaid.script_task import ScriptTask as RealmRaidScriptTask
 
 
 from module.logger import logger
 from module.logger import logger
 from module.exception import RequestHumanTakeover, TaskEnd
 from module.exception import RequestHumanTakeover, TaskEnd
@@ -66,16 +68,49 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, ExplorationAssets):
                             f' Enter {explorationConfig.exploration_config.exploration_level} failed!')
                             f' Enter {explorationConfig.exploration_config.exploration_level} failed!')
             raise RequestHumanTakeover
             raise RequestHumanTakeover
 
 
-        # 只探索7次
-        if explorationConfig.exploration_config.attack_number == AttackNumber.SEVEN:
+        # 探索
+        exploration_count = explorationConfig.exploration_config.current_exploration_count
+        # logger.info("探索执行次数:" + str(exploration_count))
+        if exploration_count > 0:
             count = 0
             count = 0
-            while count < 7:
+            while count < exploration_count:
                 if self.wait_until_appear(self.I_E_EXPLORATION_CLICK, wait_time=1):
                 if self.wait_until_appear(self.I_E_EXPLORATION_CLICK, wait_time=1):
+                    # 如果突破卷超出设定数量,退出循环,去打个突
+                    con_scrolls = self.config.exploration.scrolls
+                    # 如果打开绘卷模式
+                    if con_scrolls.scrolls_on:
+                        if con_scrolls.scrolls_cd > 0:
+                            self.screenshot()
+                            cu, res, total = self.O_REALM_RAID_NUMBER1.ocr(self.device.image)
+                            if cu >= con_scrolls.scrolls_number:
+                                # 设定下次探索时间
+                                next_run = datetime.now() + timedelta(minutes=con_scrolls.scrolls_cd)
+                                self.set_next_run(task='Exploration', success=False, finish=False, target=next_run)
+
+                                self.appear_then_click(self.I_RED_CLOSE)
+                                self.ui_goto(page_main)
+                                # 关闭 buff
+                                if con.buff_gold_50_click or con.buff_gold_100_click or con.buff_exp_50_click or con.buff_exp_100_click:
+                                    self.open_buff()
+                                    self.gold_50(is_open=False)
+                                    self.gold_100(is_open=False)
+                                    self.exp_50(is_open=False)
+                                    self.exp_100(is_open=False)
+                                    self.close_buff()
+
+                                # 去打个突
+                                RealmRaidScriptTask(config=self.config, device=self.device).run()
+
                     self.click(self.I_E_EXPLORATION_CLICK)
                     self.click(self.I_E_EXPLORATION_CLICK)
                     count += 1
                     count += 1
+                    logger.info("exploration count :" + str(count))
                     # 进入战斗环节
                     # 进入战斗环节
                     self.battle_process()
                     self.battle_process()
-                if self.appear(self.I_EXPLORATION_TITLE):
+                # 判断宝箱
+                if self.appear_then_click(self.I_TREASURE_BOX_CLICK, interval=1.8):
+                    self.open_expect_level()
+                # 判断妖气
+                elif self.appear(self.I_EXPLORATION_TITLE):
                     self.open_expect_level()
                     self.open_expect_level()
 
 
             if self.wait_until_appear(self.I_RED_CLOSE, wait_time=2):
             if self.wait_until_appear(self.I_RED_CLOSE, wait_time=2):