Skip to main content

Event

Enum Event 

Source
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.

Trait Implementations§

Source§

impl Clone for Event

Source§

fn clone(&self) -> Event

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Event

Source§

impl Debug for Event

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Event

Source§

impl Hash for Event

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Event

Source§

fn eq(&self, other: &Event) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Event

Auto Trait Implementations§

§

impl Freeze for Event

§

impl RefUnwindSafe for Event

§

impl Send for Event

§

impl Sync for Event

§

impl Unpin for Event

§

impl UnsafeUnpin for Event

§

impl UnwindSafe for Event

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.