58 lines
1.6 KiB
Rust
58 lines
1.6 KiB
Rust
use pkmn_lib_interface::app_interface::list::ImmutableList;
|
|
use pkmn_lib_interface::app_interface::{
|
|
get_hash, DamageSource, 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()
|
|
);
|
|
choice.user().damage(50, DamageSource::Misc);
|
|
if let TurnChoice::Move(d) = choice {
|
|
dbg!(
|
|
"On before turn for move choice: {}",
|
|
d.used_move().move_data().name()
|
|
);
|
|
}
|
|
}
|
|
}
|