fix(combat): correct spell DC formula

This commit is contained in:
2026-09-04 22:55:37 +02:00
parent 43303cf28e
commit 789d2f5396
11 changed files with 40 additions and 10 deletions
+9 -8
View File
@@ -56,6 +56,7 @@ def _make_caster(cid: str = "caster", *, level: int = 5) -> Combatant:
speed_land_ft=30,
saves=Saves(fort=3, ref=4, will=4),
attacks=[attack],
casting_ability="int",
)
@@ -366,18 +367,18 @@ class TestSpellDispatchViaExecute:
)
assert t.hp < hp_before
class TestSpellDcScalesWithLevel:
"""Given: a caster with level N
When: a spell with base_dc 10 is cast
Then: the DC is 10 + N."""
"""Given: a caster with level N and casting ability mod M
When: a spell of level L is cast
Then: the DC is 10 + L + M."""
def test_dc_is_base_plus_level(self) -> None:
caster = _make_caster(level=5)
def test_dc_is_ten_plus_spell_level_plus_ability_mod(self) -> None:
caster = _make_caster(level=5) # int 18 -> mod +4
target = _make_target()
engine, c, t = _make_engine(caster, target, [20, 1, 1, 1, 1, 1, 1])
engine._cast_spell(c, t, "Fireball")
assert any("DC15" in line for line in engine._transcript)
engine._cast_spell(c, t, "Fireball") # fireball is level 3
# DC = 10 + spell_level(3) + int_mod(4) = 17
assert any("DC17" in line for line in engine._transcript)
class TestSpellDamageWithDr: