Skip to main content

Trigger

Struct Trigger 

Source
pub struct Trigger {
    pub id: u32,
    pub base: TriggerReplacementBase,
    pub kind: TriggerType,
    pub mode: Box<dyn TriggerBehavior>,
    pub ir: TriggerIr,
    pub execute: String,
    pub optional: bool,
    pub description: String,
    pub static_trigger: bool,
    pub trigger_remembered: Vec<AbilityValue>,
    pub spawning_ability: Option<SpellAbility>,
}

Fields§

§id: u32§base: TriggerReplacementBase§kind: TriggerType

Cheap discriminant for pattern-matching (replaces matches!(t.mode, TriggerMode::X { .. })).

§mode: Box<dyn TriggerBehavior>§ir: TriggerIr§execute: String§optional: bool§description: String§static_trigger: bool§trigger_remembered: Vec<AbilityValue>§spawning_ability: Option<SpellAbility>

Implementations§

Source§

impl Trigger

Source

pub fn get_id(&self) -> u32

Source

pub fn set_id(&mut self, id: u32)

Source

pub fn host_card_id(&self) -> CardId

Returns the host card’s ID. Mirrors Java’s getHostCard().getId().

Source

pub fn host_controller(&self, game: &GameState) -> PlayerId

Returns the host card’s current controller from live game state. Use this instead of the stored host card’s controller, which may be stale.

Source

pub fn get_mode(&self) -> &dyn TriggerBehavior

Source

pub fn origin_zone(&self) -> Option<ZoneType>

Source

pub fn destination_zone(&self) -> Option<ZoneType>

Source

pub fn set_mode(&mut self, mode: Box<dyn TriggerBehavior>)

Source

pub fn get_trigger_remembered(&self) -> &[AbilityValue]

Source

pub fn bind_host_card_id(&mut self, host_card: CardId)

Source

pub fn get_active_zone(&self) -> &[ZoneType]

Source

pub fn set_active_zone(&mut self, zones: Vec<ZoneType>)

Source

pub fn is_intrinsic(&self) -> bool

Source

pub fn set_intrinsic(&mut self, intrinsic: bool)

Source

pub fn get_overriding_ability(&self) -> Option<&SpellAbility>

Source

pub fn set_overriding_ability(&mut self, overriding_ability: SpellAbility)

Source

pub fn get_spawning_ability(&self) -> Option<&SpellAbility>

Source

pub fn set_spawning_ability(&mut self, ability: SpellAbility)

Source§

impl Trigger

Source

pub fn set_trigger_phases(&mut self, phases: Vec<PhaseType>)

Source

pub fn reset_i_ds(next_id: &mut u32)

Java parity shim for Trigger.resetIDs().

Source

pub fn to_string_with_active(&self, active: bool) -> String

Source

pub fn replace_ability_text( &self, desc: &str, game: &GameState, host_card: CardId, activating_player: PlayerId, ) -> String

Minimal ABILITY replacement parity used by stack text paths.

Source

pub fn replace_ability_text_with_ability( &self, desc: &str, sa: Option<SpellAbility>, game: &GameState, host_card: CardId, activating_player: PlayerId, ) -> String

Source

pub fn replace_ability_text_for_stack( &self, desc: &str, sa: Option<SpellAbility>, _for_stack: bool, game: &GameState, host_card: CardId, activating_player: PlayerId, ) -> String

Source

pub fn phases_check( &self, game: &GameState, host_card: CardId, event_phase: Option<PhaseType>, ) -> bool

Mirrors Java Trigger.phasesCheck() for common phase/turn params.

Source

pub fn requirements_check(&self, game: &GameState, host_card: CardId) -> bool

Mirrors Java Trigger.requirementsCheck() subset used in current engine.

Source

pub fn check_resolved_limit(&self, game: &GameState, host_card: CardId) -> bool

Mirrors Java Trigger.checkResolvedLimit() (approximation with per-card counter).

Source

pub fn check_activation_limit( &self, game: &GameState, host_card: CardId, ) -> bool

Mirrors Java Trigger.checkActivationLimit().

Source

pub fn get_activations_this_turn( &self, game: &GameState, host_card: CardId, ) -> u32

Source

pub fn matches_optional_valid_card_filter( &self, filter: &Option<CompiledSelector>, card_id: Option<CardId>, game: &GameState, ) -> bool

Polymorphic Valid... check for optional card payloads. Mirrors Java’s matchesValidParam flow by routing through CardTrait.

Source

pub fn matches_optional_valid_player_filter( &self, filter: &Option<CompiledSelector>, player_id: Option<PlayerId>, game: &GameState, ) -> bool

Polymorphic Valid... check for optional player payloads. Mirrors Java’s matchesValidParam flow by routing through CardTrait.

Source

pub fn matches_valid_card_filter( &self, filter: &CompiledSelector, card_id: CardId, game: &GameState, ) -> bool

Matches a required card against a Valid... card filter from this trigger’s host context.

Source

pub fn matches_valid_player_filter( &self, filter: &CompiledSelector, player: PlayerId, game: &GameState, ) -> bool

Matches a required player against a Valid... player filter from this trigger’s host context.

Source

pub fn matches_valid_player_filter_with_controller( &self, filter: &CompiledSelector, player: PlayerId, source_controller: PlayerId, ) -> bool

Matches a required player against a Valid... player filter from an explicit source controller.

Source

pub fn matches_counter_type_filter( expected: &Option<String>, actual: &Option<String>, ) -> bool

Matches an optional counter-type filter.

Source

pub fn matches_zone_filter( expected: &Option<ZoneType>, actual: Option<ZoneType>, ) -> bool

Matches zone filters (origin and/or destination).

Source

pub fn matches_valid_sa_filter(&self, filter: &str, sa: &SpellAbility) -> bool

Matches spell-ability filter tokens.

Source

pub fn matches_damage_target_filter( &self, filter: &Option<CompiledSelector>, run_params: &RunParams, game: &GameState, strict_card_filter: bool, ) -> bool

Matches a damage target filter for either player or card targets.

Source

pub fn get_activations_this_game( &self, game: &GameState, host_card: CardId, ) -> u32

Source

pub fn meets_requirements_on_triggered_objects( &self, game: &GameState, run_params: &RunParams, host_card: CardId, ) -> bool

Mirrors Java Trigger.meetsRequirementsOnTriggeredObjects() subset.

Source

pub fn add_remembered<T: Into<AbilityValue>>(&mut self, item: T)

Source

pub fn is_static(&self) -> bool

Source

pub fn is_mana_ability( &self, game: &GameState, host_card: CardId, activating_player: PlayerId, ) -> bool

Mirrors Java’s Trigger.isManaAbility(). A trigger is a mana ability only if its mode is TapsForMana or ManaAdded AND the resulting SpellAbility itself is a mana ability (has a mana part).

Source

pub fn add_remembered_many<T: Into<AbilityValue>, I: IntoIterator<Item = T>>( &mut self, items: I, )

Source

pub fn copy(&self, next_id: &mut u32, keep_id: bool) -> Self

Source

pub fn copy_to_host( &self, new_host: Card, lki: bool, keep_text_changes: bool, spell_ability: Option<SpellAbility>, next_id: &mut u32, ) -> Self

Source

pub fn trigger_run(&self, game: &mut GameState, host_card: CardId)

Tracks trigger activation on the host card.

Source

pub fn ensure_ability( &self, game: &GameState, host_card: CardId, activating_player: PlayerId, ) -> Option<SpellAbility>

Ensures trigger execute ability can be built from host SVar.

Source

pub fn ensure_ability_mut( &mut self, game: &GameState, host_card: CardId, activating_player: PlayerId, ) -> Option<&mut SpellAbility>

Source

pub fn is_chapter(&self) -> bool

Source

pub fn get_chapter(&self) -> Option<i32>

Source

pub fn is_last_chapter(&self, card: &Card) -> bool

Source

pub fn while_keyword_check(&self, _param: &str, _run_params: &RunParams) -> bool

Source

pub fn set_triggering_objects( &self, sa: &mut SpellAbility, params: &RunParams, game: &GameState, _host_card: CardId, _host_controller: PlayerId, )

Source

pub fn build_triggered_spell_ability( &self, game: &GameState, host_card: CardId, host_controller: PlayerId, trigger_index: usize, params: &RunParams, ) -> SpellAbility

Trait Implementations§

Source§

impl CardTrait for Trigger

Mirrors Java’s Trigger extends CardTraitBase override of matchesValid: when this instanceof Trigger and a spawning ability is present, the source player resolves to the spawning ability’s activating player rather than the source card’s controller.

Source§

fn base(&self) -> &CardTraitBase

Borrow the underlying CardTraitBase. Implementors own a CardTraitBase (directly or transitively) and return a reference.
Source§

fn resolve_source_player(&self, src_card: &Card) -> PlayerId

Resolves the player whose perspective is used for Valid$ expressions. Default matches Java’s base behavior (source card’s controller). Trigger overrides — mirrors this instanceof Trigger in Java CardTraitBase.matchesValid(Object, String[], Card) at line 214.
Source§

fn matches_compiled_valid( &self, target: &MatchValidTarget<'_>, selector: &CompiledSelector, src_card: Option<&Card>, ) -> bool

Source§

fn matches_valid( &self, target: &MatchValidTarget<'_>, valids: &[&str], src_card: Option<&Card>, ) -> bool

Mirrors matchesValid(Object, String[], Card).
Source§

fn matches_valid_param( &self, param: &str, target: &MatchValidTarget<'_>, src_card: Option<&Card>, ) -> bool

Source§

fn matches_valid_card(&self, expr: &str, card: &Card, source: &Card) -> bool

Ergonomic comma-separated-expression wrapper over matches_valid for card targets. Mirrors Java’s matchesValid(Object, String[], Card) call pattern where valids is often a single comma-separated string (e.g. "Creature.YouCtrl,Artifact").
Source§

fn matches_compiled_valid_card( &self, selector: &CompiledSelector, card: &Card, source: &Card, ) -> bool

Source§

fn matches_valid_player( &self, expr: &str, player: PlayerId, source: &Card, ) -> bool

Ergonomic comma-separated-expression wrapper over matches_valid for player targets.
Source§

fn matches_compiled_valid_player( &self, selector: &CompiledSelector, player: PlayerId, source: &Card, ) -> bool

Source§

impl CardTraitIrOwner for Trigger

Source§

type Ir = TriggerIr

Source§

fn ir(&self) -> &Self::Ir

Source§

fn card_trait_requirements(&self) -> &CardTraitRequirementsIr

Source§

fn meets_card_trait_requirements( &self, game: &GameState, source: &Card, svar_source: &dyn HasSVars, ) -> bool

Source§

impl Clone for Trigger

Source§

fn clone(&self) -> Trigger

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 Trigger

Source§

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

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

impl<'de> Deserialize<'de> for Trigger

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Trigger

Source§

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

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

impl Eq for Trigger

Source§

impl Hash for Trigger

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Trigger

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl Serialize for Trigger

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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> CallHasher for T
where T: Hash + ?Sized,

Source§

default fn get_hash<H, B>(value: &H, build_hasher: &B) -> u64
where H: Hash + ?Sized, B: BuildHasher,

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

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

Source§

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

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

Source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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