feat(combat): summoning
This commit is contained in:
+27
-3
@@ -108,13 +108,13 @@ def _make_engine(
|
||||
|
||||
|
||||
class TestSpellLoading:
|
||||
"""Given: data/spells/ directory with 10 JSON spell files
|
||||
"""Given: data/spells/ directory with 11 JSON spell files
|
||||
When: load_spell_registry is called
|
||||
Then: all 10 spells are loaded with correct fields."""
|
||||
Then: all 11 spells are loaded with correct fields."""
|
||||
|
||||
def test_loads_all_10_spells(self) -> None:
|
||||
reg = load_spell_registry(_SPELLS_DIR)
|
||||
assert len(reg) == 10
|
||||
assert len(reg) == 11
|
||||
|
||||
def test_spell_names_present(self) -> None:
|
||||
reg = load_spell_registry(_SPELLS_DIR)
|
||||
@@ -122,6 +122,7 @@ class TestSpellLoading:
|
||||
"Magic Missile", "Burning Hands", "Fireball", "Lightning Bolt",
|
||||
"Cure Light Wounds", "Cure Moderate Wounds", "Hold Person",
|
||||
"Fear", "Bull's Strength", "Acid Arrow",
|
||||
"Summon Monster II",
|
||||
}
|
||||
assert set(reg) == expected
|
||||
|
||||
@@ -411,3 +412,26 @@ class TestSpellDamageWithDr:
|
||||
engine._cast_spell(c, t, "Fireball")
|
||||
# Save fails (2), 6d6 rolls all 3 = 18 damage, DR 5/- -> 13 damage
|
||||
assert t.hp == hp_before - 13
|
||||
|
||||
|
||||
class TestSummonMonster:
|
||||
"""Given: a caster casting Summon Monster II
|
||||
When: _cast_spell is called
|
||||
Then: a celestial wolf is summoned adjacent to the caster."""
|
||||
|
||||
def test_summon_creature(self) -> None:
|
||||
caster = _make_caster()
|
||||
target = _make_target(hp_max=100)
|
||||
engine, c, t = _make_engine(caster, target, [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3])
|
||||
hp_before = len(engine._states)
|
||||
engine._cast_spell(c, t, "Summon Monster II")
|
||||
# Caster + target + summoned = 3 combatants
|
||||
assert len(engine._states) == hp_before + 1
|
||||
# Find the summoned creature
|
||||
summoned = [s for s in engine._states if s.combatant.id == "celestial_wolf"]
|
||||
assert len(summoned) == 1
|
||||
assert summoned[0].side == "players"
|
||||
# Check it has correct HP
|
||||
assert summoned[0].hp == 15
|
||||
# Check transcript mentions summon
|
||||
assert any("summon" in line.lower() for line in engine._transcript)
|
||||
|
||||
Reference in New Issue
Block a user