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
+46
View File
@@ -0,0 +1,46 @@
"""Read-only availability checks shared by combat planners and runners."""
def _identifier(value):
if isinstance(value, bool):
return None
try:
result = int(value)
except (TypeError, ValueError, OverflowError):
return None
return result if result > 0 else None
def _exploring_ids(snapshot):
result = set()
for team in snapshot.raw.get("exploreTeams") or []:
if not isinstance(team, dict) or _identifier(team.get("status")) != 1:
continue
members = team.get("monsters")
if isinstance(members, str):
members = members.split(",")
if not isinstance(members, (list, tuple)):
continue
result.update(mid for value in members if (mid := _identifier(value)) is not None)
return result
def team_availability_reason(snapshot, team_name):
"""Return why the complete selected battle team cannot enter combat.
An active exploration team or an individual exploration marker reserves
the whole selected lineup. Never drop busy members to make a partial team.
"""
team = next((row for row in snapshot.raw.get("teams") or []
if isinstance(row, dict) and row.get("teamName") == team_name
and row.get("teamType") == "battleTeam"), {})
if not team:
return "未找到所选战队"
ids = [mid for value in team.get("monsters") or [] if (mid := _identifier(value)) is not None]
if not ids or any(mid not in snapshot.monsters for mid in ids):
return "所选战队无有效魔物或实例缺失"
active = _exploring_ids(snapshot)
busy = {mid for mid in ids if mid in active or (_identifier(snapshot.monsters[mid].get("inExploreTeam")) or 0) > 0}
if busy:
return f"所选战队有 {len(busy)}/{len(ids)} 只魔物正在探险,须整队空闲后才能战斗"
return ""