PkmnLib_rs/src/dynamic_data/script_handling/item_script.rs

47 lines
1.4 KiB
Rust
Executable File

use crate::dynamic_data::Pokemon;
use crate::static_data::Parameter;
use std::sync::Arc;
/// The script functions that are relevant to item use.
pub trait ItemScript {
/// Initializes the script with the given parameters for a specific item
fn on_initialize(&self, _pars: Vec<Arc<Parameter>>) -> 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(())
}
}