fix(combat): witch hex trigger uses the SRD close range scaled by caster level (25 ft + 5 ft per 2 levels, extracted as spells.close_range_ft and shared with spell_range_ft) instead of the fixed _HEX_RANGE_FT 25 - a level-5 witch reaches 35 ft; + scaling regression test

This commit is contained in:
2026-09-19 19:07:41 +02:00
parent 6f01a8ebdd
commit 238e5f201e
3 changed files with 31 additions and 4 deletions
+16
View File
@@ -319,6 +319,22 @@ def test_nairda_emits_hex_when_available() -> None:
assert any(a.kind == "hex" for a in actions)
def test_nairda_hex_close_range_scales_with_caster_level() -> None:
"""SRD (Magic - Range): close = 25 ft + 5 ft per 2 caster levels -> 35 ft
at level 5; the fixed 25 ft cut off a 30 ft target. APG hexes carry a
close range, so a goblin at 30 ft (6 squares, 4 diagonals) gets hexed
and one at 40 ft (8 squares) does not."""
engine, me, _ = _engine(_combatant("nairda", resources={"hexes": 5}), [])
near = _state(_combatant("goblin", hp_max=6), "monsters", (1, 1), hp=6)
engine.states.append(near)
assert any(a.kind == "hex" for a in default_policy(engine, me))
engine2, me2, _ = _engine(_combatant("nairda-b", resources={"hexes": 5}), [])
far = _state(_combatant("goblin-b", hp_max=6), "monsters", (11, 9), hp=6)
engine2.states.append(far)
assert not any(a.kind == "hex" for a in default_policy(engine2, me2))
def test_nairda_silent_when_hexes_exhausted() -> None:
nairda = _combatant("nairda", resources={"hexes": 0})
goblin = _combatant("goblin", hp_max=6)