From 880ea55a67cb0d88a75900226bc10eb934046b2b Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sun, 12 Jun 2022 19:04:22 +0200 Subject: [PATCH] Some work on script function parameters. --- src/dynamic_data/script_handling/mod.rs | 4 +-- src/dynamic_data/script_handling/script.rs | 40 +++++++++++++--------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/dynamic_data/script_handling/mod.rs b/src/dynamic_data/script_handling/mod.rs index 70dadc1..4e864af 100644 --- a/src/dynamic_data/script_handling/mod.rs +++ b/src/dynamic_data/script_handling/mod.rs @@ -180,9 +180,9 @@ mod tests { 0 } - fn add_suppression(&self) {} + fn add_suppression(&mut self) {} - fn remove_suppression(&self) {} + fn remove_suppression(&mut self) {} fn on_initialize(&mut self, _pars: &[EffectParameter]) { self.test_count += 1; diff --git a/src/dynamic_data/script_handling/script.rs b/src/dynamic_data/script_handling/script.rs index 2ac0fb3..117a7c5 100644 --- a/src/dynamic_data/script_handling/script.rs +++ b/src/dynamic_data/script_handling/script.rs @@ -1,4 +1,6 @@ +use crate::dynamic_data::choices::TurnChoice; use crate::dynamic_data::models::damage_source::DamageSource; +use crate::dynamic_data::models::executing_move::ExecutingMove; use crate::dynamic_data::models::pokemon::Pokemon; use crate::static_data::moves::secondary_effect::EffectParameter; use crate::StringKey; @@ -14,24 +16,30 @@ pub trait Script { self.get_suppressed_count() > 0 } fn get_suppressed_count(&self) -> usize; - fn add_suppression(&self); - fn remove_suppression(&self); + fn add_suppression(&mut self); + fn remove_suppression(&mut self); - // FIXME: add missing parameters - fn stack(&self) {} - fn on_remove(&self) {} + // FIXME: add missing parameters, and make all these mut + fn stack(&mut self) {} + fn on_remove(&mut self) {} fn on_initialize(&mut self, _pars: &[EffectParameter]) {} - fn on_before_turn(&self) {} - fn change_speed(&self) {} - fn change_priority(&self) {} - fn change_attack(&self) {} - fn change_number_of_hits(&self) {} - fn prevent_attack(&self) {} - fn fail_attack(&self) {} - fn stop_before_attack(&self) {} - fn on_before_attack(&self) {} - fn fail_incoming_attack(&self) {} - fn is_invulnerable(&self) {} + fn on_before_turn(&mut self, _choice: &TurnChoice) {} + fn change_speed(&mut self, _choice: &TurnChoice, _speed: &mut u32) {} + fn change_priority(&mut self, _choice: &TurnChoice, _priority: &mut i8) {} + fn change_attack(&mut self, _choice: &TurnChoice, _moveName: &mut StringKey) {} + fn change_number_of_hits(&mut self, _choice: &TurnChoice, _numberOfHits: &mut u8) {} + fn prevent_attack(&mut self, _move: &ExecutingMove, _prevent: &mut bool) {} + fn fail_attack(&mut self, _move: &ExecutingMove, _fail: &mut bool) {} + fn stop_before_attack(&mut self, _move: &ExecutingMove, _stop: &mut bool) {} + fn on_before_attack(&mut self, _move: &ExecutingMove) {} + fn fail_incoming_attack(&mut self, _move: &ExecutingMove, target: &Pokemon, _fail: &mut bool) {} + fn is_invulnerable( + &mut self, + _move: &ExecutingMove, + target: &Pokemon, + _invulnerable: &mut bool, + ) { + } fn on_attack_miss(&self) {} fn change_attack_type(&self) {} fn block_critical(&self) {}