56 lines
1.5 KiB
Rust
56 lines
1.5 KiB
Rust
use crate::common_usings::*;
|
|
use alloc::vec::Vec;
|
|
use pkmn_lib_interface::PkmnResult;
|
|
|
|
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<Vec<Rc<EffectParameter>>>,
|
|
) -> PkmnResult<()> {
|
|
self.amount.store(
|
|
parameters.unwrap().get(0).unwrap().as_int() as i8,
|
|
Ordering::SeqCst,
|
|
);
|
|
Ok(())
|
|
}
|
|
|
|
fn on_secondary_effect(&self, mv: ExecutingMove, target: Pokemon, _hit: u8) -> PkmnResult<()> {
|
|
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))?;
|
|
Ok(())
|
|
}
|
|
|
|
fn as_any(&self) -> &dyn Any {
|
|
self
|
|
}
|
|
}
|