pub trait MonsterProvider {
type SpeciesId: Copy + Eq + Debug;
type MoveId: Copy + Eq + Debug;
type Genetics: Clone + Debug + Default + PartialEq + Eq;
type Training: Clone + Debug + Default + PartialEq + Eq;
type Stat: Copy + Eq + Debug;
// Required methods
fn base_stat(&self, species: Self::SpeciesId, stat: Self::Stat) -> u16;
fn calc_stat(
&self,
species: Self::SpeciesId,
stat: Self::Stat,
level: u8,
genetics: &Self::Genetics,
training: &Self::Training,
) -> u16;
fn stats(&self) -> &[Self::Stat];
fn hp_stat(&self) -> Self::Stat;
fn max_moves(&self) -> usize;
}Expand description
Game-supplied definition of how monsters work.
This is the master provider for the party model, analogous to
crate::GameData. It binds the game’s concrete id types and supplies the
stat-calculation hooks. The engine stores instances and drives transitions;
the game decides every number.
Required Associated Types§
Sourcetype SpeciesId: Copy + Eq + Debug
type SpeciesId: Copy + Eq + Debug
Opaque species identifier (e.g. a numeric dex id newtype/enum).
Sourcetype Genetics: Clone + Debug + Default + PartialEq + Eq
type Genetics: Clone + Debug + Default + PartialEq + Eq
Per-instance “genetics” the game uses in stat calc (Gen-1 DVs, modern
IVs). The engine treats this as opaque and just stores it. PartialEq + Eq are required so MonsterInstance / Party can derive them
(handy for round-trip identity tests and snapshot comparison).
Required Methods§
Sourcefn base_stat(&self, species: Self::SpeciesId, stat: Self::Stat) -> u16
fn base_stat(&self, species: Self::SpeciesId, stat: Self::Stat) -> u16
Base stat value for a species + stat.
Sourcefn calc_stat(
&self,
species: Self::SpeciesId,
stat: Self::Stat,
level: u8,
genetics: &Self::Genetics,
training: &Self::Training,
) -> u16
fn calc_stat( &self, species: Self::SpeciesId, stat: Self::Stat, level: u8, genetics: &Self::Genetics, training: &Self::Training, ) -> u16
Compute a single derived stat from base / level / genetics / training.
This is where the Gen-1 formula (or any other) lives — in the game.
Sourcefn hp_stat(&self) -> Self::Stat
fn hp_stat(&self) -> Self::Stat
Which Self::Stat represents HP. The engine cannot guess this, so the
game declares it; MonsterInstance::max_hp uses it.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".