51 lines
1.1 KiB
Rust
Executable File
51 lines
1.1 KiB
Rust
Executable File
use crate::common_usings::*;
|
|
|
|
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 Saturating<u8>,
|
|
) -> PkmnResult<()> {
|
|
// 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.0 = match rand_value {
|
|
0..=34 => 2,
|
|
35..=69 => 3,
|
|
70..=84 => 4,
|
|
85..=100 => 5,
|
|
_ => number_of_hits.0,
|
|
};
|
|
Ok(())
|
|
}
|
|
|
|
fn as_any(&self) -> &dyn Any {
|
|
self
|
|
}
|
|
}
|