data(spells): add batch 3 of PC spell list (32 spells)

This commit is contained in:
2026-09-10 19:43:07 +02:00
parent 543da6a931
commit 1ca5aed758
37 changed files with 579 additions and 8 deletions
+2 -2
View File
@@ -24,11 +24,11 @@ MAP = ROOT / "data" / "maps" / "sample_arena.yaml"
ONI = ROOT / "data" / "pcs" / "oni.json"
GOBLIN = ROOT / "data" / "monsters" / "goblin.json"
_NUM_SPELLS = 75
_NUM_SPELLS = 107
def test_runner_loads_realtime_spell_registry() -> None:
"""The runner's registry source holds all 75 real spells from data/spells/."""
"""The runner's registry source holds all 107 real spells from data/spells/."""
registry = load_spell_registry(SPELLS_DIR)
assert len(registry) == _NUM_SPELLS
+2 -1
View File
@@ -115,7 +115,8 @@ class TestBatch2Loading:
def test_registry_grew_by_exactly_32(self) -> None:
reg = load_spell_registry(_SPELLS_DIR)
assert len(reg) == _BATCH1_COUNT + 32
# Batch 3 adds more spells; the exact total is pinned there.
assert len(reg) >= _BATCH1_COUNT + 32
assert set(_BATCH2) <= set(reg)
def test_every_effect_validates(self) -> None:
+146
View File
@@ -0,0 +1,146 @@
"""Batch 3 (V6c): the final 32 PC-sheet spells added to data/spells/.
Given: the registry directory with the 11 original spells plus batches 1-2 (75)
When: load_spell_registry / load_spell is called
Then: every batch-3 spell loads with the expected level/school/range/save,
the registry reaches exactly 107 (11 + 96), every effect validates against the
schema (parsing raises on any unknown field value or condition), and the
registry covers EVERY spell name referenced by data/pcs/*.json (no missing
spell remains).
"""
from __future__ import annotations
import json
from pathlib import Path
import pytest
from pf1e_simulator.conditions import CONDITIONS_BY_NAME
from pf1e_simulator.spells import (
AreaEffect,
BuffEffect,
ConditionEffect,
DamageEffect,
HealEffect,
SpellEffect,
SpellSpec,
SummonEffect,
load_spell,
load_spell_registry,
)
_SPELLS_DIR = Path(__file__).resolve().parent.parent / "data" / "spells"
_PCS_DIR = Path(__file__).resolve().parent.parent / "data" / "pcs"
_BATCH2_COUNT = 75
# name -> (file stem, level, school, range, save)
_BATCH3: dict[str, tuple[str, int, str, str, str]] = {
"Ray of Enfeeblement": ("ray_of_enfeeblement", 1, "necromancy", "close", "fort"),
"Ray of Frost": ("ray_of_frost", 0, "evocation", "close", "none"),
"Read Magic": ("read_magic", 0, "divination", "personal", "none"),
"Resistance": ("resistance", 0, "abjuration", "touch", "will"),
"Restoration, Lesser": ("restoration_lesser", 2, "conjuration", "touch", "will"),
"Sanctuary": ("sanctuary", 1, "abjuration", "touch", "will"),
"Saving Finale": ("saving_finale", 1, "evocation", "close", "will"),
"Scorching Ray": ("scorching_ray", 2, "evocation", "close", "none"),
"Shard of Chaos": ("shard_of_chaos", 2, "evocation", "close", "will"),
"Shield": ("shield", 1, "abjuration", "personal", "none"),
"Shield of Faith": ("shield_of_faith", 1, "abjuration", "touch", "will"),
"Shocking Grasp": ("shocking_grasp", 1, "evocation", "touch", "none"),
"Silence": ("silence", 2, "illusion", "long", "will"),
"Sleep": ("sleep", 1, "enchantment", "medium", "will"),
"Sound Burst": ("sound_burst", 2, "evocation", "close", "fort"),
"Spark": ("spark", 0, "evocation", "close", "fort"),
"Spear of Purity": ("spear_of_purity", 2, "evocation", "close", "will"),
"Spiritual Weapon": ("spiritual_weapon", 2, "evocation", "medium", "none"),
"Stabilize": ("stabilize", 0, "conjuration", "close", "will"),
"Status": ("status", 2, "divination", "touch", "will"),
"Stave Off Corruption": ("stave_off_corruption", 2, "abjuration", "touch", "will"),
"Summon Instrument": ("summon_instrument", 0, "conjuration", "personal", "none"),
"Summon Monster I": ("summon_monster_i", 1, "conjuration", "close", "none"),
"Suppress Charms and Compulsions": (
"suppress_charms_and_compulsions", 2, "abjuration", "close", "will",
),
"Surmount Affliction": ("surmount_affliction", 2, "abjuration", "personal", "none"),
"Tears to Wine": ("tears_to_wine", 2, "transmutation", "close", "will"),
"Touch of Fatigue": ("touch_of_fatigue", 0, "necromancy", "touch", "fort"),
"Unseen Servant": ("unseen_servant", 1, "conjuration", "close", "none"),
"Vanish": ("vanish", 1, "illusion", "touch", "will"),
"Virtue": ("virtue", 0, "transmutation", "touch", "none"),
"Weapon of Awe": ("weapon_of_awe", 2, "transmutation", "touch", "will"),
"Web": ("web", 2, "conjuration", "medium", "ref"),
}
_EFFECT_TYPES = (
DamageEffect,
ConditionEffect,
HealEffect,
BuffEffect,
AreaEffect,
SummonEffect,
)
def _walk_effects(effects: tuple[SpellEffect, ...]) -> list[SpellEffect]:
flat: list[SpellEffect] = []
for effect in effects:
flat.append(effect)
if isinstance(effect, AreaEffect):
flat.extend(_walk_effects(effect.effects))
return flat
class TestBatch3Loading:
"""Each batch-3 spell loads with the expected metadata."""
@pytest.mark.parametrize(
("name", "stem", "level", "school", "range_", "save"),
[
(name, *fields) for name, fields in sorted(_BATCH3.items())
],
)
def test_spell_fields(
self, name: str, stem: str, level: int, school: str, range_: str, save: str
) -> None:
spell = load_spell(_SPELLS_DIR / f"{stem}.json")
assert spell.name == name
assert spell.level == level
assert spell.school == school
assert spell.range == range_
assert spell.save == save
assert spell.base_dc == 10
assert spell.description
def test_registry_reaches_107(self) -> None:
reg = load_spell_registry(_SPELLS_DIR)
assert len(reg) == _BATCH2_COUNT + 32 == 107
assert set(_BATCH3) <= set(reg)
def test_every_effect_validates(self) -> None:
reg = load_spell_registry(_SPELLS_DIR)
for name in _BATCH3:
spell: SpellSpec = reg[name]
for effect in _walk_effects(spell.effects):
assert isinstance(effect, _EFFECT_TYPES)
if isinstance(effect, ConditionEffect):
assert effect.condition_name in CONDITIONS_BY_NAME
if isinstance(effect, BuffEffect):
assert effect.modifiers
if isinstance(effect, SummonEffect):
assert effect.creature
class TestFullPcSpellCoverage:
"""The registry now covers every spell name referenced by the PC sheets."""
def test_no_pc_spell_is_missing_from_the_registry(self) -> None:
reg = load_spell_registry(_SPELLS_DIR)
missing: set[tuple[str, str]] = set()
for path in sorted(_PCS_DIR.glob("*.json")):
data = json.loads(path.read_text())
for spell_name in data.get("spells", []):
if spell_name not in reg:
missing.add((path.name, spell_name))
assert not missing
+4 -4
View File
@@ -123,13 +123,13 @@ def _make_engine(
class TestSpellLoading:
"""Given: data/spells/ directory with 75 JSON spell files
"""Given: data/spells/ directory with 107 JSON spell files
When: load_spell_registry is called
Then: all 75 spells are loaded with correct fields."""
Then: all 107 spells are loaded with correct fields."""
def test_loads_all_10_spells(self) -> None:
reg = load_spell_registry(_SPELLS_DIR)
assert len(reg) == 75
assert len(reg) == 107
def test_spell_names_present(self) -> None:
reg = load_spell_registry(_SPELLS_DIR)
@@ -140,7 +140,7 @@ class TestSpellLoading:
"Summon Monster II",
}
assert expected <= set(reg)
assert len(reg) == 75
assert len(reg) == 107
def test_fireball_fields(self) -> None:
spell = load_spell(_SPELLS_DIR / "fireball.json")