Removes derive-getters, as it was incredibly annoying in IDEs, and couldn't figure out borrow lifetimes.
This commit is contained in:
@@ -1,7 +1,16 @@
|
||||
use crate::defines::LevelInt;
|
||||
use derive_getters::Getters;
|
||||
|
||||
#[derive(Getters, Debug)]
|
||||
#[derive(Debug)]
|
||||
pub struct LibrarySettings {
|
||||
pub(crate) maximum_level: LevelInt,
|
||||
maximum_level: LevelInt,
|
||||
}
|
||||
|
||||
impl LibrarySettings {
|
||||
pub fn new(maximum_level: LevelInt) -> Self {
|
||||
Self { maximum_level }
|
||||
}
|
||||
|
||||
pub fn maximum_level(&self) -> LevelInt {
|
||||
self.maximum_level
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ pub mod tests {
|
||||
let r = &lib;
|
||||
let mon = r.get("foo");
|
||||
assert!(mon.is_some());
|
||||
assert_eq!(*mon.unwrap().id(), 0_u16);
|
||||
assert_eq!(mon.unwrap().id(), 0_u16);
|
||||
assert_eq!(mon.unwrap().as_ref().name(), "foo");
|
||||
assert_eq!(r.len(), 1);
|
||||
}
|
||||
|
||||
@@ -5,9 +5,8 @@ use crate::static_data::libraries::move_library::MoveLibrary;
|
||||
use crate::static_data::libraries::species_library::SpeciesLibrary;
|
||||
use crate::static_data::libraries::type_library::TypeLibrary;
|
||||
use crate::static_data::natures::NatureLibrary;
|
||||
use derive_getters::Getters;
|
||||
|
||||
#[derive(Getters, Debug)]
|
||||
#[derive(Debug)]
|
||||
pub struct StaticData<'a> {
|
||||
settings: LibrarySettings,
|
||||
species: SpeciesLibrary<'a>,
|
||||
@@ -18,6 +17,50 @@ pub struct StaticData<'a> {
|
||||
natures: NatureLibrary,
|
||||
}
|
||||
|
||||
impl<'a> StaticData<'a> {
|
||||
pub fn new(
|
||||
settings: LibrarySettings,
|
||||
species: SpeciesLibrary<'a>,
|
||||
moves: MoveLibrary,
|
||||
items: ItemLibrary,
|
||||
growth_rates: GrowthRateLibrary,
|
||||
types: TypeLibrary,
|
||||
natures: NatureLibrary,
|
||||
) -> Self {
|
||||
Self {
|
||||
settings,
|
||||
species,
|
||||
moves,
|
||||
items,
|
||||
growth_rates,
|
||||
types,
|
||||
natures,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn settings(&self) -> &LibrarySettings {
|
||||
&self.settings
|
||||
}
|
||||
pub fn species(&self) -> &SpeciesLibrary<'a> {
|
||||
&self.species
|
||||
}
|
||||
pub fn moves(&self) -> &MoveLibrary {
|
||||
&self.moves
|
||||
}
|
||||
pub fn items(&self) -> &ItemLibrary {
|
||||
&self.items
|
||||
}
|
||||
pub fn growth_rates(&self) -> &GrowthRateLibrary {
|
||||
&self.growth_rates
|
||||
}
|
||||
pub fn types(&self) -> &TypeLibrary {
|
||||
&self.types
|
||||
}
|
||||
pub fn natures(&self) -> &NatureLibrary {
|
||||
&self.natures
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod test {
|
||||
use crate::static_data::libraries::library_settings::LibrarySettings;
|
||||
@@ -29,7 +72,7 @@ pub mod test {
|
||||
|
||||
pub fn build<'a>() -> StaticData<'a> {
|
||||
StaticData {
|
||||
settings: LibrarySettings { maximum_level: 100 },
|
||||
settings: LibrarySettings::new(100),
|
||||
species: species_library::tests::build(),
|
||||
moves: move_library::tests::build(),
|
||||
items: item_library::tests::build(),
|
||||
|
||||
Reference in New Issue
Block a user