Expand description
Generic, game-agnostic battle turn-execution driver (P0b).
BattleDriver::execute_turn sits above the existing
BattleProvider/BattlerState/BattleState
abstraction and owns the control flow of a single battle turn:
- Ask the provider for each actor’s
OrderKeyand stable-sort them ascending (turn order — C4). - For each actor in order: run the
before_movepre-move status gate, then execute its action — forFight, anaccuracy_checkfollowed bycalculate_damage; forSwitch,apply_switch. Faints are detected after each hit. - Run the
end_of_turnresidual hook. - Fold everything into a
TurnOutcomeand detect aBattleEnd.
Every number and rule decision (the damage formula, accuracy/crit math,
status semantics, residual ordering, turn-order tie-breaks) lives in the
provider; the driver only sequences. All randomness is injected through
BattleRng so the engine never links rand and the game controls the
exact draw sequence (C2).
The driver is event-sourced: it returns a Vec<TurnEvent> that the
game maps onto its own UI/animation state machine, keeping rendering out of
the engine and making the driver unit-testable without a screen.
Structs§
- Battle
Driver - The generic turn-execution driver. Stateless: state goes in, events come out.
- Turn
Outcome - The result of executing one turn.