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: KeywordInstanceDataThe 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
impl KeywordInstance
Sourcepub fn new(data: KeywordInstanceData) -> Self
pub fn new(data: KeywordInstanceData) -> Self
Create a new keyword instance from base data.
Sourcepub fn create_traits(&mut self)
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).
Sourcepub fn add_trigger(&mut self, trigger: String)
pub fn add_trigger(&mut self, trigger: String)
Add a trigger definition string.
Mirrors Java’s KeywordInstance.addTrigger(Trigger).
Sourcepub fn add_replacement(&mut self, replacement: String)
pub fn add_replacement(&mut self, replacement: String)
Add a replacement effect definition string.
Mirrors Java’s KeywordInstance.addReplacement(ReplacementEffect).
Sourcepub fn add_spell_ability(&mut self, ability: String)
pub fn add_spell_ability(&mut self, ability: String)
Add a spell ability definition string.
Mirrors Java’s KeywordInstance.addSpellAbility(SpellAbility).
Sourcepub fn add_static_ability(&mut self, static_ab: String)
pub fn add_static_ability(&mut self, static_ab: String)
Add a static ability definition string.
Mirrors Java’s KeywordInstance.addStaticAbility(StaticAbility).
Sourcepub fn has_traits(&self) -> bool
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().
Sourcepub fn apply_spell_ability(&self, card: &mut Card)
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).
Sourcepub fn apply_trigger(&self, card: &mut Card)
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).
Sourcepub fn apply_replacement_effect(&self, card: &mut Card)
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).
Sourcepub fn apply_static_ability(&self, card: &mut Card)
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).
Sourcepub fn copy(&self) -> Self
pub fn copy(&self) -> Self
Create a deep copy of this keyword instance.
Mirrors Java’s KeywordInstance.copy(Card, boolean).
Sourcepub fn redundant(&self, other: &Self) -> bool
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).
Sourcepub fn has_s_var(&self, name: &str) -> bool
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).
Sourcepub fn remove_s_var(&mut self, name: &str)
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
impl Clone for KeywordInstance
Source§fn clone(&self) -> KeywordInstance
fn clone(&self) -> KeywordInstance
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more