41 lines
826 B
Rust
41 lines
826 B
Rust
use crate::common_usings::*;
|
|
use pkmn_lib_interface::handling::item_script::ItemScript;
|
|
|
|
script!(
|
|
HealingItem,
|
|
"healing_item",
|
|
amount: AtomicU32
|
|
);
|
|
|
|
impl ItemScript for HealingItem {
|
|
fn new() -> Self
|
|
where
|
|
Self: Sized,
|
|
{
|
|
Self {
|
|
amount: Default::default(),
|
|
}
|
|
}
|
|
|
|
fn get_name(&self) -> &'static str {
|
|
Self::get_const_name()
|
|
}
|
|
|
|
fn is_item_usable(&self) -> PkmnResult<bool> {
|
|
Ok(true)
|
|
}
|
|
|
|
fn requires_target(&self) -> PkmnResult<bool> {
|
|
Ok(true)
|
|
}
|
|
|
|
fn is_target_valid(&self, target: &Pokemon) -> PkmnResult<bool> {
|
|
Ok(!target.is_fainted()?)
|
|
}
|
|
|
|
fn on_use_with_target(&self, target: &Pokemon) -> PkmnResult<()> {
|
|
target.heal(self.amount.load(Ordering::Relaxed), false)?;
|
|
Ok(())
|
|
}
|
|
}
|