fix(stats): non-attack damage now lands in damage_taken - bleed ticks, recurring spell damage (Acid Arrow) and cure-spells-damage-undead (SRD Cure Light Wounds negative-energy hit, attributed to the caster's damage_dealt) were invisible to attrition while attacks were counted; transcripts and RNG untouched

This commit is contained in:
2026-09-19 17:02:21 +02:00
parent 7fefce4653
commit 0ad627c97c
4 changed files with 72 additions and 1 deletions
+20
View File
@@ -244,3 +244,23 @@ class TestRecurringSnapshot:
assert entry["recurring_damage"] == [
{"formula": "2d4", "types": ("acid",), "rounds_left": 2}
]
class TestRecurringTicksRecordDamageTaken:
"""Given: a target burning from Acid Arrow
When: each recurring tick lands
Then: attrition's damage_taken grows by the tick (README "dégâts subis");
the initial spell hit was already counted at cast time."""
def test_each_tick_counts_as_damage_taken(self) -> None:
caster = _caster(level=3)
victim = _victim(hp_max=200)
# attack (15) + initial 2d4 (3+3) + tick1 2d4 (2+2) + tick2 2d4 (4+4)
engine, c, v = _engine(caster, victim, [15, 3, 3, 2, 2, 4, 4])
engine._cast_spell(c, v, "Acid Arrow")
assert engine._stats["victim"].damage_taken == 6
assert engine._stats["caster"].damage_dealt == 6
engine._apply_recurring_damage(v)
assert engine._stats["victim"].damage_taken == 10
engine._apply_recurring_damage(v)
assert engine._stats["victim"].damage_taken == 18