Improve task filters, exploration rewards and V4 battle simulation

This commit is contained in:
AttilaNet
2026-11-10 14:09:53 +08:00
parent 5082c2df5c
commit 6d74730735
20 changed files with 1129 additions and 42 deletions
+8 -2
View File
@@ -559,6 +559,7 @@ class Engine:
def _battle_capability(self, intent):
try:
from .battle_simulator import DEFAULT_DAMAGE_PROFILE, DESKTOP_DAMAGE_PROFILE
if self._is_commission(intent) and not self.quest_policy.battle_tasks:
return False, "战斗委托未启用;未开始战斗"
if self.battles.runtime is None:
@@ -569,7 +570,9 @@ class Engine:
reason = self.battles.resource_reason(self.snapshot, intent, policy, self.policy)
if reason:
return False, reason
key = digest({"snapshot": self._battle_snapshot_digest, "runtime": id(self.battles.runtime), "team": policy.team, "mode": policy.battle_mode,
damage_profile = DESKTOP_DAMAGE_PROFILE if policy.battle_mode == "experimental" else DEFAULT_DAMAGE_PROFILE
key = digest({"snapshot": self._battle_snapshot_digest, "runtime": id(self.battles.runtime), "team": policy.team,
"mode": policy.battle_mode, "damage_profile": damage_profile,
**{name: value(intent, name) for name in ("task_type_id", "step_number", "stage_id", "difficulty", "battle_kind")}})
if key not in self._capability_cache:
request = self.battles.request(self.snapshot, intent, policy)
@@ -626,6 +629,7 @@ class Engine:
return rows, adjusted
def _battle_request(self, snapshot, intent, policy, request):
from .battle_simulator import DEFAULT_DAMAGE_PROFILE, DESKTOP_DAMAGE_PROFILE
self._ensure_progression()
self._select_battle_runtime(policy.battle_mode)
if self._battle_snapshot_source is not snapshot:
@@ -640,6 +644,7 @@ class Engine:
self.game_data.stage_battle(value(intent, "stage_id"), value(intent, "difficulty", "1"))
prepared = request | {"snapshot": self._battle_roster,
"battle_mode": policy.battle_mode,
"damage_profile": DESKTOP_DAMAGE_PROFILE if policy.battle_mode == "experimental" else DEFAULT_DAMAGE_PROFILE,
"context": "task_pass_stage" if task and kind == "passStage" else "task_battle" if task else "ordinary_stage",
"original_data": {"battle": battle, "manifest": self.game_data.manifest},
"roster": self._battle_roster, "task_id": value(intent, "task_id"),
@@ -1195,11 +1200,12 @@ class Engine:
stop_after_loss=0, battle_mode="experimental")
def _map_roster_signature(self, snapshot, team):
from .battle_simulator import DESKTOP_DAMAGE_PROFILE
selected = next((row for row in snapshot.raw.get("teams", []) if row.get("teamName") == team
and row.get("teamType") == "battleTeam"), {})
ids = {int(mid) for mid in selected.get("monsters", []) if mid and int(mid) > 0}
transient = {"exp", "timeStart", "nicName", "roomId"}
return digest({"team": selected,
return digest({"team": selected, "damage_profile": DESKTOP_DAMAGE_PROFILE,
"master": {key: val for key, val in snapshot.raw["master"].items() if key == "level" or key.startswith("global")},
"monsters": sorted([{key: val for key, val in mon.items() if key not in transient}
for mon in snapshot.raw.get("monsters", []) if int(mon["id"]) in ids], key=lambda mon: int(mon["id"])),