45 lines
1.2 KiB
Rust
Executable File
45 lines
1.2 KiB
Rust
Executable File
#[cfg(not(feature = "mock_data"))]
|
|
use crate::app_interface::PokemonImpl;
|
|
use crate::{ExternRef, ExternalReferenceType, Pokemon};
|
|
use alloc::rc::Rc;
|
|
|
|
pub trait ChoiceQueueTrait {
|
|
fn move_pokemon_choice_next(&self, pokemon: &Pokemon) -> bool;
|
|
}
|
|
|
|
pub type ChoiceQueue = Rc<dyn ChoiceQueueTrait>;
|
|
|
|
#[derive(Clone)]
|
|
pub struct ChoiceQueueImpl {
|
|
reference: ExternRef<ChoiceQueueImpl>,
|
|
}
|
|
|
|
#[cfg(not(feature = "mock_data"))]
|
|
impl ChoiceQueueImpl {
|
|
pub fn new(reference: ExternRef<ChoiceQueueImpl>) -> Self {
|
|
Self { reference }
|
|
}
|
|
}
|
|
|
|
#[cfg(not(feature = "mock_data"))]
|
|
impl ChoiceQueueTrait for ChoiceQueueImpl {
|
|
fn move_pokemon_choice_next(&self, pokemon: &Pokemon) -> bool {
|
|
unsafe { choice_queue_move_pokemon_choice_next(self.reference, pokemon.reference().into()) }
|
|
}
|
|
}
|
|
|
|
#[cfg(not(feature = "mock_data"))]
|
|
impl ExternalReferenceType for ChoiceQueueImpl {
|
|
fn from_extern_value(reference: ExternRef<Self>) -> Self {
|
|
Self::new(reference)
|
|
}
|
|
}
|
|
|
|
#[cfg(not(feature = "mock_data"))]
|
|
extern "wasm" {
|
|
fn choice_queue_move_pokemon_choice_next(
|
|
r: ExternRef<ChoiceQueueImpl>,
|
|
pokemon: ExternRef<PokemonImpl>,
|
|
) -> bool;
|
|
}
|