27 lines
846 B
Rust
27 lines
846 B
Rust
use crate::dynamic_data::{Pokemon, PokemonParty};
|
|
use crate::script_implementations::wasm::export_registry::register;
|
|
use crate::script_implementations::wasm::extern_ref::ExternRef;
|
|
use crate::script_implementations::wasm::script_resolver::WebAssemblyEnv;
|
|
use wasmer::FunctionEnvMut;
|
|
|
|
register! {
|
|
fn party_get_pokemon(
|
|
env: FunctionEnvMut<WebAssemblyEnv>,
|
|
party: ExternRef<PokemonParty>,
|
|
index: u32
|
|
) -> ExternRef<Pokemon> {
|
|
if let Some(v) = &party.value_func(&env).unwrap().pokemon()[index as usize] {
|
|
ExternRef::func_new(&env, v.as_ref())
|
|
} else {
|
|
ExternRef::null()
|
|
}
|
|
}
|
|
|
|
fn party_get_length(
|
|
env: FunctionEnvMut<WebAssemblyEnv>,
|
|
party: ExternRef<PokemonParty>,
|
|
) -> u32 {
|
|
party.value_func(&env).unwrap().length() as u32
|
|
}
|
|
}
|