feat: add configurable battle loss cooldown in Web 2.0.13
Web image / image (push) Waiting to run

This commit is contained in:
AttilaNet
2026-11-17 00:17:52 +08:00
parent 598bdf5c1c
commit b976151263
23 changed files with 297 additions and 43 deletions
+13 -3
View File
@@ -32,6 +32,7 @@ from .resource_stages import resource_entry_reason, item_requirements, available
from .quests import indexed, stage_has_level
from .sweeping import SweepPolicy, hidden_stage_id
from .team_availability import team_availability_reason
from .battle_retry import loss_retry_reason
def value(obj, name, default=None):
@@ -152,6 +153,14 @@ class BattleJournal:
state = self.role(snapshot)
return next((r for r in state["records"] if r["attempt_id"] == state["pending"]), None)
def loss_reason(self, snapshot, policy):
state = self.role(snapshot)
before = (state.get("losses"), state.get("last_loss_at"))
reason = loss_retry_reason(state, snapshot.now, policy)
if before != (state.get("losses"), state.get("last_loss_at")):
self.save()
return reason
def records(self, snapshot):
with self.lock:
self.reload()
@@ -201,8 +210,10 @@ class BattleJournal:
shared_loss_budget = record.get("kind") != "map_battle" and not record.get("sweep_sample_id")
if outcome == "loss" and shared_loss_budget:
state["losses"] += 1
state["last_loss_at"] = snapshot.now
elif outcome == "win" and shared_loss_budget:
state["losses"] = 0
state["last_loss_at"] = None
self.save()
def cursors(self, snapshot):
@@ -350,9 +361,8 @@ class BattleOrchestrator:
return "任务实例或服务器步骤已变化,请重新规划"
if planner_validated is None and checkpoints.get(str(number), {}).get("submitted"):
return "该任务步骤已有确认记录,等待剧情 / 服务器步骤核对"
limit = max(0, int(policy.stop_after_loss))
if limit and self.journal.role(snapshot)["losses"] >= limit:
return "已达战败停止次数,请核对阵容后重置战败计数"
if reason := self.journal.loss_reason(snapshot, policy):
return reason
reason = team_availability_reason(snapshot, policy.team)
if reason:
return reason