39 lines
903 B
Rust
39 lines
903 B
Rust
|
use crate::common_usings::*;
|
||
|
|
||
|
script!(
|
||
|
HealEachEndOfTurnEffect,
|
||
|
"heal_each_end_of_turn_effect",
|
||
|
pub heal_percent: AtomicF32
|
||
|
);
|
||
|
|
||
|
impl Script for HealEachEndOfTurnEffect {
|
||
|
fn new() -> Self {
|
||
|
Self {
|
||
|
heal_percent: Default::default(),
|
||
|
}
|
||
|
}
|
||
|
|
||
|
fn get_name(&self) -> &'static str {
|
||
|
Self::get_const_name()
|
||
|
}
|
||
|
|
||
|
fn get_capabilities(&self) -> &[ScriptCapabilities] {
|
||
|
&[ScriptCapabilities::OnEndTurn]
|
||
|
}
|
||
|
|
||
|
fn on_end_turn(&self) {
|
||
|
if let Some(ScriptOwner::Pokemon(pokemon)) = self.get_owner() {
|
||
|
let mut amount =
|
||
|
pokemon.max_health() as f32 * self.heal_percent.load(Ordering::Relaxed);
|
||
|
if pokemon.has_held_item("big_root") {
|
||
|
amount *= 1.3;
|
||
|
}
|
||
|
pokemon.heal(amount as u32, false);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
fn as_any(&self) -> &dyn Any {
|
||
|
self
|
||
|
}
|
||
|
}
|