Skip to main content

Module ctx

Module ctx 

Source
Expand description

The effect provider, per-effect state arena, per-move scratch, and the split-borrow BattleCtx (design §3).

The borrow-checker crux: never hand a handler &mut BattleState plus borrowed battler refs. Instead, hand it a BattleCtx of split accessors and resolve via the relay fold (the dispatch loop in dispatch owns iteration and re-borrows per step).

Structs§

BattleCtx
Split-borrow context handed to every handler (design §3.2). A handler’s only mutable path into the battle is through this struct’s accessors.
EffectState
One live effect’s mutable per-instance state, held in an arena keyed by id (design §3.1). kind is the game’s typed counter enum, so the compiler checks every counter (no positional slot bag).
MoveContext
Per-move scratch shared across a move’s event chain (design §3.2): the crit flag, the rolled damage, the miss flag, and the last damage dealt (the canonical home for Counter/Bide reads — design §9 open question).

Enums§

EffectHost
Where an effect is hosted (design §3.1, the broadened addressing). A cross-gen battle hosts effects not only on a battler (volatiles, ability, item) but on a side (screens, hazards, Wish) or the field (weather, terrain, Trick Room). EffectHost is the 3-way scope the engine routes by.

Traits§

EffectProvider
The game’s effect registry, extending BattleProvider (design §1.5).