pub enum Event {
Show 34 variants
BeforeTurn,
ResidualOrder,
AfterTurn,
BeforeMove,
ModifyMove,
ModifyType,
ModifyCritRatio,
Accuracy,
Invulnerability,
ModifyDamage,
Effectiveness,
AfterMove,
TryHit,
Damage,
DamagingHit,
Heal,
AfterFaint,
TrySetStatus,
AfterSetStatus,
TryBoost,
AfterBoost,
ModifyStat,
WeatherModifyStat,
Start,
End,
Faint,
SwitchIn,
SwitchOut,
SetWeather,
FieldResidual,
SideResidual,
OnMiss,
Residual,
Custom(u16),
}Expand description
The closed taxonomy of dispatch kinds (design §1.1, broadened §1.4).
Events are an enum of keys with no payload — the payload rides in a
typed RelayVar threaded through the fold. A closed enum (not a
string-keyed bus) keeps the comparator and the parity tests auditable, which
the Gen-1 quirks demand; Event::Custom is the open tail so a game is
never blocked by the closed set.
Grouped per design §1.2. Variants beyond the POC’s BeforeMove/
ModifyCritRatio/Accuracy/ModifyDamage/Damage/DamagingHit/Residual
are present as subscription seams — inert until a driver extension fires
them.
Variants§
BeforeTurn
After speed-sort settled, before each move resolves.
ResidualOrder
End-of-turn batch ordering (weather tick → status tick → leftovers → …); drives the Gen-2+ end-of-turn sequence.
AfterTurn
Post-residual cleanup (Gen-5 form reset, counters).
BeforeMove
Pre-move status gate (sleep/freeze/trap/flinch/recharge/confusion/para/ Truant) — the veto point. In the POC slice, paralysis full-para is gated here.
ModifyMove
Mutate the move in flight (multi-hit count, type override, Normalize).
ModifyType
Per-hit type override (Pixilate/Aerilate, Hidden Power) — split from
ModifyMove because abilities re-type after the move’s own type pick.
ModifyCritRatio
Numeric fold producing the critical-hit threshold (Focus Energy /4,
high-crit ×8, Super Luck, Razor Claw). Crit is drawn here — before
Accuracy (design §4).
Accuracy
Accuracy fold returning a 0..=255 INT (the Gen-1 1/256 miss; Compound
Eyes, Hustle, Sand Veil).
Invulnerability
Fly/Dig/Dive/Bounce gate; fast_exit veto.
ModifyDamage
Numeric fold scaling the final damage (the damage roll lands here; Life Orb, weather boost, STAB-via-Adaptability).
Effectiveness
Type-effectiveness fold (Gen-1 immunity-as-miss; Levitate, Scrappy, Tinted Lens, Wonder Guard).
AfterMove
Per-action cleanup (Hyper Beam recharge set, Life Orb recoil, Rocky Helmet contact damage via the contact flag).
TryHit
Pre-damage interception veto (Substitute swap-target, Protect/Detect, Magic Bounce redirect).
Damage
Damage-application fold (Substitute absorb, Disguise, Endure/Sturdy floor-to-1).
DamagingHit
A hit connected — secondary-effect + reactive fire-point (Counter/Bide read, Static/Flame Body, recoil, drain).
Heal
Healing fold (Heal Block veto, Big Root item boost).
AfterFaint
Post-KO (Moxie/Beast Boost, Aftermath, Destiny Bond resolution).
TrySetStatus
Veto setting a non-volatile status (type immunity, Immunity/Limber, Safeguard, Substitute block).
AfterSetStatus
Status applied (Synchronize, Toxic Orb self-status).
TryBoost
Veto/modify a stat-stage change (Clear Body, Hyper Cutter, White Smoke).
AfterBoost
Stat change applied (Defiant/Competitive).
ModifyStat
Persistent stat fold for the damage-formula reads (Huge Power, Choice
Band, para ÷4 speed, burn ÷2 atk) — one fold parameterized by P::Stat.
WeatherModifyStat
Weather/ability stat multipliers that layer after ModifyStat (Sand
Force, Chlorophyll, Swift Swim).
Start
An effect was added to a host (volatile applied; ability/item attached on switch-in).
End
An effect was removed (volatile expired → Thrash self-confuse; item consumed).
Faint
A battler fainted.
SwitchIn
A battler entered — the cross-gen ability/item/hazard fire-point (Intimidate, Drizzle, Stealth Rock damage, Toxic Spikes).
SwitchOut
A battler is leaving (Regenerator, Natural Cure, pursuit, Baton Pass).
SetWeather
Veto/replace a weather change (Air Lock/Cloud Nine suppress, Damp Rock duration).
FieldResidual
Field-hosted end-of-turn tick (weather chip damage, Trick Room countdown, terrain).
SideResidual
Side-hosted end-of-turn tick (Spikes, Wish, Reflect/Light Screen countdown).
OnMiss
Accuracy-miss reaction (the one true Gen-1 core touch, blueprint 15
§3). Fired by the StackDriver on the
accuracy-miss branch — the point where a move whiffed. Gen-1 Jump Kick /
Hi Jump Kick crash the user for 1 HP here. Additive + DEFAULTED: the
driver fires it through the move’s own effect, so it is INERT for a move
(and a game) that registers no OnMiss hook — every existing slice/game
collects zero handlers for it, so the fold is a no-op and consumed() /
the byte stream are byte-identical. (Custom could not serve this: the
fire-point is INSIDE the driver’s miss branch, which only the engine drives.)
Residual
PER-MOVER end-of-action residual (burn/psn/toxic → leech). Order is load-bearing (design §6 #7).
The §1.4 taxonomy folds this into ResidualOrder/FieldResidual/
SideResidual, but the 88 Gen-1 stack-parity slices fire Residual
directly — it is kept as an existing variant so those slices compile and
pass unchanged (the additive/non-breaking constraint trumps the
rename). New games should prefer the §1.4 kinds.
Custom(u16)
Game-defined dispatch key. The engine dispatches it like any other event (collect → sort → fold) but assigns it no built-in meaning — a game’s driver extension fires it. Lets a game add an interaction point WITHOUT an engine change, at the cost of the closed-set audit guarantee for that key.