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: TriggerTypeCheap 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
impl Trigger
pub fn get_id(&self) -> u32
pub fn set_id(&mut self, id: u32)
Sourcepub fn host_card_id(&self) -> CardId
pub fn host_card_id(&self) -> CardId
Returns the host card’s ID. Mirrors Java’s getHostCard().getId().
Sourcepub fn host_controller(&self, game: &GameState) -> PlayerId
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.
pub fn get_mode(&self) -> &dyn TriggerBehavior
pub fn origin_zone(&self) -> Option<ZoneType>
pub fn destination_zone(&self) -> Option<ZoneType>
pub fn set_mode(&mut self, mode: Box<dyn TriggerBehavior>)
pub fn get_trigger_remembered(&self) -> &[AbilityValue]
pub fn bind_host_card_id(&mut self, host_card: CardId)
pub fn get_active_zone(&self) -> &[ZoneType]
pub fn set_active_zone(&mut self, zones: Vec<ZoneType>)
pub fn is_intrinsic(&self) -> bool
pub fn set_intrinsic(&mut self, intrinsic: bool)
pub fn get_overriding_ability(&self) -> Option<&SpellAbility>
pub fn set_overriding_ability(&mut self, overriding_ability: SpellAbility)
pub fn get_spawning_ability(&self) -> Option<&SpellAbility>
pub fn set_spawning_ability(&mut self, ability: SpellAbility)
Source§impl Trigger
impl Trigger
pub fn set_trigger_phases(&mut self, phases: Vec<PhaseType>)
Sourcepub fn reset_i_ds(next_id: &mut u32)
pub fn reset_i_ds(next_id: &mut u32)
Java parity shim for Trigger.resetIDs().
pub fn to_string_with_active(&self, active: bool) -> String
Sourcepub fn replace_ability_text(
&self,
desc: &str,
game: &GameState,
host_card: CardId,
activating_player: PlayerId,
) -> String
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.
pub fn replace_ability_text_with_ability( &self, desc: &str, sa: Option<SpellAbility>, game: &GameState, host_card: CardId, activating_player: PlayerId, ) -> String
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
Sourcepub fn phases_check(
&self,
game: &GameState,
host_card: CardId,
event_phase: Option<PhaseType>,
) -> bool
pub fn phases_check( &self, game: &GameState, host_card: CardId, event_phase: Option<PhaseType>, ) -> bool
Mirrors Java Trigger.phasesCheck() for common phase/turn params.
Sourcepub fn requirements_check(&self, game: &GameState, host_card: CardId) -> bool
pub fn requirements_check(&self, game: &GameState, host_card: CardId) -> bool
Mirrors Java Trigger.requirementsCheck() subset used in current engine.
Sourcepub fn check_resolved_limit(&self, game: &GameState, host_card: CardId) -> bool
pub fn check_resolved_limit(&self, game: &GameState, host_card: CardId) -> bool
Mirrors Java Trigger.checkResolvedLimit() (approximation with per-card counter).
Sourcepub fn check_activation_limit(
&self,
game: &GameState,
host_card: CardId,
) -> bool
pub fn check_activation_limit( &self, game: &GameState, host_card: CardId, ) -> bool
Mirrors Java Trigger.checkActivationLimit().
pub fn get_activations_this_turn( &self, game: &GameState, host_card: CardId, ) -> u32
Sourcepub fn matches_optional_valid_card_filter(
&self,
filter: &Option<CompiledSelector>,
card_id: Option<CardId>,
game: &GameState,
) -> bool
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.
Sourcepub fn matches_optional_valid_player_filter(
&self,
filter: &Option<CompiledSelector>,
player_id: Option<PlayerId>,
game: &GameState,
) -> bool
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.
Sourcepub fn matches_valid_card_filter(
&self,
filter: &CompiledSelector,
card_id: CardId,
game: &GameState,
) -> bool
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.
Sourcepub fn matches_valid_player_filter(
&self,
filter: &CompiledSelector,
player: PlayerId,
game: &GameState,
) -> bool
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.
Sourcepub fn matches_valid_player_filter_with_controller(
&self,
filter: &CompiledSelector,
player: PlayerId,
source_controller: PlayerId,
) -> bool
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.
Sourcepub fn matches_counter_type_filter(
expected: &Option<String>,
actual: &Option<String>,
) -> bool
pub fn matches_counter_type_filter( expected: &Option<String>, actual: &Option<String>, ) -> bool
Matches an optional counter-type filter.
Sourcepub fn matches_zone_filter(
expected: &Option<ZoneType>,
actual: Option<ZoneType>,
) -> bool
pub fn matches_zone_filter( expected: &Option<ZoneType>, actual: Option<ZoneType>, ) -> bool
Matches zone filters (origin and/or destination).
Sourcepub fn matches_valid_sa_filter(&self, filter: &str, sa: &SpellAbility) -> bool
pub fn matches_valid_sa_filter(&self, filter: &str, sa: &SpellAbility) -> bool
Matches spell-ability filter tokens.
Sourcepub fn matches_damage_target_filter(
&self,
filter: &Option<CompiledSelector>,
run_params: &RunParams,
game: &GameState,
strict_card_filter: bool,
) -> bool
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.
pub fn get_activations_this_game( &self, game: &GameState, host_card: CardId, ) -> u32
Sourcepub fn meets_requirements_on_triggered_objects(
&self,
game: &GameState,
run_params: &RunParams,
host_card: CardId,
) -> bool
pub fn meets_requirements_on_triggered_objects( &self, game: &GameState, run_params: &RunParams, host_card: CardId, ) -> bool
Mirrors Java Trigger.meetsRequirementsOnTriggeredObjects() subset.
pub fn add_remembered<T: Into<AbilityValue>>(&mut self, item: T)
pub fn is_static(&self) -> bool
Sourcepub fn is_mana_ability(
&self,
game: &GameState,
host_card: CardId,
activating_player: PlayerId,
) -> bool
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).
pub fn add_remembered_many<T: Into<AbilityValue>, I: IntoIterator<Item = T>>( &mut self, items: I, )
pub fn copy(&self, next_id: &mut u32, keep_id: bool) -> Self
pub fn copy_to_host( &self, new_host: Card, lki: bool, keep_text_changes: bool, spell_ability: Option<SpellAbility>, next_id: &mut u32, ) -> Self
Sourcepub fn trigger_run(&self, game: &mut GameState, host_card: CardId)
pub fn trigger_run(&self, game: &mut GameState, host_card: CardId)
Tracks trigger activation on the host card.
Sourcepub fn ensure_ability(
&self,
game: &GameState,
host_card: CardId,
activating_player: PlayerId,
) -> Option<SpellAbility>
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.
pub fn ensure_ability_mut( &mut self, game: &GameState, host_card: CardId, activating_player: PlayerId, ) -> Option<&mut SpellAbility>
pub fn is_chapter(&self) -> bool
pub fn get_chapter(&self) -> Option<i32>
pub fn is_last_chapter(&self, card: &Card) -> bool
pub fn while_keyword_check(&self, _param: &str, _run_params: &RunParams) -> bool
pub fn set_triggering_objects( &self, sa: &mut SpellAbility, params: &RunParams, game: &GameState, _host_card: CardId, _host_controller: PlayerId, )
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.
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
fn base(&self) -> &CardTraitBase
CardTraitBase. Implementors own a
CardTraitBase (directly or transitively) and return a reference.Source§fn resolve_source_player(&self, src_card: &Card) -> PlayerId
fn resolve_source_player(&self, src_card: &Card) -> PlayerId
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.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
fn matches_valid( &self, target: &MatchValidTarget<'_>, valids: &[&str], src_card: Option<&Card>, ) -> bool
matchesValid(Object, String[], Card).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
fn matches_valid_card(&self, expr: &str, card: &Card, source: &Card) -> bool
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").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
fn matches_valid_player( &self, expr: &str, player: PlayerId, source: &Card, ) -> bool
matches_valid for
player targets.fn matches_compiled_valid_player( &self, selector: &CompiledSelector, player: PlayerId, source: &Card, ) -> bool
Source§impl CardTraitIrOwner for Trigger
impl CardTraitIrOwner for Trigger
Source§impl<'de> Deserialize<'de> for Trigger
impl<'de> Deserialize<'de> for Trigger
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Trigger
Auto Trait Implementations§
impl !RefUnwindSafe for Trigger
impl !UnwindSafe for Trigger
impl Freeze for Trigger
impl Send for Trigger
impl Sync for Trigger
impl Unpin for Trigger
impl UnsafeUnpin for Trigger
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CallHasher for T
impl<T> CallHasher for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.