Skip to main content

MonsterProvider

Trait MonsterProvider 

Source
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§

Source

type SpeciesId: Copy + Eq + Debug

Opaque species identifier (e.g. a numeric dex id newtype/enum).

Source

type MoveId: Copy + Eq + Debug

Opaque move identifier.

Source

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

Source

type Training: Clone + Debug + Default + PartialEq + Eq

Accumulated training data (Gen-1 stat-exp, modern EVs). Opaque to the engine.

Source

type Stat: Copy + Eq + Debug

The set of stats this game uses. Must be index-mappable / comparable.

Required Methods§

Source

fn base_stat(&self, species: Self::SpeciesId, stat: Self::Stat) -> u16

Base stat value for a species + stat.

Source

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.

Source

fn stats(&self) -> &[Self::Stat]

All stats the game iterates over (for full recalculation).

Source

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.

Source

fn max_moves(&self) -> usize

Max number of moves a monster can know (Gen-1 = 4).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§