fix(rules): expose healing_done in per-combatant stats and the CLI report - the channel/spell healing deliberately removed from damage_dealt (2e2873f) was invisible; CombatantStats/_LiveStats gain a healing_done counter booked with the hp actually restored (capped at the target's hp_max, overheal uncounted) by _channel_heal and by spell HealEffect on living targets, while cure-as-damage on undead stays in damage_dealt and the damage counters keep their exact semantics; the runner aggregates and averages the new field and the French report prints it as 'soins prodigués'; +4 tests (channel heal, cure spell, undead cure guard, run_encounter aggregate) +1 CLI assertion

This commit is contained in:
2026-09-19 23:23:00 +02:00
parent 5e7436b210
commit e6021a6dda
8 changed files with 180 additions and 7 deletions
+14 -4
View File
@@ -651,12 +651,18 @@ def _bresenham_line(start: Pos, end: Pos) -> list[Pos]:
@dataclass(frozen=True)
class CombatantStats:
"""Aggregated outcomes for one combatant over a battle."""
"""Aggregated outcomes for one combatant over a battle.
``healing_done`` is hit points *restored* by the combatant (channel heal
and spell HealEffect, capped at the target's hp_max); healing is never
counted in ``damage_dealt``/``damage_taken`` (those stay damage-only).
"""
hits: int = 0
crits: int = 0
damage_dealt: int = 0
damage_taken: int = 0
healing_done: int = 0
_PC_SOURCE_PREFIX = "fiches_personnages/"
@@ -1256,6 +1262,7 @@ class _LiveStats:
crits: int = 0
damage_dealt: int = 0
damage_taken: int = 0
healing_done: int = 0
@dataclass
@@ -5882,9 +5889,10 @@ class CombatEngine:
if affected_state.hp < 0:
affected_state.stabilized_hp = affected_state.hp
actual = affected_state.hp - old_hp
# Healing is NOT damage dealt: the attrition counters track damage only
# (README "degats infligés/subis"), consistent with spell healing
# (HealEffect), which is counted nowhere.
# Healing is NOT damage dealt: the damage counters stay damage-only
# (README "degats infligés/subis"); restored hp are booked to the
# healer's separate healing_done counter (mirrors spell HealEffect).
self._stats[state.combatant.id].healing_done += actual
self._stop_bleeding(affected_state)
self._log(
f"round {self._current_round} {state.combatant.id}: "
@@ -7330,6 +7338,8 @@ class CombatEngine:
if target.hp < 0:
target.stabilized_hp = target.hp
actual = target.hp - old_hp
if caster_live is not None:
caster_live.healing_done += actual
self._stop_bleeding(target)
return f"+{actual} HP"