Gen7ScriptsRs/pkmn_lib_interface/src/handling/script.rs

40 lines
979 B
Rust

use crate::app_interface::list::ImmutableList;
use crate::app_interface::{BaseTurnChoice, BattleLibrary, EffectParameter};
use crate::handling::ScriptCapabilities;
use crate::ExternRef;
use core::ffi::c_void;
use core::fmt::Debug;
pub trait Script {
fn new() -> Self
where
Self: Sized;
fn destroy(&self);
fn get_name(&self) -> &str;
fn get_capabilities(&self) -> &[ScriptCapabilities];
fn on_initialize(
&self,
_library: &BattleLibrary,
_parameters: Option<ImmutableList<EffectParameter>>,
) {
}
fn on_before_turn(&self, _choice: ExternRef<BaseTurnChoice>) {}
}
impl Debug for dyn Script {
fn fmt(&self, _f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
core::fmt::Result::Ok(())
}
}
pub trait OwnerGetter {
fn get_owner<T>(&self) -> Option<ExternRef<T>> {
unimplemented!()
}
}
extern "wasm" {
pub fn get_script_owner(pointer: *const c_void) -> ExternRef<u8>;
}