Fix fast automation routing and blocked quest navigation loops

Isolate hatch, gift, exploration and breakthrough timers; cancel queued automation after settings change. Check battle readiness before local quest navigation and reject exploring teams or disabled sweeps before entry.
This commit is contained in:
AttilaNet
2026-11-09 12:14:47 +08:00
parent 9f819d828a
commit eaaad3488b
9 changed files with 931 additions and 37 deletions
+47 -8
View File
@@ -159,6 +159,7 @@ class Window(ExplorationPages, ProgressionPages, ActivityPages, W.QMainWindow):
self.pending_exploration_view = False
self.monster_data_pending = False
self.pending_schedule = False
self.automation_generation = 0
self.next_explore = float("inf")
self.next_breakthrough = float("inf")
self.monster_view_visible = False
@@ -669,6 +670,7 @@ class Window(ExplorationPages, ProgressionPages, ActivityPages, W.QMainWindow):
self.update_workflow_status()
def stop_workflow(self):
self.automation_generation += 1
self.set_strategy_checked(False)
self.engine.auto = False
self.cancel_progression()
@@ -1337,6 +1339,9 @@ class Window(ExplorationPages, ProgressionPages, ActivityPages, W.QMainWindow):
self.progression_views = None
if self.presentation_active and self.tabs.currentWidget() in (self.progression_page, self.battle_records_page):
self.pending_progression_view = True
self.arm_hatching()
self.arm_gifting()
self.arm_extended_automation()
if self.pending_schedule and not self.closed and not self.close_after_job:
self.pending_schedule = False
self.schedule()
@@ -1567,7 +1572,14 @@ class Window(ExplorationPages, ProgressionPages, ActivityPages, W.QMainWindow):
if hatch_only:
self.hatch_timer.stop()
self.next_hatch = float("inf")
self.run_job("hatch" if hatch_only else "poll", lambda: self.engine.poll(hatch_only=hatch_only, defer_hatch=not hatch_only))
engine, generation = self.engine, self.automation_generation
def dispatch():
if automated and (generation != self.automation_generation or engine is not self.engine):
return engine.snapshot, [], "自动化设置已变化,未开始的自动轮询已取消"
return engine.poll(hatch_only=hatch_only, defer_hatch=not hatch_only)
self.run_job("hatch" if hatch_only else "poll", dispatch)
except ValueError as error:
self.stop_workflow()
self.engine.policy = Policy(enabled=False)
@@ -1577,18 +1589,41 @@ class Window(ExplorationPages, ProgressionPages, ActivityPages, W.QMainWindow):
self.submit("poll", self.engine.poll)
def run_extended_automation(self):
if self.busy or not self.engine.auto or not self.engine.snapshot:
if self.busy or not self.monitoring or not self.strategy_toggle.isChecked() or not self.engine.snapshot:
return
self.submit("automation", self.engine.poll)
now = time.monotonic()
if now >= self.next_explore and self.explore_enabled.isChecked():
self.run_fast_automation("explore")
elif now >= self.next_breakthrough and self.breakthrough_targets:
self.run_fast_automation("breakthrough")
def run_fast_automation(self, kind):
if self.busy or self.closed or self.logout_phase is not None:
return
self.automation_generation += 1
setattr(self, "next_" + kind, float("inf"))
generation = self.automation_generation
engine = self.engine
def dispatch():
if generation != self.automation_generation or engine is not self.engine:
return engine.snapshot, [], "自动化设置已变化,未开始的快速任务已取消"
return engine.poll_automation(kind)
self.submit("automation", dispatch)
def arm_extended_automation(self):
active = self.monitoring and self.strategy_toggle.isChecked() and not self.closed and self.engine.snapshot is not None
plans = self.latest_render[1] if self.latest_render else []
explore = active and self.explore_enabled.isChecked() and any(
action.kind in ("explore_start", "explore_finish") and action.path for action in plans)
breakthrough = active and any(action.kind in ("potential", "breakthrough") for action in plans)
self.next_explore = time.monotonic() + 1 if explore else float("inf")
self.next_breakthrough = time.monotonic() + 1 if breakthrough else float("inf")
breakthrough = active and bool(self.breakthrough_targets) and any(
action.kind in ("potential", "breakthrough") for action in plans)
now = time.monotonic()
for kind, enabled in (("explore", explore), ("breakthrough", breakthrough)):
attribute = "next_" + kind
deadline = getattr(self, attribute)
setattr(self, attribute, (now + 1 if deadline == float("inf") else deadline) if enabled else float("inf"))
def poll_delay(self):
return random.uniform(0, self.interval.currentData())
@@ -1654,11 +1689,11 @@ class Window(ExplorationPages, ProgressionPages, ActivityPages, W.QMainWindow):
self.submit("growth_sync", self.engine.sync_growth)
elif (self.monitoring and self.strategy_toggle.isChecked() and self.fill.isChecked()
and self.ranch_enabled.isChecked() and now >= self.next_hatch):
self.refresh(automated=True, hatch_only=True)
self.run_fast_automation("hatch")
elif self.monitoring and now >= self.next_poll:
self.refresh(automated=True)
elif self.monitoring and self.strategy_toggle.isChecked() and now >= self.next_gift:
self.refresh(automated=True)
self.run_fast_automation("gift")
elif self.monitoring and self.strategy_toggle.isChecked() and now >= min(self.next_explore, self.next_breakthrough):
self.run_extended_automation()
@@ -2067,7 +2102,11 @@ class Window(ExplorationPages, ProgressionPages, ActivityPages, W.QMainWindow):
def settings_changed(self, *args):
if not self.closed and not self.loading_config and hasattr(self, "auto_save_timer"):
self.automation_generation += 1
self.auto_save_timer.start(300)
self.arm_hatching()
self.arm_gifting()
self.arm_extended_automation()
def persist_settings(self):
if self.closed or self.loading_config: