Expand description
Event taxonomy, handler signature, and effect registration types for the Showdown-style effect-stack battle engine (design doc §1).
Everything here is 100% game-agnostic: no game-specific concrete
types appear. The game registers Effects carrying HandlerFn pointers via
the EffectProvider trait.
§The broadened taxonomy (design §1, P0b)
The enum below is the multi-gen authoring surface (design §1.4): the 6
groups / 31 kinds + the Custom(u16) escape hatch + the legacy Residual
kept for the Gen-1 slices (see the note on Residual). Adding a variant is a
non-breaking engine change: handlers subscribe by listing
EventHook { event: Event::X, .. } and never match the whole enum — the
only exhaustive matches live inside the engine driver, which we control. So
growing this enum only offers new subscription points; it forces no
existing handler or game to change. Kinds the engine driver does not yet
fire are simply never collected for, hence inert (zero behavioral change),
exactly as Start/End/Faint were in the POC.
Structs§
- Effect
- An effect = id/type + a sparse table of hooks (design §1.5). Moves,
statuses, abilities, items all share this shape (Showdown’s
BasicEffect). The hook table is'staticso registrations are zero-alloc constants. - Effect
Id - An effect identifier. The engine treats it opaquely; the game assigns ids to
moves/statuses/volatiles. Used as the binary-search key into the
EffectStatearena and to address handlersource_effect. - Event
Hook - One
(Event → HandlerFn)subscription with its ordering metadata (design §1.5).order/priority/sub_ordermirror Showdown’son<Event>Order/on<Event>Priority/ effect-type sub-order.
Enums§
- Effect
Type - The effect category, feeding the comparator’s
sub_orderdefault (design §1.3). Gen-1 leaves this defaulting; kept for generality. - Event
- The closed taxonomy of dispatch kinds (design §1.1, broadened §1.4).
- Handler
Result - The verdict a handler returns, mirroring Showdown’s
undefined / value / false / null(design §1.2). - Relay
Var - The typed value threaded through a dispatch fold (design §1.2). Mirrors Showdown’s relay variable.
Type Aliases§
- Handler
Fn - A handler is a zero-capture
fnpointer (design §1.2): it cannot capture or alias battle state, so the only mutable path is throughctx. Per-effect counter state lives inEffectState, not a closure.