pub struct MonsterInstance<P: MonsterProvider> {
pub species: P::SpeciesId,
pub level: u8,
pub exp: u32,
pub genetics: P::Genetics,
pub training: P::Training,
pub stats: StatSet<P>,
pub current_hp: u16,
pub status: MonsterStatus,
pub moves: Vec<MoveSlot<P>>,
}Expand description
A generic monster instance: species, level, exp, computed stats, status, and
known moves. All numbers are delegated to the MonsterProvider.
Fields§
§species: P::SpeciesIdThe species.
level: u8Current level.
exp: u32Total accumulated experience.
genetics: P::GeneticsPer-instance genetics (opaque to the engine).
training: P::TrainingAccumulated training (opaque to the engine).
stats: StatSet<P>Cached computed stats, keyed by the provider’s stat order.
current_hp: u16Current HP.
status: MonsterStatusStatus condition.
moves: Vec<MoveSlot<P>>Known moves.
Implementations§
Source§impl<P: MonsterProvider> MonsterInstance<P>
impl<P: MonsterProvider> MonsterInstance<P>
Sourcepub fn new(
provider: &P,
species: P::SpeciesId,
level: u8,
genetics: P::Genetics,
training: P::Training,
) -> Self
pub fn new( provider: &P, species: P::SpeciesId, level: u8, genetics: P::Genetics, training: P::Training, ) -> Self
Construct at a level. The caller supplies genetics/training; stats are
computed from the provider and current_hp is initialized to full.
Sourcepub fn recalc_stats(&mut self, provider: &P)
pub fn recalc_stats(&mut self, provider: &P)
Recompute every stat from the provider.
Preserves the absolute current_hp, clamped to the new max HP (this
matches Gen-1 recalculation behavior, where current HP is not scaled
by ratio on a stat recompute).
Sourcepub fn is_fainted(&self) -> bool
pub fn is_fainted(&self) -> bool
Whether the monster has fainted (0 HP).
Source§impl<P: ExpProvider> MonsterInstance<P>
impl<P: ExpProvider> MonsterInstance<P>
Sourcepub fn gain_exp(&mut self, provider: &P, amount: u32) -> LevelUp<P>
pub fn gain_exp(&mut self, provider: &P, amount: u32) -> LevelUp<P>
Add EXP, advancing level while the threshold for the next level is met.
Recomputes stats on each level gained. Caps at the provider’s
ExpProvider::max_level. Returns a summary of what happened.
Note: the engine drives the mechanism (cross thresholds, recalc). Any
game-specific quirks (e.g. the Gen-1 experience underflow) live in the
game’s ExpProvider::exp_for_level implementation and in how the game
chooses to call this method.
Source§impl<P: EvolutionProvider> MonsterInstance<P>
impl<P: EvolutionProvider> MonsterInstance<P>
Sourcepub fn try_evolve(
&mut self,
provider: &P,
trigger: EvolutionTrigger<P::EvoItem>,
) -> Option<P::SpeciesId>
pub fn try_evolve( &mut self, provider: &P, trigger: EvolutionTrigger<P::EvoItem>, ) -> Option<P::SpeciesId>
If the provider says we evolve, switch species and recalc stats.
Returns the new species id if evolution happened, otherwise None
(the provider returning None is how evolution is canceled).
Source§impl<P: MonsterProvider> MonsterInstance<P>
impl<P: MonsterProvider> MonsterInstance<P>
Sourcepub fn to_battler<B, FS, FM, FST>(
&self,
provider: &P,
map_species: FS,
map_move: FM,
map_stat: FST,
) -> BattlerState<B>
pub fn to_battler<B, FS, FM, FST>( &self, provider: &P, map_species: FS, map_move: FM, map_stat: FST, ) -> BattlerState<B>
Build a BattlerState snapshot for the battle engine.
This is the seam the later battle-migration milestone builds on. The
engine’s BattlerState is generic over a single BattleProvider
B, whose associated Species / Move / Stat types are independent
of this monster’s MonsterProvider. To stay fully game-agnostic the
caller supplies the conversions:
map_species:P::SpeciesId -> B::Speciesmap_move:P::MoveId -> B::Movemap_stat:P::Stat -> B::Stat
Stat stages start neutral, status defaults to None, and the live HP /
level / species / stats / moves are carried over. Status is intentionally
not mapped here (it is a battle-provider-defined Option<B::Status>);
the caller can set bs.status afterwards if needed. This keeps the
mapping total and the engine decoupled from any concrete status model.
Trait Implementations§
Source§impl<P: Clone + MonsterProvider> Clone for MonsterInstance<P>
impl<P: Clone + MonsterProvider> Clone for MonsterInstance<P>
Source§fn clone(&self) -> MonsterInstance<P>
fn clone(&self) -> MonsterInstance<P>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more