pub struct FightEngine { /* private fields */ }Expand description
Bounded, deterministic driver for fight simulations.
Implementations§
Source§impl FightEngine
impl FightEngine
pub fn new( game_config: SharedGameConfig, behaviors: Arc<BehaviorRegistry>, seed: Seed, ) -> Self
Sourcepub fn breakdown(&self, outcome: FightOutcome) -> Option<FightBreakdown>
pub fn breakdown(&self, outcome: FightOutcome) -> Option<FightBreakdown>
Per-source damage/heal breakdown of the fight this engine last ran.
The engine stops at EndFight without processing it, so the summary
never reaches OverlordState here — this is how a simulation, a PvP
precalculation or a test reads it.
Sourcepub fn start(
&mut self,
state: OverlordState,
prepare_fight_type: PrepareFightType,
) -> Result<FightSim, FightError>
pub fn start( &mut self, state: OverlordState, prepare_fight_type: PrepareFightType, ) -> Result<FightSim, FightError>
Prepare a fight on a copy of the player’s state. Any pre-existing
active_fight is discarded — the sim owns the whole fight lifecycle.
Sourcepub fn step(
&mut self,
sim: &mut FightSim,
) -> Result<Option<FightResult>, FightError>
pub fn step( &mut self, sim: &mut FightSim, ) -> Result<Option<FightResult>, FightError>
Advance the fight by exactly one game tick (100 ticker units).
Returns Some(result) once the fight has ended.
Sourcepub fn run(
&mut self,
state: OverlordState,
prepare_fight_type: PrepareFightType,
max_game_ticks: u64,
) -> Result<FightOutcome, FightError>
pub fn run( &mut self, state: OverlordState, prepare_fight_type: PrepareFightType, max_game_ticks: u64, ) -> Result<FightOutcome, FightError>
Run the fight to completion, executing at most max_game_ticks steps.
Total by construction: always returns, with FightResult::Undecided
when the budget is exhausted.
Sourcepub fn run_prepared(
&mut self,
sim: &mut FightSim,
max_game_ticks: u64,
) -> Result<FightOutcome, FightError>
pub fn run_prepared( &mut self, sim: &mut FightSim, max_game_ticks: u64, ) -> Result<FightOutcome, FightError>
Drive an already-started fight to completion.
Split out of run so a caller that must touch the prepared
state before the first step — the A2-BAL-001 calibration installing a
frozen reference build, see FightSim::state_mut — still goes through
the same bounded, deterministic loop rather than reimplementing it.