2023-07-22 19:17:06 +00:00
|
|
|
use crate::dynamic_data::Pokemon;
|
|
|
|
use crate::static_data::EffectParameter;
|
|
|
|
use std::sync::Arc;
|
|
|
|
|
2022-07-01 15:07:22 +00:00
|
|
|
/// The script functions that are relevant to item use.
|
2023-07-22 19:17:06 +00:00
|
|
|
pub trait ItemScript {
|
|
|
|
/// Initializes the script with the given parameters for a specific item
|
|
|
|
fn on_initialize(&self, _pars: Vec<Arc<EffectParameter>>) -> anyhow_ext::Result<()> {
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Returns whether the item is usable in the current context.
|
|
|
|
fn is_item_usable(&self) -> anyhow_ext::Result<bool> {
|
|
|
|
Ok(false)
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Returns whether the item requires a target to be used.
|
|
|
|
fn requires_target(&self) -> anyhow_ext::Result<bool> {
|
|
|
|
Ok(false)
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Returns whether the item is usable on the given target.
|
|
|
|
fn is_target_valid(&self, _target: &Pokemon) -> anyhow_ext::Result<bool> {
|
|
|
|
Ok(false)
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Returns whether the item can be held by the given target.
|
|
|
|
fn is_holdable(&self) -> anyhow_ext::Result<bool> {
|
|
|
|
Ok(false)
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Returns whether the item can be held by the given target.
|
|
|
|
fn can_target_hold(&self, _target: &Pokemon) -> anyhow_ext::Result<bool> {
|
|
|
|
Ok(false)
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Handles the use of the item.
|
|
|
|
fn on_use(&self) -> anyhow_ext::Result<()> {
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Handles the use of the item on the given target.
|
|
|
|
fn on_use_with_target(&self, _target: &Pokemon) -> anyhow_ext::Result<()> {
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|