Gen7ScriptsRs/pkmn_lib_interface/src/handling/item_script.rs

56 lines
1.6 KiB
Rust

use crate::app_interface::{EffectParameter, Pokemon};
use alloc::rc::Rc;
use alloc::vec::Vec;
type Result<T> = crate::result::PkmnResult<T>;
pub trait ItemScript {
fn new() -> Self
where
Self: Sized;
fn get_name(&self) -> &'static str;
/// Initializes the script with the given parameters for a specific item
fn on_initialize(&self, _pars: Option<Vec<Rc<EffectParameter>>>) -> Result<()> {
Ok(())
}
/// Returns whether the item is usable in the current context.
/// Note that the host caches this value, so it will not be called again
fn is_item_usable(&self) -> Result<bool> {
Ok(false)
}
/// Returns whether the item requires a target to be used.
/// Note that the host caches this value, so it will not be called again
fn requires_target(&self) -> Result<bool> {
Ok(false)
}
/// Returns whether the item can be held.
/// Note that the host caches this value, so it will not be called again
fn is_holdable(&self) -> Result<bool> {
Ok(false)
}
/// Returns whether the item is usable on the given target.
fn is_target_valid(&self, _target: &Pokemon) -> Result<bool> {
Ok(false)
}
/// Returns whether the item can be held by the given target.
fn can_target_hold(&self, _target: &Pokemon) -> Result<bool> {
Ok(false)
}
/// Handles the use of the item.
fn on_use(&self) -> Result<()> {
Ok(())
}
/// Handles the use of the item on the given target.
fn on_use_with_target(&self, _target: &Pokemon) -> Result<()> {
Ok(())
}
}