Gen7ScriptsRs/gen_7_scripts/src/test_script.rs

51 lines
1.3 KiB
Rust

use pkmn_lib_interface::app_interface::list::ImmutableList;
use pkmn_lib_interface::app_interface::{
get_hash, DataLibrary, DynamicLibrary, EffectParameter, TurnChoice,
};
use pkmn_lib_interface::dbg;
use pkmn_lib_interface::handling::{Script, ScriptCapabilities};
pub struct TestScript {}
impl Script for TestScript {
fn new() -> Self {
TestScript {}
}
fn destroy(&self) {}
fn get_name(&self) -> &str {
"TestScript"
}
fn get_capabilities(&self) -> &[ScriptCapabilities] {
&[
ScriptCapabilities::Initialize,
ScriptCapabilities::OnBeforeTurn,
]
}
fn on_initialize(
&self,
library: &DynamicLibrary,
parameters: Option<ImmutableList<EffectParameter>>,
) {
let l = library.data_library();
let ml = l.move_library();
let m = ml.get_by_hash(const { get_hash(b"tackle") }).unwrap();
dbg!("found move!");
dbg!("{:?} has {} base power", m.name().str(), m.base_power());
dbg!(
"Found a parameter with value: {}",
parameters.unwrap().get(0).unwrap()
);
if m.has_flag(b"foo") {}
}
fn on_before_turn(&self, choice: TurnChoice) {
dbg!(
"On before turn for user: {}",
choice.user().species().name()
);
}
}