43 lines
1.1 KiB
Rust
Executable File
43 lines
1.1 KiB
Rust
Executable File
use core::any::Any;
|
|
use pkmn_lib_interface::app_interface::TurnChoice;
|
|
use pkmn_lib_interface::handling::{Script, ScriptCapabilities};
|
|
|
|
pub struct MultiHitMove {}
|
|
|
|
impl MultiHitMove {
|
|
pub const fn get_const_name() -> &'static str {
|
|
"2_5_hit_move"
|
|
}
|
|
}
|
|
|
|
impl Script for MultiHitMove {
|
|
fn new() -> Self {
|
|
Self {}
|
|
}
|
|
|
|
fn get_name(&self) -> &'static str {
|
|
Self::get_const_name()
|
|
}
|
|
|
|
fn get_capabilities(&self) -> &[ScriptCapabilities] {
|
|
&[ScriptCapabilities::ChangeNumberOfHits]
|
|
}
|
|
|
|
fn change_number_of_hits(&self, choice: TurnChoice, number_of_hits: &mut u8) {
|
|
// 35% chance that it will hit 2 times, a 35% chance it will hit 3 times, a 15% chance it
|
|
// will hit 4 times, and a 15% chance it will hit 5 times.
|
|
let rand_value = choice.user().battle().unwrap().random().get_between(0, 100);
|
|
*number_of_hits = match rand_value {
|
|
0..=34 => 2,
|
|
35..=69 => 3,
|
|
70..=84 => 4,
|
|
85..=100 => 5,
|
|
_ => *number_of_hits,
|
|
}
|
|
}
|
|
|
|
fn as_any(&self) -> &dyn Any {
|
|
self
|
|
}
|
|
}
|