Add v1.2 development quest progression and experimental battle runtime

This commit is contained in:
AttilaNet
2026-11-08 19:29:28 +08:00
parent 79b7672471
commit 0d3e231cde
71 changed files with 14349 additions and 172 deletions
+8 -5
View File
@@ -78,7 +78,9 @@ class TaskPlanner:
self.guard = Planner(catalog)
def current(self, snapshot):
return [t for t in snapshot.raw.get("currentTasks", []) if str(t.get("typeId")) in self.catalog.data.get("task_info", {})]
infos = self.catalog.data.get("task_info", {})
return [t for t in snapshot.raw.get("currentTasks", []) if str(t.get("typeId")) in infos
and infos[str(t["typeId"])].get("type", 4) == 4]
def requirement(self, snapshot, step, task, policy, ranch):
if not condition_ok(step.get("condition"), snapshot):
@@ -146,11 +148,11 @@ class TaskPlanner:
continue
for type_id in offers:
info = self.catalog.data.get("task_info", {}).get(str(type_id), {})
if info:
if info and info.get("type", 4) == 4:
rows.append((str(type_id), info.get("name", ""), f"城市 {city} 可接", info.get("des", ""), {"city": int(city)}))
return rows
def plan(self, snapshot, policy, ranch):
def plan(self, snapshot, policy, ranch, *, include_active=True, accept_supported=None):
if not policy.enabled:
return []
history = snapshot.raw.get("history", {})
@@ -159,7 +161,7 @@ class TaskPlanner:
current_day = int((snapshot.now - 10 + 8 * 3600) // 86400)
if old_day < current_day:
return [Action("quest_reset", "刷新跨日委托", "taskService/taskLoopFlush", {})]
for task in self.current(snapshot):
for task in self.current(snapshot) if include_active else []:
info = self.catalog.data["task_info"][str(task["typeId"])]
index, steps = int(task.get("curStep", 1)) - 1, info.get("steps", [])
payload = {"taskId": int(task["id"]), "taskTypeId": str(task["typeId"])}
@@ -182,7 +184,8 @@ class TaskPlanner:
if info.get("closed") or not condition_ok((info.get("startStep") or {}).get("condition"), snapshot):
continue
steps = info.get("steps", [])
supported = all((s.get("statusType") in ("passStage", "battle") and policy.battle_tasks)
supported = accept_supported(type_id) if accept_supported else all(
(s.get("statusType") in ("passStage", "battle") and policy.battle_tasks)
or self.requirement(snapshot, s, {}, policy, ranch)[0] for s in steps)
if supported:
return [Action("quest_accept", f"接取委托:{name}", "taskService/taskLoopReceive", {"taskTypeId": type_id, "city": city})]