Expand description
Showdown-style effect-stack battle engine (Pattern C) — vertical-slice
POC (design doc 06-battle-engine-effect-stack-design.md, §8).
This is an additive sibling to crate::battle::driver; the existing
BattleDriver and every other game’s code keep compiling unchanged. The
module is 100% game-agnostic: no game-specific concrete types, no
rand (randomness only via the existing BattleRng).
§Pieces
event— the closedEventtaxonomy,RelayVar/HandlerResult, thefn-pointerHandlerFnsignature, and theEffect/EventHookregistration shape.ctx— theEffectProvidertrait, the typedEffectStatearena, per-move scratch, and the split-borrowBattleCtx(battler_mut/pair_mut(both branches) /effect_mut).dispatch— the ShowdowncomparePrioritycomparator, the speed-tie draw, and therun_eventfold.driver— theStackDriverfiring the fixed §2 per-turn sequence with the per-mover residual + first-mover-faint short-circuit.
Re-exports§
pub use ctx::BattleCtx;pub use ctx::EffectHost;pub use ctx::EffectProvider;pub use ctx::EffectState;pub use ctx::MoveContext;pub use dispatch::collect_handlers;pub use dispatch::compare;pub use dispatch::run_event;pub use dispatch::run_event_checked;pub use dispatch::CollectedHandler;pub use driver::FirstMover;pub use driver::StackDriver;pub use driver::StackTurnResult;pub use log::HpChangeCause;pub use log::TurnEvent;pub use log::TurnLog;pub use event::Effect;pub use event::EffectId;pub use event::EffectType;pub use event::Event;pub use event::EventHook;pub use event::HandlerFn;pub use event::HandlerResult;pub use event::RelayVar;
Modules§
- authoring
- Developer-facing effect-authoring helpers (design §4.1).
- ctx
- The effect provider, per-effect state arena, per-move scratch, and the
split-borrow
BattleCtx(design §3). - dispatch
- Handler collection, the Showdown
comparePrioritycomparator, the speed-tie draw, and therun_eventdispatch fold (design §1.3, §3.4). - driver
- The
StackDriver— the fixed per-turn firing sequence (design §2). - event
- Event taxonomy, handler signature, and effect registration types for the Showdown-style effect-stack battle engine (design doc §1).
- log
- P6a — a generic, additive per-turn event log for stack-driven battles.