Fix away summary merge for deliveries

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rope 2026-11-11 13:50:15 +00:00
parent 450abc9be9
commit f042a718cd
2 changed files with 14 additions and 2 deletions

View file

@ -3560,7 +3560,7 @@ def empty_summary() -> dict:
return {"done": 0, "items": {}, "overflow": {}, "xp": {}, "levels": [], "eaten": {}, "used": {}, "damage": 0,
"gold": 0, "wins": 0, "losses": 0, "lucky": 0, "stopped": None, "resumed": None, "run_over": None, "skipped": [],
"sold": {}, "sold_gold": 0, "pp_spent": 0, "pp_gained": 0, "prayer_out": False, "second_wind": 0,
"kept": 0, "potions_drunk": {}, "potion_out": [], "labour": 0}
"kept": 0, "potions_drunk": {}, "potion_out": [], "labour": 0, "delivered": {}}
def process_player(world: dict, player: dict, now: float, rng: random.Random | None = None) -> dict:
@ -4174,8 +4174,11 @@ def merge_summary(into: dict, more: dict) -> dict:
elif isinstance(value, (int, float)):
into[key] = into.get(key, 0) + value
elif isinstance(value, dict):
bucket = into.get(key)
if not isinstance(bucket, dict): # new to this summary, or an older save's count
bucket = into[key] = {}
for item, qty in value.items():
into.setdefault(key, {})[item] = into[key].get(item, 0) + qty
bucket[item] = bucket.get(item, 0) + qty
elif key == "levels":
into[key] = [entry for entry in into.get(key, []) if entry[0] not in {s for s, _ in value}] + value
elif isinstance(value, list):