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

Merge remote-tracking branch 'origin/exploration' into exploration

ljxun 2 лет назад
Родитель
Сommit
5d096d4be3
2 измененных файлов с 25 добавлено и 29 удалено
  1. 4 5
      tasks/Exploration/config.py
  2. 21 24
      tasks/Exploration/script_task.py

+ 4 - 5
tasks/Exploration/config.py

@@ -2,7 +2,7 @@ from pydantic import BaseModel, Field
 from enum import Enum
 from enum import Enum
 from tasks.Component.GeneralBattle.config_general_battle import GeneralBattleConfig
 from tasks.Component.GeneralBattle.config_general_battle import GeneralBattleConfig
 from tasks.Component.SwitchSoul.switch_soul_config import SwitchSoulConfig
 from tasks.Component.SwitchSoul.switch_soul_config import SwitchSoulConfig
-from tasks.Component.config_base import ConfigBase
+from tasks.Component.config_base import ConfigBase, TimeDelta
 from tasks.Component.config_scheduler import Scheduler
 from tasks.Component.config_scheduler import Scheduler
 
 
 
 
@@ -62,10 +62,9 @@ class ChooseRarity(str, Enum):
 
 
 class Scrolls(BaseModel):
 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='设置突破票数量,超过去打突破')
+    scrolls_enable: bool = Field(title='绘卷模式', default=False, description='绘卷模式(探索->突破)循环')
+    scrolls_cd: TimeDelta = Field(title='探索间隔时间', default=TimeDelta(hours=0, minutes=30, seconds=0), description='探索间隔时间')
+    scrolls_threshold: int = Field(title='突破票数量', default='25', description='设置突破票数量,超过去打突破')
 
 
 
 
 class ExplorationConfig(BaseModel):
 class ExplorationConfig(BaseModel):

+ 21 - 24
tasks/Exploration/script_task.py

@@ -69,7 +69,7 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, ExplorationAssets):
             raise RequestHumanTakeover
             raise RequestHumanTakeover
         con_scrolls = self.config.exploration.scrolls
         con_scrolls = self.config.exploration.scrolls
         # 判断是否绘卷模式,设置探索次数
         # 判断是否绘卷模式,设置探索次数
-        if con_scrolls.scrolls_on:
+        if con_scrolls.scrolls_enable:
             exploration_count = 50
             exploration_count = 50
         else:
         else:
             exploration_count = explorationConfig.exploration_config.current_exploration_count
             exploration_count = explorationConfig.exploration_config.current_exploration_count
@@ -80,30 +80,27 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, ExplorationAssets):
             while count < exploration_count:
             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):
                     # 如果打开绘卷模式
                     # 如果打开绘卷模式
-                    if con_scrolls.scrolls_on:
-                        if con_scrolls.scrolls_cd > 0:
+                    if con_scrolls.scrolls_enable:
+                        self.screenshot()
+                        cu, res, total = self.O_REALM_RAID_NUMBER1.ocr(self.device.image)
+                        # 如果突破卷超出设定数量,去打个突
+                        if cu >= con_scrolls.scrolls_threshold:
+                            # 设定下次探索时间
+                            next_run = datetime.now() + con_scrolls.scrolls_cd
+                            self.set_next_run(task='Exploration', success=False, finish=False, target=next_run)
+                            self.set_next_run(task='RealmRaid', success=False, finish=False, target=datetime.now())
 
 
-                            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.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()
+                            raise TaskEnd
 
 
                     self.click(self.I_E_EXPLORATION_CLICK)
                     self.click(self.I_E_EXPLORATION_CLICK)
                     count += 1
                     count += 1