feat(combat): summoning
This commit is contained in:
@@ -68,8 +68,18 @@ class AreaEffect:
|
||||
effects: tuple[SpellEffect, ...] = ()
|
||||
save_for_half: bool = True
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class SummonEffect:
|
||||
"""Summoning spell effect.
|
||||
|
||||
- creature: path to the creature JSON file (e.g., "data/monsters/celestial_wolf.json")
|
||||
- duration_rounds: how long the summoned creature stays
|
||||
"""
|
||||
creature: str
|
||||
duration_rounds: int
|
||||
|
||||
SpellEffect = DamageEffect | ConditionEffect | HealEffect | BuffEffect | AreaEffect
|
||||
|
||||
SpellEffect = DamageEffect | ConditionEffect | HealEffect | BuffEffect | AreaEffect | SummonEffect
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -134,6 +144,11 @@ def _parse_effect(data: dict[str, Json]) -> SpellEffect:
|
||||
effects=tuple(_parse_effect(e) for e in data["effects"]), # type: ignore[index]
|
||||
save_for_half=bool(data.get("save_for_half", True)),
|
||||
)
|
||||
if effect_type == "summon":
|
||||
return SummonEffect(
|
||||
creature=str(data["creature"]), # type: ignore[index]
|
||||
duration_rounds=int(data["duration_rounds"]), # type: ignore[arg-type]
|
||||
)
|
||||
raise ValueError(f"Unknown effect type: {effect_type}")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user