pub struct StackDriver;Expand description
The stateless stack-based turn driver (design §2).
Implementations§
Source§impl StackDriver
impl StackDriver
Sourcepub fn execute_turn<P: EffectProvider>(
provider: &P,
state: &mut BattleState<P>,
effects: &mut Vec<EffectState<P>>,
actions: [BattleAction<P>; 2],
rng: &mut dyn BattleRng,
) -> StackTurnResult
pub fn execute_turn<P: EffectProvider>( provider: &P, state: &mut BattleState<P>, effects: &mut Vec<EffectState<P>>, actions: [BattleAction<P>; 2], rng: &mut dyn BattleRng, ) -> StackTurnResult
Execute exactly one full battle turn.
actions[0] is the player’s chosen action, actions[1] the opponent’s.
effects is the live per-effect-state arena (kept sorted by id); the
driver does not allocate it so per-turn state (toxic counters, …)
persists across turns.
The firing sequence (design §2):
- resolve order → speed-tie draw (via
turn_order_key) - for actor in [first, second]:
a.
BeforeMovegate (may abort — status draws here) b. if it acts:ModifyCritRatio(+crit draw) →Accuracy(+acc draw) →ModifyDamage(+dmg roll) →Damage/DamagingHitc. fireResidual+ faint-check FOR THIS ACTOR (per-mover) d. if this actor’s residual KO’d it, or the move KO’d the defender → STOP (cancel the second move)
Sourcepub fn execute_turn_logged<P: EffectProvider>(
provider: &P,
state: &mut BattleState<P>,
effects: &mut Vec<EffectState<P>>,
actions: [BattleAction<P>; 2],
rng: &mut dyn BattleRng,
) -> (StackTurnResult, TurnLog<P>)
pub fn execute_turn_logged<P: EffectProvider>( provider: &P, state: &mut BattleState<P>, effects: &mut Vec<EffectState<P>>, actions: [BattleAction<P>; 2], rng: &mut dyn BattleRng, ) -> (StackTurnResult, TurnLog<P>)
Like execute_turn but also returns a generic
TurnLog narrating the turn (move used / miss / crit / damage / heal /
status / stat change / faint, in order) for a frontend to render.
ADDITIVE + DEFAULTED: this runs the SAME turn as execute_turn — the
identical rng draw order and identical final BattleState — and merely
records a structural before/after diff at the driver’s existing event sites.
execute_turn is execute_turn_logged with the log discarded; the no-log
path is byte-identical (it allocates nothing and observes nothing).