use crate::common_usings::*; use crate::pokemon::assurance_data::AssuranceData; use pkmn_lib_interface::PkmnResult; script!(Assurance, "assurance"); impl Script for Assurance { fn new() -> Self { Self {} } fn get_name(&self) -> &'static str { Self::get_const_name() } fn get_capabilities(&self) -> &[ScriptCapabilities] { &[ ScriptCapabilities::OnBeforeTurn, ScriptCapabilities::ChangeBasePower, ] } fn on_before_turn(&self, choice: TurnChoice) -> PkmnResult<()> { if let TurnChoice::Move(data) = &choice { let side: BattleSide = choice .user() .battle()? .unwrap() .sides() .get(data.target_side() as usize) .unwrap() .clone(); side.add_volatile(AssuranceData::create_for_assurance(data.target_index()))?; } Ok(()) } fn change_base_power( &self, _move: ExecutingMove, target: Pokemon, _hit: u8, base_power: &mut u8, ) -> PkmnResult<()> { if let Some(s) = get_volatile_as::( target.battle_side()?.as_ref(), AssuranceData::get_const_name(), )? { if s.has_hit() { *base_power *= 2; } } Ok(()) } fn as_any(&self) -> &dyn Any { self } }