2022-08-14 11:37:17 +00:00
|
|
|
use crate::app_interface::Pokemon;
|
|
|
|
use crate::{ExternRef, ExternalReferenceType};
|
|
|
|
|
|
|
|
#[derive(Clone)]
|
|
|
|
pub struct Party {
|
|
|
|
reference: ExternRef<Party>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Party {
|
|
|
|
pub fn new(reference: ExternRef<Party>) -> Self {
|
|
|
|
Self { reference }
|
|
|
|
}
|
|
|
|
|
2022-08-17 16:05:38 +00:00
|
|
|
#[cfg(not(feature = "mock_data"))]
|
2022-08-14 11:37:17 +00:00
|
|
|
pub fn get_pokemon(&self, index: usize) -> Option<Pokemon> {
|
|
|
|
unsafe { party_get_pokemon(self.reference, index).get_value() }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl ExternalReferenceType for Party {
|
|
|
|
fn from_extern_value(reference: ExternRef<Self>) -> Self {
|
|
|
|
Self::new(reference)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-17 16:05:38 +00:00
|
|
|
#[cfg(not(feature = "mock_data"))]
|
2022-08-14 11:37:17 +00:00
|
|
|
extern "wasm" {
|
|
|
|
fn party_get_pokemon(r: ExternRef<Party>, index: usize) -> ExternRef<Pokemon>;
|
|
|
|
}
|