Skip to main content

ItemUseResult

Enum ItemUseResult 

Source
pub enum ItemUseResult<I: Copy + Eq + Hash + Debug> {
    Applied {
        consume: bool,
        message_key: Option<String>,
    },
    NoEffect,
    Caught,
    Failed,
    EvolutionTriggered {
        item: I,
        message_key: Option<String>,
    },
    MoveLearned {
        consume: bool,
        message_key: Option<String>,
    },
}
Expand description

Neutral result of an item-use attempt, returned by ItemProvider::apply_effect and propagated by use_item.

The driver consumes one unit of the item only on ItemUseResult::Applied with consume: true, or on ItemUseResult::Caught.

Variants§

§

Applied

The effect was applied. consume tells the driver whether to remove one unit from the bag (consumables vs. reusable tools). message_key is an opaque, game-defined message identifier (the engine never reads it).

Fields

§consume: bool

Whether the driver should remove one unit from the inventory.

§message_key: Option<String>

Optional game-defined message id to display. Opaque to the engine.

§

NoEffect

The item was applicable but produced no effect (e.g. Potion at full HP -> “It won’t have any effect”). Not consumed.

§

Caught

A capture device succeeded (battle context). Consumed.

§

Failed

The attempt failed (e.g. a ball that broke free, or the item could not be used here). Not consumed.

§

EvolutionTriggered

The item triggered an evolution sequence (e.g. Thunderstone, Rare Candy, or any evolution-inducing item). The driver should NOT consume the item until the evolution is confirmed/completed.

Fields

§item: I

The item that triggered the evolution (may be consumed later upon evolution confirmation).

§message_key: Option<String>

Optional game-defined message id to display.

§

MoveLearned

The item taught a new move to the target (e.g. TM/HM). The driver should consume the item if consume is true (TMs are consumed in Gen 1-4; HMs are never consumed).

Fields

§consume: bool

Whether the driver should remove one unit from the inventory.

§message_key: Option<String>

Optional game-defined message id to display.

Implementations§

Source§

impl<I: Copy + Eq + Hash + Debug> ItemUseResult<I>

Source

pub fn consumes(&self) -> bool

Whether the driver should remove one unit from the bag for this result.

Trait Implementations§

Source§

impl<I: Clone + Copy + Eq + Hash + Debug> Clone for ItemUseResult<I>

Source§

fn clone(&self) -> ItemUseResult<I>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<I: Debug + Copy + Eq + Hash + Debug> Debug for ItemUseResult<I>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<I: Eq + Copy + Eq + Hash + Debug> Eq for ItemUseResult<I>

Source§

impl<I: PartialEq + Copy + Eq + Hash + Debug> PartialEq for ItemUseResult<I>

Source§

fn eq(&self, other: &ItemUseResult<I>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<I: PartialEq + Copy + Eq + Hash + Debug> StructuralPartialEq for ItemUseResult<I>

Auto Trait Implementations§

§

impl<I> Freeze for ItemUseResult<I>
where I: Freeze,

§

impl<I> RefUnwindSafe for ItemUseResult<I>
where I: RefUnwindSafe,

§

impl<I> Send for ItemUseResult<I>
where I: Send,

§

impl<I> Sync for ItemUseResult<I>
where I: Sync,

§

impl<I> Unpin for ItemUseResult<I>
where I: Unpin,

§

impl<I> UnsafeUnpin for ItemUseResult<I>
where I: UnsafeUnpin,

§

impl<I> UnwindSafe for ItemUseResult<I>
where I: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.