Rework of FFI, adding a value identifier, so we can keep knowledge of data even when data moves.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-10-08 13:15:04 +02:00
parent 84ddf0307d
commit 41b40ef98e
38 changed files with 582 additions and 230 deletions

View File

@@ -1,9 +1,13 @@
use crate::static_data::Statistic;
use crate::{ValueIdentifiable, ValueIdentifier};
use std::sync::Arc;
/// A nature is an attribute on a Pokemon that modifies the effective base stats on a Pokemon. They
/// can have an increased statistic and a decreased statistic, or be neutral.
#[derive(Debug)]
pub struct Nature {
/// A unique identifier so we know what value this is.
identifier: ValueIdentifier,
/// The stat that should receive the increased modifier.
increase_stat: Statistic,
/// The stat that should receive the decreased modifier.
@@ -21,13 +25,14 @@ impl Nature {
decrease_stat: Statistic,
increase_modifier: f32,
decrease_modifier: f32,
) -> Self {
Self {
) -> Arc<Self> {
Arc::new(Self {
identifier: Default::default(),
increase_stat,
decrease_stat,
increase_modifier,
decrease_modifier,
}
})
}
/// The stat that should receive the increased modifier.
@@ -52,3 +57,9 @@ impl Nature {
}
}
}
impl ValueIdentifiable for Nature {
fn value_identifier(&self) -> ValueIdentifier {
self.identifier
}
}