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

fix(DemonEncounter): 修正重进地图导航

- 重进地图改为先回 town 再进 realworld,替代原直接 goto 逢魔入口页
- 搜索重试由2轮提升至3轮,每轮中央集结点击次数由2次提升至3次
- 补齐 GameStuckError 导入
User 1 месяц назад
Родитель
Сommit
4e4e9079f3
1 измененных файлов с 11 добавлено и 11 удалено
  1. 11 11
      tasks/DemonEncounter/script_task.py

+ 11 - 11
tasks/DemonEncounter/script_task.py

@@ -9,13 +9,13 @@ from cached_property import cached_property
 from datetime import datetime, timedelta
 
 from module.logger import logger
-from module.exception import TaskEnd
+from module.exception import GameStuckError, TaskEnd
 from module.base.timer import Timer
 
 from tasks.Component.SwitchSoul.switch_soul import SwitchSoul
 from tasks.DemonEncounter.config import BossType, DemonEncounter, convert_to_general_battle_config
 from tasks.GameUi.game_ui import GameUi
-from tasks.GameUi.page import page_demon_encounter, page_demon_encounter_realworld, page_shikigami_records
+from tasks.GameUi.page import page_town, page_demon_encounter_realworld, page_shikigami_records
 from tasks.DemonEncounter.assets import DemonEncounterAssets
 from tasks.Component.GeneralBattle.general_battle import GeneralBattle
 from tasks.Component.GeneralBattle.config_general_battle import GeneralBattleConfig
@@ -108,8 +108,8 @@ class ScriptTask(GameUi, GeneralBattle, DemonEncounterAssets, SwitchSoul):
                     self.appear_then_click(self.I_DE_LOCATION, interval=2)
                     time.sleep(1)
 
-                # 最多重新执行两轮“逢魔/极逢魔 -> 地图中央首领”的完整流程。
-                for search_attempt in range(1, 3):
+                # 最多重新执行三轮“逢魔/极逢魔 -> 地图中央首领”的完整流程。
+                for search_attempt in range(1, 4):
                     self.device.click_record_clear()
                     self.screenshot()
                     if self.appear(self.I_BOSS_FIRE) or self.appear(self.I_BEST_BOSS_FIRE):
@@ -121,14 +121,14 @@ class ScriptTask(GameUi, GeneralBattle, DemonEncounterAssets, SwitchSoul):
                     if not self.appear_then_click(search_button, interval=2):
                         raise GameStuckError(f'Cannot find {boss_name} search button')
                     logger.info(
-                        f'Finding {boss_name}, attempt {search_attempt}/2 '
+                        f'Finding {boss_name}, attempt {search_attempt}/3 '
                         f'(re-enter round {reenter_round}/3)...'
                     )
                     time.sleep(1)
 
-                    # 每轮点击地图中央框选的红色“集结”区域至多两次,
+                    # 每轮点击地图中央框选的红色“集结”区域至多三次,
                     # 每次等待集结挑战标志5秒。
-                    for center_attempt in range(1, 3):
+                    for center_attempt in range(1, 4):
                         self.click(self.C_DM_BOSS_CLICK, interval=2)
                         deadline = time.monotonic() + 5
                         while time.monotonic() < deadline:
@@ -136,13 +136,13 @@ class ScriptTask(GameUi, GeneralBattle, DemonEncounterAssets, SwitchSoul):
                             if self.appear(self.I_BOSS_FIRE) or self.appear(self.I_BEST_BOSS_FIRE):
                                 logger.info(
                                     f'{boss_name} gather appeared after center click '
-                                    f'{center_attempt}/2'
+                                    f'{center_attempt}/3'
                                 )
                                 return True
                             time.sleep(0.2)
                         logger.warning(
                             f'{boss_name} gather did not appear after center click '
-                            f'{center_attempt}/2'
+                            f'{center_attempt}/3'
                         )
 
                     # 本轮失败,返回逢魔地图,重新点击逢魔/极逢魔进行下一轮搜寻。
@@ -156,9 +156,9 @@ class ScriptTask(GameUi, GeneralBattle, DemonEncounterAssets, SwitchSoul):
                                 break
                             time.sleep(0.2)
 
-                # 2次搜索都没找到: 重进地图清状态, 最多3轮
+                # 3次搜索都没找到: 重进地图清状态, 最多3轮
                 logger.info(f'Boss not found, re-enter demon encounter map (round {reenter_round}/3)')
-                self.goto_page(page_demon_encounter)
+                self.goto_page(page_town)
                 self.goto_page(page_demon_encounter_realworld)
 
             raise GameStuckError(