Skip to main content

StackDriver

Struct StackDriver 

Source
pub struct StackDriver;
Expand description

The stateless stack-based turn driver (design §2).

Implementations§

Source§

impl StackDriver

Source

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):

  1. resolve order → speed-tie draw (via turn_order_key)
  2. for actor in [first, second]: a. BeforeMove gate (may abort — status draws here) b. if it acts: ModifyCritRatio(+crit draw) → Accuracy(+acc draw) → ModifyDamage(+dmg roll) → Damage/DamagingHit c. fire Residual + 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)
Source

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

Auto Trait Implementations§

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