60 lines
1.7 KiB
Rust
60 lines
1.7 KiB
Rust
use crate::script;
|
|
use alloc::rc::Rc;
|
|
use core::any::Any;
|
|
use core::sync::atomic::{AtomicI8, Ordering};
|
|
use pkmn_lib_interface::app_interface::list::ImmutableList;
|
|
use pkmn_lib_interface::app_interface::{
|
|
DynamicLibrary, EffectParameter, ExecutingMove, Pokemon, Statistic,
|
|
};
|
|
use pkmn_lib_interface::handling::{Script, ScriptCapabilities};
|
|
|
|
script!(
|
|
ChangeAllTargetStats,
|
|
"change_all_target_stats",
|
|
amount: AtomicI8
|
|
);
|
|
|
|
impl Script for ChangeAllTargetStats {
|
|
fn new() -> Self {
|
|
Self {
|
|
amount: Default::default(),
|
|
}
|
|
}
|
|
|
|
fn get_name(&self) -> &'static str {
|
|
Self::get_const_name()
|
|
}
|
|
|
|
fn get_capabilities(&self) -> &[ScriptCapabilities] {
|
|
&[
|
|
ScriptCapabilities::Initialize,
|
|
ScriptCapabilities::OnSecondaryEffect,
|
|
]
|
|
}
|
|
|
|
fn on_initialize(
|
|
&self,
|
|
_library: DynamicLibrary,
|
|
parameters: Option<ImmutableList<Rc<EffectParameter>>>,
|
|
) {
|
|
self.amount.store(
|
|
parameters.unwrap().get(0).unwrap().as_int() as i8,
|
|
Ordering::SeqCst,
|
|
);
|
|
}
|
|
|
|
fn on_secondary_effect(&self, mv: ExecutingMove, target: Pokemon, _hit: u8) {
|
|
let user = mv.user();
|
|
let amount = self.amount.load(Ordering::SeqCst);
|
|
target.change_stat_boost(Statistic::Attack, amount, user.equals(&target));
|
|
target.change_stat_boost(Statistic::Defense, amount, user.equals(&target));
|
|
target.change_stat_boost(Statistic::SpecialAttack, amount, user.equals(&target));
|
|
target.change_stat_boost(Statistic::SpecialDefense, amount, user.equals(&target));
|
|
target.change_stat_boost(Statistic::Speed, amount, user.equals(&target));
|
|
}
|
|
|
|
fn as_any(&self) -> &dyn Any {
|
|
self
|
|
}
|
|
}
|