use crate::{ExternRef, ExternalReferenceType}; #[derive(Clone)] pub struct BattleRandom { reference: ExternRef, } impl BattleRandom { #[cfg(not(feature = "mock_data"))] pub fn get(&self) -> i32 { unsafe { battle_random_get(self.reference) } } #[cfg(not(feature = "mock_data"))] pub fn get_max(&self, max: i32) -> i32 { unsafe { battle_random_get_max(self.reference, max) } } #[cfg(not(feature = "mock_data"))] pub fn get_between(&self, min: i32, max: i32) -> i32 { unsafe { battle_random_get_between(self.reference, min, max) } } // TODO: effect_chance() } impl ExternalReferenceType for BattleRandom { fn from_extern_value(reference: ExternRef) -> Self { Self { reference } } } #[cfg(not(feature = "mock_data"))] extern "wasm" { fn battle_random_get(r: ExternRef) -> i32; fn battle_random_get_max(r: ExternRef, max: i32) -> i32; fn battle_random_get_between(r: ExternRef, min: i32, max: i32) -> i32; }