Gen7ScriptsRs/pkmn_lib_interface/src/app_interface/dynamic_data/battle_random.rs

37 lines
1.0 KiB
Rust
Executable File

use crate::{ExternRef, ExternalReferenceType};
#[derive(Clone)]
pub struct BattleRandom {
reference: ExternRef<Self>,
}
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 {
Self { reference }
}
}
#[cfg(not(feature = "mock_data"))]
extern "wasm" {
fn battle_random_get(r: ExternRef<BattleRandom>) -> i32;
fn battle_random_get_max(r: ExternRef<BattleRandom>, max: i32) -> i32;
fn battle_random_get_between(r: ExternRef<BattleRandom>, min: i32, max: i32) -> i32;
}