More work on using interior mutability instead of exterior mutability for dynamic types (Battle, Pokemon, etc).
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-06-18 15:52:39 +02:00
parent c45c7538bf
commit 5576bc8b80
21 changed files with 324 additions and 385 deletions

View File

@@ -33,86 +33,51 @@ pub trait Script {
fn fail_move(&mut self, _move: &ExecutingMove, _fail: &mut bool) {}
fn stop_before_move(&mut self, _move: &ExecutingMove, _stop: &mut bool) {}
fn on_before_move(&mut self, _move: &ExecutingMove) {}
fn fail_incoming_move(&mut self, _move: &ExecutingMove, _target: &Arc<RwLock<Pokemon>>, _fail: &mut bool) {}
fn is_invulnerable(&mut self, _move: &ExecutingMove, _target: &Arc<RwLock<Pokemon>>, _invulnerable: &mut bool) {}
fn on_move_miss(&mut self, _move: &ExecutingMove, _target: &Arc<RwLock<Pokemon>>) {}
fn change_move_type(
&mut self,
_move: &ExecutingMove,
_target: &Arc<RwLock<Pokemon>>,
_hit: u8,
_move_type: &mut u8,
) {
}
fn fail_incoming_move(&mut self, _move: &ExecutingMove, _target: &Arc<Pokemon>, _fail: &mut bool) {}
fn is_invulnerable(&mut self, _move: &ExecutingMove, _target: &Arc<Pokemon>, _invulnerable: &mut bool) {}
fn on_move_miss(&mut self, _move: &ExecutingMove, _target: &Arc<Pokemon>) {}
fn change_move_type(&mut self, _move: &ExecutingMove, _target: &Arc<Pokemon>, _hit: u8, _move_type: &mut u8) {}
fn change_effectiveness(
&mut self,
_move: &ExecutingMove,
_target: &Arc<RwLock<Pokemon>>,
_target: &Arc<Pokemon>,
_hit: u8,
_effectiveness: &mut f32,
) {
}
fn block_critical(
&mut self,
_move: &ExecutingMove,
_target: &Arc<RwLock<Pokemon>>,
_hit: u8,
_block_critical: &mut bool,
) {
}
fn block_critical(&mut self, _move: &ExecutingMove, _target: &Arc<Pokemon>, _hit: u8, _block_critical: &mut bool) {}
fn block_incoming_critical(
&mut self,
_move: &ExecutingMove,
_target: &Arc<RwLock<Pokemon>>,
_target: &Arc<Pokemon>,
_hit: u8,
_block_critical: &mut bool,
) {
}
fn change_critical_stage(
&mut self,
_move: &ExecutingMove,
_target: &Arc<RwLock<Pokemon>>,
_hit: u8,
_stage: &mut u8,
) {
}
fn change_critical_stage(&mut self, _move: &ExecutingMove, _target: &Arc<Pokemon>, _hit: u8, _stage: &mut u8) {}
fn change_critical_modifier(
&mut self,
_move: &ExecutingMove,
_target: &Arc<RwLock<Pokemon>>,
_hit: u8,
_modifier: &mut f32,
) {
}
fn change_stab_modifier(
&mut self,
_move: &ExecutingMove,
_target: &Arc<RwLock<Pokemon>>,
_target: &Arc<Pokemon>,
_hit: u8,
_modifier: &mut f32,
) {
}
fn change_stab_modifier(&mut self, _move: &ExecutingMove, _target: &Arc<Pokemon>, _hit: u8, _modifier: &mut f32) {}
fn change_base_power(
&mut self,
_move: &ExecutingMove,
_target: &Arc<RwLock<Pokemon>>,
_hit: u8,
_base_power: &mut u8,
) {
}
fn change_base_power(&mut self, _move: &ExecutingMove, _target: &Arc<Pokemon>, _hit: u8, _base_power: &mut u8) {}
fn change_damage_stats_user(
&mut self,
_move: &ExecutingMove,
_target: &Arc<RwLock<Pokemon>>,
_target: &Arc<Pokemon>,
_hit: u8,
_stats_user: &mut Arc<RwLock<Pokemon>>,
_stats_user: &mut Arc<Pokemon>,
) {
}
fn bypass_defensive_stat_boost(
&mut self,
_move: &ExecutingMove,
_target: &Arc<RwLock<Pokemon>>,
_target: &Arc<Pokemon>,
_hit: u8,
_bypass: &mut bool,
) {
@@ -120,7 +85,7 @@ pub trait Script {
fn bypass_offensive_stat_boost(
&mut self,
_move: &ExecutingMove,
_target: &Arc<RwLock<Pokemon>>,
_target: &Arc<Pokemon>,
_hit: u8,
_bypass: &mut bool,
) {
@@ -128,7 +93,7 @@ pub trait Script {
fn change_offensive_stat_value(
&mut self,
_move: &ExecutingMove,
_target: &Arc<RwLock<Pokemon>>,
_target: &Arc<Pokemon>,
_hit: u8,
_amount: &mut u32,
) {
@@ -136,7 +101,7 @@ pub trait Script {
fn change_defensive_stat_value(
&mut self,
_move: &ExecutingMove,
_target: &Arc<RwLock<Pokemon>>,
_target: &Arc<Pokemon>,
_hit: u8,
_amount: &mut u32,
) {
@@ -145,30 +110,17 @@ pub trait Script {
fn change_damage_stat_modifier(
&mut self,
_move: &ExecutingMove,
_target: &Arc<RwLock<Pokemon>>,
_target: &Arc<Pokemon>,
_hit: u8,
_modifier: &mut f32,
) {
}
fn change_damage_modifier(
&mut self,
_move: &ExecutingMove,
_target: &Arc<RwLock<Pokemon>>,
_hit: u8,
_modifier: &mut f32,
) {
fn change_damage_modifier(&mut self, _move: &ExecutingMove, _target: &Arc<Pokemon>, _hit: u8, _modifier: &mut f32) {
}
fn change_damage(&mut self, _move: &ExecutingMove, _target: &Arc<RwLock<Pokemon>>, _hit: u8, _damage: &mut u32) {}
fn change_incoming_damage(
&mut self,
_move: &ExecutingMove,
_target: &Arc<RwLock<Pokemon>>,
_hit: u8,
_damage: &mut u32,
) {
}
fn on_incoming_hit(&mut self, _move: &ExecutingMove, _target: &Arc<RwLock<Pokemon>>, _hit: u8) {}
fn on_opponent_faints(&mut self, _move: &ExecutingMove, _target: &Arc<RwLock<Pokemon>>, _hit: u8) {}
fn change_damage(&mut self, _move: &ExecutingMove, _target: &Arc<Pokemon>, _hit: u8, _damage: &mut u32) {}
fn change_incoming_damage(&mut self, _move: &ExecutingMove, _target: &Arc<Pokemon>, _hit: u8, _damage: &mut u32) {}
fn on_incoming_hit(&mut self, _move: &ExecutingMove, _target: &Arc<Pokemon>, _hit: u8) {}
fn on_opponent_faints(&mut self, _move: &ExecutingMove, _target: &Arc<Pokemon>, _hit: u8) {}
fn prevent_stat_boost_change(
&mut self,
_target: &Pokemon,
@@ -189,29 +141,22 @@ pub trait Script {
fn prevent_secondary_effect(
&mut self,
_move: &ExecutingMove,
_target: &Arc<RwLock<Pokemon>>,
_target: &Arc<Pokemon>,
_hit: u8,
_prevent: &mut bool,
) {
}
fn change_effect_chance(
&mut self,
_move: &ExecutingMove,
_target: &Arc<RwLock<Pokemon>>,
_hit: u8,
_chance: &mut f32,
) {
}
fn change_effect_chance(&mut self, _move: &ExecutingMove, _target: &Arc<Pokemon>, _hit: u8, _chance: &mut f32) {}
fn change_incoming_effect_chance(
&mut self,
_move: &ExecutingMove,
_target: &Arc<RwLock<Pokemon>>,
_target: &Arc<Pokemon>,
_hit: u8,
_chance: &mut f32,
) {
}
fn on_secondary_effect(&mut self, _move: &ExecutingMove, _target: &Arc<RwLock<Pokemon>>, _hit: u8) {}
fn on_after_hits(&mut self, _move: &ExecutingMove, _target: &Arc<RwLock<Pokemon>>) {}
fn on_secondary_effect(&mut self, _move: &ExecutingMove, _target: &Arc<Pokemon>, _hit: u8) {}
fn on_after_hits(&mut self, _move: &ExecutingMove, _target: &Arc<Pokemon>) {}
fn prevent_self_switch(&mut self, _choice: &TurnChoice, _prevent: &mut bool) {}
fn prevent_opponent_switch(&mut self, _choice: &TurnChoice, _prevent: &mut bool) {}
fn on_fail(&mut self, _target: &Pokemon) {}