use crate::static_data::EffectParameter; use crate::StringKey; use std::fmt::Debug; use std::sync::Arc; /// An ability is a passive effect in battle that is attached to a Pokemon. pub trait Ability: Debug { /// The name of the ability. fn name(&self) -> &StringKey; /// The name of the script effect of the ability. fn effect(&self) -> &StringKey; /// The parameters for the script effect of the ability. fn parameters(&self) -> &Vec>; } /// An ability is a passive effect in battle that is attached to a Pokemon. #[derive(Debug)] pub struct AbilityImpl { /// The name of the ability. name: StringKey, /// The name of the script effect of the ability. effect: StringKey, /// The parameters for the script effect of the ability. parameters: Vec>, } impl AbilityImpl { /// Instantiates a new ability. pub fn new(name: &StringKey, effect: &StringKey, parameters: Vec>) -> Self { Self { name: name.clone(), effect: effect.clone(), parameters, } } } impl Ability for AbilityImpl { /// The name of the ability. fn name(&self) -> &StringKey { &self.name } /// The name of the script effect of the ability. fn effect(&self) -> &StringKey { &self.effect } /// The parameters for the script effect of the ability. fn parameters(&self) -> &Vec> { &self.parameters } } /// An ability index allows us to find an ability on a form. It combines a bool for whether the /// ability is hidden or not, and then an index of the ability. #[derive(Copy, Clone, Debug, Eq, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[repr(C)] pub struct AbilityIndex { /// Whether or not the ability we're referring to is a hidden ability. pub hidden: bool, /// The index of the ability. pub index: u8, } #[cfg(test)] #[allow(clippy::indexing_slicing)] #[allow(clippy::unwrap_used)] pub(crate) mod tests { use super::*; mockall::mock! { #[derive(Debug)] pub Ability{} impl Ability for Ability { fn name(&self) -> &StringKey; fn effect(&self) -> &StringKey; fn parameters(&self) -> &Vec>; } } }