fix(rules): dirty trick RAW list extended to shaken and sickened (APG), with runtime validation

This commit is contained in:
2026-09-16 20:16:35 +02:00
parent 2b5920c85c
commit 06da519fc6
3 changed files with 75 additions and 6 deletions
+19 -2
View File
@@ -151,7 +151,9 @@ if TYPE_CHECKING:
from pf1e_simulator.rng import Rng
from pf1e_simulator.spells import SpellSpec
TrickCondition = Literal["dazzled", "blinded", "deafened", "entangled"]
TrickCondition = Literal[
"dazzled", "blinded", "deafened", "entangled", "shaken", "sickened"
]
ReadyTrigger = Literal[
"enemy_enters_reach", "enemy_casts", "enemy_attacks", "enemy_hits_ally"
@@ -268,6 +270,11 @@ _RUN_SPEED_FACTOR = 4 # PF1e: running is a full-round action at 4x speed
_OVERRUN_PRONE_MARGIN = 5 # PF1e: overrun knocks prone only on a 5+ CMB margin
_BULL_RUSH_EXTRA_PER_MARGIN = 5 # PF1e: +5 ft push per 5 points above CMD
_DIRTY_TRICK_EXTRA_ROUND_MARGIN = 5 # PF1e APG: +1 round per 5 points above CMD
# PF1e (APG "Dirty Trick"): "The penalty is limited to one of the following
# conditions: blinded, dazzled, deafened, entangled, shaken, or sickened."
_DIRTY_TRICK_CONDITIONS: frozenset[str] = frozenset(
{"blinded", "dazzled", "deafened", "entangled", "shaken", "sickened"}
)
_REPOSITION_EXTRA_PER_MARGIN = 5 # PF1e APG: +5 ft move per 5 points above CMD
_DRAG_EXTRA_PER_MARGIN = 5 # PF1e APG: +5 ft drag per 5 points above CMD
_TRIP_RETALIATION_MARGIN = 10 # PF1e: trip failing by 10+ knocks the attacker prone
@@ -5102,12 +5109,22 @@ class CombatEngine:
target: CombatantState,
m: _ManeuverRoll,
*,
trick_condition: TrickCondition | None = None,
trick_condition: str | None = None,
) -> None:
# ``trick_condition`` is typed ``str`` here (not the TrickCondition
# Literal) because the APG RAW list is enforced at RUNTIME by
# ``_DIRTY_TRICK_CONDITIONS`` — untrusted policy payloads must be
# rejected, not just statically annotated away.
if not m.success:
self._maneuver_fail(state, target, "dirty_trick", m)
return
condition_name = trick_condition or "dazzled"
if condition_name not in _DIRTY_TRICK_CONDITIONS:
self._log(
f"round {self._current_round} {state.combatant.id}: "
f"dirty trick unknown condition {condition_name!r}"
)
return
condition = CONDITIONS_BY_NAME[condition_name]
# PF1e (APG Dirty Trick): "This condition lasts for 1 round. For
# every 5 by which your attack exceeds your opponent's CMD, the