Gen7ScriptsRs/gen_7_scripts/src/moves/cure_party_status.rs

37 lines
917 B
Rust

use crate::common_usings::*;
script!(CurePartyStatus, "cure_party_status");
impl Script for CurePartyStatus {
fn new() -> Self {
Self {}
}
fn get_name(&self) -> &'static str {
Self::get_const_name()
}
fn get_capabilities(&self) -> &[ScriptCapabilities] {
&[ScriptCapabilities::OnSecondaryEffect]
}
fn on_secondary_effect(&self, mv: ExecutingMove, _target: Pokemon, _hit: u8) -> PkmnResult<()> {
let user = mv.user();
user.clear_status();
let party = user.battle()?.unwrap().find_party_for_pokemon(&user)?;
if let Some(party) = party {
let p = party.party();
for mon in p.as_ref().into_iter().flatten() {
if !mon.equals(&user) {
mon.clear_status();
}
}
}
Ok(())
}
fn as_any(&self) -> &dyn Any {
self
}
}