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

@@ -4,13 +4,15 @@ use crate::static_data::Statistic;
use crate::static_data::TypeIdentifier;
use crate::static_data::{Ability, StaticStatisticSet};
use crate::static_data::{AbilityIndex, LearnableMoves};
use crate::Random;
use crate::StringKey;
use crate::{Random, ValueIdentifiable, ValueIdentifier};
/// A form is a variant of a specific species. A species always has at least one form, but can have
/// many more.
#[derive(Debug)]
pub struct Form {
/// A unique identifier so we know what value this is.
identifier: ValueIdentifier,
/// The name of the form.
name: StringKey,
/// The height of the form in meters.
@@ -48,6 +50,7 @@ impl Form {
flags: HashSet<StringKey>,
) -> Form {
Form {
identifier: Default::default(),
name: name.clone(),
height,
weight,
@@ -156,3 +159,9 @@ impl Form {
self.flags.contains(key)
}
}
impl ValueIdentifiable for Form {
fn value_identifier(&self) -> ValueIdentifier {
self.identifier
}
}