Skip to main content

KeywordInstance

Struct KeywordInstance 

Source
pub struct KeywordInstance {
    pub data: KeywordInstanceData,
    pub triggers: Vec<String>,
    pub replacements: Vec<String>,
    pub spell_abilities: Vec<String>,
    pub static_abilities: Vec<String>,
    pub svars: HashMap<String, String>,
}
Expand description

A keyword instance with its associated traits (triggers, replacement effects, static abilities, spell abilities). Mirrors Java’s KeywordInstance<T> abstract class.

Fields§

§data: KeywordInstanceData

The underlying keyword data (keyword enum, original string, intrinsic flag, idx).

§triggers: Vec<String>

Trigger definitions associated with this keyword.

§replacements: Vec<String>

Replacement effect definitions associated with this keyword.

§spell_abilities: Vec<String>

Spell ability definitions associated with this keyword.

§static_abilities: Vec<String>

Static ability definitions associated with this keyword.

§svars: HashMap<String, String>

SVars associated with this keyword instance.

Implementations§

Source§

impl KeywordInstance

Source

pub fn new(data: KeywordInstanceData) -> Self

Create a new keyword instance from base data.

Source

pub fn create_traits(&mut self)

Initialize trait lists from the keyword. Clears existing traits and re-parses them from the keyword definition. Mirrors Java’s KeywordInstance.createTraits(Card, boolean).

Source

pub fn add_trigger(&mut self, trigger: String)

Add a trigger definition string. Mirrors Java’s KeywordInstance.addTrigger(Trigger).

Source

pub fn add_replacement(&mut self, replacement: String)

Add a replacement effect definition string. Mirrors Java’s KeywordInstance.addReplacement(ReplacementEffect).

Source

pub fn add_spell_ability(&mut self, ability: String)

Add a spell ability definition string. Mirrors Java’s KeywordInstance.addSpellAbility(SpellAbility).

Source

pub fn add_static_ability(&mut self, static_ab: String)

Add a static ability definition string. Mirrors Java’s KeywordInstance.addStaticAbility(StaticAbility).

Source

pub fn has_traits(&self) -> bool

Returns true if any traits (triggers, replacements, spell abilities, or static abilities) are defined. Mirrors Java’s KeywordInstance.hasTraits().

Source

pub fn apply_spell_ability(&self, card: &mut Card)

Apply this keyword’s spell abilities to a card by parsing each spell ability string and adding it to the card’s abilities list. Mirrors Java’s KeywordInstance.applySpellAbility(List).

Source

pub fn apply_trigger(&self, card: &mut Card)

Apply this keyword’s triggers to a card by parsing each trigger string and adding it to the card’s triggers list. Mirrors Java’s KeywordInstance.applyTrigger(List).

Source

pub fn apply_replacement_effect(&self, card: &mut Card)

Apply this keyword’s replacement effects to a card by parsing each replacement effect string and adding it to the card’s replacement effects list. Mirrors Java’s KeywordInstance.applyReplacementEffect(List).

Source

pub fn apply_static_ability(&self, card: &mut Card)

Apply this keyword’s static abilities to a card by parsing each static ability string and adding it to the card’s static abilities list. Mirrors Java’s KeywordInstance.applyStaticAbility(List).

Source

pub fn copy(&self) -> Self

Create a deep copy of this keyword instance. Mirrors Java’s KeywordInstance.copy(Card, boolean).

Source

pub fn redundant(&self, other: &Self) -> bool

Check if this keyword instance is redundant with another (same keyword text). Mirrors Java’s KeywordInstance.redundant(Collection).

Source

pub fn has_s_var(&self, name: &str) -> bool

Check if this keyword instance has an SVar with the given name. Mirrors Java’s KeywordInstance.hasSVar(String).

Source

pub fn remove_s_var(&mut self, name: &str)

Remove an SVar from this keyword instance by name. Mirrors Java’s KeywordInstance.removeSVar(String).

Trait Implementations§

Source§

impl Clone for KeywordInstance

Source§

fn clone(&self) -> KeywordInstance

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 Debug for KeywordInstance

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

Source§

fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
Source§

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Gets the layout of the type.
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The type for metadata in pointers and references to Self.
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V