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:
@@ -341,6 +341,9 @@ class Engine:
|
||||
self.game_data = load_progression_data()
|
||||
if self.progression_planner is None:
|
||||
self.progression_planner = ProgressionPlanner(self.catalog, self.game_data, account_key=self._progression_namespace)
|
||||
# This is a read-only preflight; the same check must precede navigation
|
||||
# and dialogue, not just the battle action they lead to.
|
||||
self.progression_planner.battle_capability = self._battle_capability
|
||||
if not self._progression_state_loaded and self.snapshot is not None:
|
||||
stored = deepcopy(self.battle_journal.role(self.snapshot).get("planner_state"))
|
||||
if stored:
|
||||
@@ -712,6 +715,8 @@ class Engine:
|
||||
self._recover_confirmed_progression()
|
||||
self._battle_snapshot_source = self.snapshot
|
||||
self._battle_snapshot_digest = digest(self.snapshot.raw)
|
||||
self.progression_planner.battle_capability_key = digest({
|
||||
"snapshot": self._battle_snapshot_digest, "runtime": id(self.battles.runtime)})
|
||||
key = digest({"snapshot": self._battle_snapshot_digest, "policy": vars(self.progression_policy),
|
||||
"quests": vars(self.quest_policy), "ranch": vars(self.policy), "local_state": self.progression_planner.state_signature(self.snapshot),
|
||||
"pending": self._progression_pending(), "runtime": id(self.battles.runtime), "day": int(self.snapshot.now // 86400)})
|
||||
@@ -1022,9 +1027,7 @@ class Engine:
|
||||
except (ValueError, TypeError, KeyError, AttributeError) as error:
|
||||
self.auto = False
|
||||
return self.snapshot, [], "状态已读取;策略暂不可用:" + str(error)
|
||||
commission_actions = [action for action in plans if action.kind.startswith("quest_") or
|
||||
action.kind == "progression" and self._is_commission(action.payload["intent"])]
|
||||
actions = (commission_actions or self.pending_hatches) if hatch_only else plans
|
||||
actions = self.pending_hatches if hatch_only else plans
|
||||
action = actions[0] if actions else None
|
||||
if action and defer_hatch and action.kind == "hatch":
|
||||
action = None
|
||||
@@ -1100,6 +1103,59 @@ class Engine:
|
||||
message += ";" + ";".join(dict.fromkeys(self.planner.notes))
|
||||
return self.snapshot, plans, message
|
||||
|
||||
@single_flight
|
||||
@account_serial
|
||||
def poll_automation(self, kind):
|
||||
"""Execute one fast-scheduler kind without dispatching other strategies."""
|
||||
if kind not in {"explore", "breakthrough", "gift", "hatch"}:
|
||||
raise ValueError("快速自动操作类型无效")
|
||||
self.last_executed = False
|
||||
if self.demo:
|
||||
if self.snapshot is None:
|
||||
self.snapshot = demo_snapshot(self.catalog)
|
||||
else:
|
||||
self.read_snapshot(sync_master=False)
|
||||
if self._progression_pending():
|
||||
pending = self.battle_journal.pending(self.snapshot) or {}
|
||||
return self.snapshot, [], pending.get("message") or "有待核对的任务 / 战斗,快速操作未执行"
|
||||
explore_pending = self.explore_planner.pending(self.snapshot)
|
||||
if explore_pending or self._breakthrough_pending:
|
||||
message = (explore_pending or self._breakthrough_pending).get("message", "自动操作待核对")
|
||||
return self.snapshot, [], message
|
||||
plans = self.plans()
|
||||
allowed = {"explore": {"explore_start", "explore_finish"},
|
||||
"breakthrough": {"potential", "breakthrough"}, "gift": {"gift"}, "hatch": {"hatch"}}[kind]
|
||||
candidates = self.pending_hatches if kind == "hatch" else plans
|
||||
action = next((action for action in candidates if action.kind in allowed and action.path), None)
|
||||
if not self.auto or self._progression_cancel.is_set():
|
||||
return self.snapshot, plans, "策略已停止,快速操作未执行"
|
||||
if action is None:
|
||||
return self.snapshot, plans, {"explore": "探险", "breakthrough": "突破",
|
||||
"gift": "赠礼", "hatch": "孵化"}[kind] + "当前无可执行动作"
|
||||
self.last_executed = True
|
||||
if kind == "explore":
|
||||
return self._execute_explore(action)
|
||||
if kind == "breakthrough":
|
||||
return self._execute_breakthrough(action)
|
||||
if self.demo:
|
||||
self.apply_demo(action)
|
||||
else:
|
||||
response = self.client.call(action.path, action.payload)
|
||||
if kind == "gift":
|
||||
try:
|
||||
self.gift_planner.remember_success(self.snapshot, action, response)
|
||||
except ValueError:
|
||||
self.auto = False
|
||||
raise
|
||||
self.read_snapshot(sync_master=False)
|
||||
if kind == "hatch":
|
||||
stack_id = action.payload["eggs"][0]["stackId"]
|
||||
slot = next((slot for slot in self.snapshot.raw["stacks"] if int(slot["id"]) == stack_id), None)
|
||||
if slot is None or int(slot.get("monsterId") or 0) <= 0:
|
||||
self.auto = False
|
||||
raise ValueError("装填已返回,但坑位状态尚未同步;已停止,请刷新核对后再继续")
|
||||
return self.snapshot, self.plans(), ("[演示] " if self.demo else "") + action.description
|
||||
|
||||
def _execute_legacy_task(self, action):
|
||||
"""Keep the commission scheduler, with the same durable replay barrier."""
|
||||
payload = action.payload
|
||||
|
||||
Reference in New Issue
Block a user