131 lines
4.1 KiB
Rust
Executable File
131 lines
4.1 KiB
Rust
Executable File
use crate::static_data::AbilityLibrary;
|
|
use crate::static_data::GrowthRateLibrary;
|
|
use crate::static_data::ItemLibrary;
|
|
use crate::static_data::LibrarySettings;
|
|
use crate::static_data::MoveLibrary;
|
|
use crate::static_data::NatureLibrary;
|
|
use crate::static_data::SpeciesLibrary;
|
|
use crate::static_data::TypeLibrary;
|
|
|
|
/// The storage for all different libraries.
|
|
#[derive(Debug)]
|
|
#[cfg_attr(feature = "wasm", derive(unique_type_id_derive::UniqueTypeId))]
|
|
pub struct StaticData {
|
|
/// Several misc settings for the library.
|
|
settings: LibrarySettings,
|
|
/// All data for Pokemon species.
|
|
species: SpeciesLibrary,
|
|
/// All data for the moves.
|
|
moves: MoveLibrary,
|
|
/// All data for the items.
|
|
items: ItemLibrary,
|
|
/// All data for growth rates.
|
|
growth_rates: GrowthRateLibrary,
|
|
/// All data related to types and type effectiveness.
|
|
types: TypeLibrary,
|
|
/// All data related to natures.
|
|
natures: NatureLibrary,
|
|
/// All data related to abilities.
|
|
abilities: AbilityLibrary,
|
|
}
|
|
|
|
impl StaticData {
|
|
/// Instantiates a new data collection.
|
|
pub fn new(settings: LibrarySettings) -> Self {
|
|
Self {
|
|
settings,
|
|
species: SpeciesLibrary::new(0),
|
|
moves: MoveLibrary::new(0),
|
|
items: ItemLibrary::new(0),
|
|
growth_rates: GrowthRateLibrary::new(0),
|
|
types: TypeLibrary::new(0),
|
|
natures: NatureLibrary::new(0),
|
|
abilities: AbilityLibrary::new(0),
|
|
}
|
|
}
|
|
/// Several misc settings for the library.
|
|
pub fn settings(&self) -> &LibrarySettings {
|
|
&self.settings
|
|
}
|
|
/// All data for Pokemon species.
|
|
pub fn species(&self) -> &SpeciesLibrary {
|
|
&self.species
|
|
}
|
|
/// All data for Pokemon species.
|
|
pub fn species_mut(&mut self) -> &mut SpeciesLibrary {
|
|
&mut self.species
|
|
}
|
|
/// All data for the moves.
|
|
pub fn moves(&self) -> &MoveLibrary {
|
|
&self.moves
|
|
}
|
|
/// All data for the moves.
|
|
pub fn moves_mut(&mut self) -> &mut MoveLibrary {
|
|
&mut self.moves
|
|
}
|
|
/// All data for the items.
|
|
pub fn items(&self) -> &ItemLibrary {
|
|
&self.items
|
|
}
|
|
/// All data for the items.
|
|
pub fn items_mut(&mut self) -> &mut ItemLibrary {
|
|
&mut self.items
|
|
}
|
|
|
|
/// All data for growth rates.
|
|
pub fn growth_rates(&self) -> &GrowthRateLibrary {
|
|
&self.growth_rates
|
|
}
|
|
/// All data for growth rates.
|
|
pub fn growth_rates_mut(&mut self) -> &mut GrowthRateLibrary {
|
|
&mut self.growth_rates
|
|
}
|
|
/// All data related to types and type effectiveness.
|
|
pub fn types(&self) -> &TypeLibrary {
|
|
&self.types
|
|
}
|
|
/// All data related to types and type effectiveness.
|
|
pub fn types_mut(&mut self) -> &mut TypeLibrary {
|
|
&mut self.types
|
|
}
|
|
/// All data related to natures.
|
|
pub fn natures(&self) -> &NatureLibrary {
|
|
&self.natures
|
|
}
|
|
/// All data related to natures.
|
|
pub fn natures_mut(&mut self) -> &mut NatureLibrary {
|
|
&mut self.natures
|
|
}
|
|
/// All data related to abilities.
|
|
pub fn abilities(&self) -> &AbilityLibrary {
|
|
&self.abilities
|
|
}
|
|
/// All data related to abilities.
|
|
pub fn abilities_mut(&mut self) -> &mut AbilityLibrary {
|
|
&mut self.abilities
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
pub mod test {
|
|
use crate::static_data::libraries::library_settings::LibrarySettings;
|
|
use crate::static_data::libraries::static_data::StaticData;
|
|
use crate::static_data::libraries::{
|
|
ability_library, growth_rate_library, item_library, move_library, species_library, type_library,
|
|
};
|
|
use crate::static_data::natures;
|
|
|
|
pub fn build() -> StaticData {
|
|
StaticData {
|
|
settings: LibrarySettings::new(100),
|
|
species: species_library::tests::build(),
|
|
moves: move_library::tests::build(),
|
|
items: item_library::tests::build(),
|
|
growth_rates: growth_rate_library::tests::build(),
|
|
types: type_library::tests::build(),
|
|
natures: natures::tests::build(),
|
|
abilities: ability_library::tests::build(),
|
|
}
|
|
}
|
|
}
|