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:
@@ -615,35 +615,69 @@ class ProgressionPlanner:
|
||||
return block(reason)
|
||||
if script and not policy.auto_dialogue:
|
||||
return block("自动对话未启用")
|
||||
if has_battle:
|
||||
local_action = self._battle_preflight_needed(step, record, number)
|
||||
reason = self._battle_step_gate(snapshot, policy, ranch, scope, account, task, info, step, number, kind,
|
||||
capability=local_action)
|
||||
if reason:
|
||||
return block(reason)
|
||||
if step.get("position") and account["position"] != step["position"]:
|
||||
return make("progression_navigate", "前往任务位置:" + self.location_text(step["position"]))
|
||||
if story and number not in record["before"]:
|
||||
return make("progression_dialogue", "完成任务对话:" + story, story=story, phase="before")
|
||||
if has_battle:
|
||||
if _integer(snapshot.raw["master"].get("ti")) < policy.reserve_ti:
|
||||
return block("当前体力低于保留体力")
|
||||
if account["losses"] >= policy.stop_after_loss:
|
||||
return block("达到任务战败停止次数")
|
||||
if kind == "battle" and not step.get("battle"):
|
||||
return block("任务战斗配置缺失")
|
||||
if kind == "passStage":
|
||||
value = step.get("statusValue") or {}
|
||||
stage_id, level = str(value.get("stage", "")), _integer(value.get("level"), -1)
|
||||
reason = self._stage_gate(snapshot, account, stage_id, level)
|
||||
if reason:
|
||||
return block(reason)
|
||||
stage = self.data.stage(stage_id)
|
||||
entry = (stage.get("level") or {}).get(str(level), {})
|
||||
if not entry.get("battle_available", bool(entry.get("battle"))):
|
||||
return block("关卡战斗配置缺失")
|
||||
reason = self._battle_resources(snapshot, policy, ranch, stage, level)
|
||||
if reason:
|
||||
return block(reason)
|
||||
return make("progression_battle", "执行任务战斗:" + info.get("name", ""),
|
||||
path="battleService/battleStart", payload={"battleType": "task", "taskTypeId": str(task["typeId"])})
|
||||
return make("progression_step", "提交任务步骤:" + requirement,
|
||||
path="taskService/taskCompleteStep", payload={"taskId": _integer(task["id"]), "taskTypeId": str(task["typeId"]), "removeIds": ids})
|
||||
|
||||
@staticmethod
|
||||
def _battle_preflight_needed(step, record, number):
|
||||
"""Only local actions need the early runtime/team readiness check."""
|
||||
return bool(step.get("position") or step.get("story") and number not in record["before"])
|
||||
|
||||
def _battle_step_gate(self, snapshot, policy, ranch, scope, account, task, info, step, number, kind, *, capability):
|
||||
"""Reject an unusable battle before navigation or its before-story."""
|
||||
if _integer(snapshot.raw["master"].get("ti")) < policy.reserve_ti:
|
||||
return "当前体力低于保留体力"
|
||||
if account["losses"] >= policy.stop_after_loss:
|
||||
return "达到任务战败停止次数"
|
||||
if kind == "battle" and not step.get("battle"):
|
||||
return "任务战斗配置缺失"
|
||||
if kind == "passStage":
|
||||
value = step.get("statusValue") or {}
|
||||
stage_id, level = str(value.get("stage", "")), _integer(value.get("level"), -1)
|
||||
reason = self._stage_gate(snapshot, account, stage_id, level)
|
||||
if reason:
|
||||
return reason
|
||||
stage = self.data.stage(stage_id)
|
||||
entry = (stage.get("level") or {}).get(str(level), {})
|
||||
if not entry.get("battle_available", bool(entry.get("battle"))):
|
||||
return "关卡战斗配置缺失"
|
||||
reason = self._battle_resources(snapshot, policy, ranch, stage, level)
|
||||
if reason:
|
||||
return reason
|
||||
check = getattr(self, "battle_capability", None) if capability else None
|
||||
if callable(check):
|
||||
intent = self._intent(scope, task, number, step, "progression_battle",
|
||||
"执行任务战斗:" + info.get("name", ""), policy,
|
||||
path="battleService/battleStart",
|
||||
payload={"battleType": "task", "taskTypeId": str(task["typeId"])})
|
||||
key = (getattr(self, "battle_capability_key", None), scope, intent.task_id, intent.task_type_id, number, intent.position, intent.stage_id,
|
||||
intent.difficulty, intent.team, intent.battle_mode,
|
||||
tuple(sorted((str(row.get("id")), row.get("curStep")) for row in snapshot.raw.get("currentTasks", []))),
|
||||
account["losses"])
|
||||
cached = getattr(self, "_battle_capability_cache", {}).get(key)
|
||||
supported, reason = cached if cached is not None else check(intent)
|
||||
if not hasattr(self, "_battle_capability_cache"):
|
||||
self._battle_capability_cache = {}
|
||||
self._battle_capability_cache[key] = (supported, reason)
|
||||
while len(self._battle_capability_cache) > 64:
|
||||
self._battle_capability_cache.pop(next(iter(self._battle_capability_cache)))
|
||||
if not supported:
|
||||
return reason or "战斗运行时或阵容尚不可用"
|
||||
return ""
|
||||
|
||||
def _battle_resources(self, snapshot, policy, ranch, stage, level):
|
||||
base = stage.get("cost") or {}
|
||||
cost = _integer(base.get("ti")) + _integer((stage.get("level") or {}).get(str(level), {}).get("cost"))
|
||||
|
||||
Reference in New Issue
Block a user