2022-08-20 10:22:12 +00:00
|
|
|
use std::intrinsics::transmute;
|
|
|
|
|
2022-08-20 11:17:20 +00:00
|
|
|
use crate::dynamic_data::LearnedMove;
|
2022-08-20 10:22:12 +00:00
|
|
|
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 crate::static_data::MoveData;
|
2022-08-27 12:14:58 +00:00
|
|
|
use wasmer::FunctionEnvMut;
|
2022-08-20 10:22:12 +00:00
|
|
|
|
|
|
|
register! {
|
2022-08-20 11:17:20 +00:00
|
|
|
fn learned_move_get_learn_method(
|
2022-08-27 12:14:58 +00:00
|
|
|
env: FunctionEnvMut<WebAssemblyEnv>,
|
2022-08-20 10:22:12 +00:00
|
|
|
turn_choice: ExternRef<LearnedMove>,
|
|
|
|
) -> u8 {
|
|
|
|
unsafe {
|
2022-08-27 16:04:56 +00:00
|
|
|
transmute(turn_choice.value_func(&env).unwrap().learn_method())
|
2022-08-20 10:22:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-20 11:17:20 +00:00
|
|
|
fn learned_move_get_move_data(
|
2022-08-27 12:14:58 +00:00
|
|
|
env: FunctionEnvMut<WebAssemblyEnv>,
|
2022-08-20 10:22:12 +00:00
|
|
|
turn_choice: ExternRef<LearnedMove>,
|
|
|
|
) -> ExternRef<MoveData> {
|
2022-08-27 16:04:56 +00:00
|
|
|
ExternRef::func_new(&env, turn_choice.value_func(&env).unwrap().move_data())
|
2022-08-20 10:22:12 +00:00
|
|
|
}
|
|
|
|
}
|