This commit is contained in:
@@ -29,12 +29,8 @@ impl AbilityLibraryImpl {
|
||||
impl AbilityLibrary for AbilityLibraryImpl {}
|
||||
|
||||
impl DataLibrary<dyn Ability> for AbilityLibraryImpl {
|
||||
fn map(&self) -> &IndexMap<StringKey, Arc<dyn Ability>> {
|
||||
&self.map
|
||||
}
|
||||
fn get_modify(&mut self) -> &mut IndexMap<StringKey, Arc<dyn Ability>> {
|
||||
&mut self.map
|
||||
}
|
||||
fn map(&self) -> &IndexMap<StringKey, Arc<dyn Ability>> { &self.map }
|
||||
fn get_modify(&mut self) -> &mut IndexMap<StringKey, Arc<dyn Ability>> { &mut self.map }
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -45,6 +41,7 @@ pub mod tests {
|
||||
use crate::static_data::AbilityImpl;
|
||||
use crate::static_data::DataLibrary;
|
||||
use crate::StringKey;
|
||||
use hashbrown::HashMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub fn build() -> AbilityLibraryImpl {
|
||||
@@ -54,7 +51,7 @@ pub mod tests {
|
||||
Arc::new(AbilityImpl::new(
|
||||
&"test_ability".into(),
|
||||
&"test_ability".into(),
|
||||
Vec::new(),
|
||||
HashMap::new(),
|
||||
)),
|
||||
);
|
||||
lib
|
||||
|
||||
@@ -38,17 +38,11 @@ impl SecondaryEffectImpl {
|
||||
|
||||
impl SecondaryEffect for SecondaryEffectImpl {
|
||||
/// The chance in percentages that the effect triggers. -1 to make it always trigger.
|
||||
fn chance(&self) -> f32 {
|
||||
self.chance
|
||||
}
|
||||
fn chance(&self) -> f32 { self.chance }
|
||||
/// The name of the effect.
|
||||
fn effect_name(&self) -> &StringKey {
|
||||
&self.effect_name
|
||||
}
|
||||
fn effect_name(&self) -> &StringKey { &self.effect_name }
|
||||
/// A list of parameters for the effect.
|
||||
fn parameters(&self) -> &HashMap<StringKey, Arc<Parameter>> {
|
||||
&self.parameters
|
||||
}
|
||||
fn parameters(&self) -> &HashMap<StringKey, Arc<Parameter>> { &self.parameters }
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -67,17 +61,17 @@ pub(crate) mod tests {
|
||||
impl SecondaryEffect for SecondaryEffect {
|
||||
fn chance(&self) -> f32;
|
||||
fn effect_name(&self) -> &StringKey;
|
||||
fn parameters(&self) -> &Vec<Arc<Parameter >>;
|
||||
fn parameters(&self) -> &HashMap<StringKey, Arc<Parameter >>;
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_secondary_effect() {
|
||||
let empty = SecondaryEffectImpl::new(0.0, "".into(), vec![]);
|
||||
let empty = SecondaryEffectImpl::new(0.0, "".into(), HashMap::new());
|
||||
assert_approx_eq!(empty.chance(), 0.0);
|
||||
assert_eq!(empty.effect_name(), &"".into());
|
||||
assert_eq!(empty.parameters().len(), 0);
|
||||
let set = SecondaryEffectImpl::new(50.0, "foo".into(), Vec::new());
|
||||
let set = SecondaryEffectImpl::new(50.0, "foo".into(), HashMap::new());
|
||||
assert_approx_eq!(set.chance(), 50.0);
|
||||
assert_eq!(set.effect_name(), &"foo".into());
|
||||
assert_eq!(set.parameters().len(), 0);
|
||||
|
||||
@@ -69,7 +69,7 @@ pub(crate) mod tests {
|
||||
impl Ability for Ability {
|
||||
fn name(&self) -> &StringKey;
|
||||
fn effect(&self) -> &StringKey;
|
||||
fn parameters(&self) -> &Vec<Arc<Parameter >>;
|
||||
fn parameters(&self) -> &HashMap<StringKey, Arc<Parameter >>;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ use serde::{Deserialize, Serialize};
|
||||
/// Stats are numerical values on Pokemon that are used in battle.
|
||||
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[cfg_attr(feature = "rune", derive(rune::Any))]
|
||||
#[repr(u8)]
|
||||
pub enum Statistic {
|
||||
/// Health Points determine how much damage a Pokemon can receive before fainting.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/// The time of day. These values are the 4 different groups of time of day in Pokemon games since
|
||||
/// gen 5. The exact times these correspond to differ between games.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "rune", derive(rune::Any))]
|
||||
#[repr(u8)]
|
||||
pub enum TimeOfDay {
|
||||
/// The morning.
|
||||
|
||||
Reference in New Issue
Block a user