More work on switching battle data to interior mutability, instead of exterior mutability.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -45,7 +45,7 @@ pub struct MoveData {
|
||||
base_usages: u8,
|
||||
target: MoveTarget,
|
||||
priority: i8,
|
||||
secondary_effect: SecondaryEffect,
|
||||
secondary_effect: Option<SecondaryEffect>,
|
||||
flags: HashSet<StringKey>,
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ impl MoveData {
|
||||
base_usages: u8,
|
||||
target: MoveTarget,
|
||||
priority: i8,
|
||||
secondary_effect: SecondaryEffect,
|
||||
secondary_effect: Option<SecondaryEffect>,
|
||||
flags: HashSet<StringKey>,
|
||||
) -> MoveData {
|
||||
MoveData {
|
||||
@@ -102,14 +102,10 @@ impl MoveData {
|
||||
self.priority
|
||||
}
|
||||
|
||||
pub fn secondary_effect(&self) -> &SecondaryEffect {
|
||||
pub fn secondary_effect(&self) -> &Option<SecondaryEffect> {
|
||||
&self.secondary_effect
|
||||
}
|
||||
|
||||
pub fn has_secondary_effect(&self) -> bool {
|
||||
self.secondary_effect.effect_name() != &StringKey::empty()
|
||||
}
|
||||
|
||||
pub fn has_flag(&self, key: &StringKey) -> bool {
|
||||
self.flags.contains(key)
|
||||
}
|
||||
|
||||
@@ -16,13 +16,6 @@ pub struct SecondaryEffect {
|
||||
}
|
||||
|
||||
impl SecondaryEffect {
|
||||
pub fn empty() -> SecondaryEffect {
|
||||
SecondaryEffect {
|
||||
chance: 0.0,
|
||||
effect_name: StringKey::empty(),
|
||||
parameters: vec![],
|
||||
}
|
||||
}
|
||||
pub fn new(chance: f32, effect_name: StringKey, parameters: Vec<EffectParameter>) -> SecondaryEffect {
|
||||
SecondaryEffect {
|
||||
chance,
|
||||
@@ -49,7 +42,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn create_secondary_effect() {
|
||||
let empty = SecondaryEffect::empty();
|
||||
let empty = SecondaryEffect::new(0.0, "".into(), vec![]);
|
||||
assert_approx_eq!(empty.chance(), 0.0);
|
||||
assert_eq!(empty.effect_name(), &"".into());
|
||||
assert_eq!(empty.parameters().len(), 0);
|
||||
|
||||
Reference in New Issue
Block a user