fix(combat): apply save negates to targeted spell damage effects

This commit is contained in:
2026-09-05 12:52:58 +02:00
parent cd75a4f2bf
commit 7cb3653750
4 changed files with 100 additions and 10 deletions
+6 -1
View File
@@ -2077,7 +2077,12 @@ class CombatEngine:
raw = effect.formula.roll(self._rng)
if maximize:
raw = effect.formula.max_value()
dmg = max(0, raw // 2) if saved and effect.half_on_save else raw
if saved and effect.half_on_save:
dmg = max(0, raw // 2)
elif saved:
dmg = 0
else:
dmg = raw
if empower:
dmg = int(dmg * 1.5)
target.hp -= dmg
+3 -2
View File
@@ -35,7 +35,8 @@ SaveType = Literal["fort", "ref", "will", "none"]
class DamageEffect:
formula: DiceExpr
types: tuple[str, ...]
half_on_save: bool = True
# False = save negates (targeted); True = half damage on save (ray/line/cone/AoE)
half_on_save: bool = False
@dataclass(frozen=True)
@@ -216,7 +217,7 @@ def _parse_effect(data: Json) -> SpellEffect:
return DamageEffect(
formula=parse_dice(_as_str(effect["formula"])),
types=tuple(_as_str(t) for t in _as_list(effect["types"])),
half_on_save=bool(effect.get("half_on_save", True)),
half_on_save=bool(effect.get("half_on_save", False)),
)
if effect_type == "condition":
return ConditionEffect(