FFI for Pokemon class

This commit is contained in:
2022-10-14 13:59:04 +02:00
parent a840605bf7
commit 9efe1b4e22
10 changed files with 439 additions and 59 deletions

View File

@@ -1,13 +1,17 @@
use std::sync::atomic::{AtomicU8, Ordering};
use std::sync::Arc;
use crate::dynamic_data::Pokemon;
use crate::static_data::MoveData;
use crate::{ValueIdentifiable, ValueIdentifier};
/// A learned move is the data attached to a Pokemon for a move it has learned. It has information
/// such as the remaining amount of users, how it has been learned, etc.
#[derive(Debug)]
#[cfg_attr(feature = "wasm", derive(unique_type_id_derive::UniqueTypeId))]
pub struct LearnedMove {
/// A unique identifier so we know what value this is.
identifier: ValueIdentifier,
/// The immutable move information of the move.
move_data: Arc<MoveData>,
/// The maximal power points for this move.
@@ -33,6 +37,7 @@ impl LearnedMove {
/// Instantiate a new learned move.
pub fn new(move_data: &Arc<MoveData>, learn_method: MoveLearnMethod) -> Self {
Self {
identifier: Default::default(),
move_data: move_data.clone(),
max_pp: move_data.base_usages(),
remaining_pp: AtomicU8::new(move_data.base_usages()),
@@ -87,3 +92,9 @@ impl LearnedMove {
.unwrap();
}
}
impl ValueIdentifiable for LearnedMove {
fn value_identifier(&self) -> ValueIdentifier {
self.identifier
}
}