Loads more work on battling, initial stretch to run a turn done.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-06-16 17:59:33 +02:00
parent a33369afcc
commit ff541b0696
50 changed files with 105871 additions and 497 deletions

View File

@@ -1,6 +1,11 @@
use crate::dynamic_data::models::executing_move::ExecutingMove;
use crate::dynamic_data::models::pokemon::Pokemon;
use crate::dynamic_data::script_handling::ScriptSource;
use crate::utils::random::Random;
use crate::{script_hook, script_hook_on_lock};
use parking_lot::RwLock;
use std::fmt::{Debug, Formatter};
use std::sync::Mutex;
use std::sync::{Arc, Mutex};
#[derive(Default)]
pub struct BattleRandom {
@@ -27,6 +32,32 @@ impl BattleRandom {
pub fn get_between(&self, min: i32, max: i32) -> i32 {
return self.get_rng().lock().unwrap().get_between(min, max);
}
pub fn effect_chance(
&self,
mut chance: f32,
executing_move: &ExecutingMove,
target: &Arc<RwLock<Pokemon>>,
hit_number: u8,
) -> bool {
script_hook!(
change_effect_chance,
executing_move,
executing_move,
target,
hit_number,
&mut chance
);
script_hook_on_lock!(
change_incoming_effect_chance,
target,
executing_move,
target,
hit_number,
&mut chance
);
self.get_rng().lock().unwrap().get_float() < (chance / 100.0)
}
}
impl Debug for BattleRandom {