Skip to main content

TriggerHandler

Struct TriggerHandler 

Source
pub struct TriggerHandler { /* private fields */ }
Expand description

Mirrors Java’s TriggerHandler — central trigger dispatcher. In Java, lives on Game. In Rust, lives on GameLoop because active_triggers and waiting_triggers are transient processing state.

Implementations§

Source§

impl TriggerHandler

Source

pub fn new() -> Self

Source

pub fn run_trigger(&mut self, mode: TriggerType, params: RunParams, hold: bool)

Mirrors Java’s runTrigger() — main entry point. Called from game actions when events occur. If hold is true, event is queued; otherwise it’s also queued (all triggers go through the waiting queue for APNAP ordering).

Source

pub fn run_trigger_with_game( &mut self, game: &GameState, mode: TriggerType, params: RunParams, hold: bool, ) -> Vec<PendingTrigger>

Java-parity entrypoint that can resolve triggers immediately when the event should not be held/frozen.

Source

pub fn parse_trigger(&mut self, raw: &str) -> Option<Trigger>

Java parity wrapper for TriggerHandler.parseTrigger(String).

Source

pub fn collect_trigger_for_waiting( &mut self, mode: TriggerType, params: RunParams, )

Java parity wrapper for TriggerHandler.collectTriggerForWaiting(…).

Source

pub fn waiting_trigger_count(&self) -> usize

Number of triggers in the waiting queue (for debug/diagnostics).

Source

pub fn pre_matched_trigger_count(&self) -> usize

Source

pub fn has_number_drawn_triggers(&self, game: &GameState) -> bool

Match waiting triggers NOW, while source cards are still in their current zones. Stores results in pre_matched_triggers so that a subsequent run_waiting_triggers call returns them even if SBA has since moved the source card (e.g. Raptor Hatchling dying to combat damage before triggers go on the stack).

Call this immediately after firing triggers and before SBA. Returns true if any active trigger is a Drawn trigger with Number$ set. Used to gate flush_waiting_triggers during draws to avoid disrupting other trigger matching when no Number$-gated Drawn triggers exist.

Source

pub fn flush_waiting_triggers(&mut self, game: &GameState)

Source

pub fn run_waiting_triggers(&mut self, game: &GameState) -> Vec<PendingTrigger>

Mirrors Java’s runWaitingTriggers(). Drains waiting queue, matches triggers, returns PendingTriggers. The caller (game_loop) handles OptionalDecider$ prompting.

Source

pub fn process_waiting_triggers( &mut self, mana_pools: &[ManaPool], game: &mut GameState, agents: &mut [Box<dyn PlayerAgent>], ) -> Vec<TriggerPushLog>

Source

pub fn process_pending_triggers( &mut self, mana_pools: &[ManaPool], game: &mut GameState, agents: &mut [Box<dyn PlayerAgent>], pending: Vec<PendingTrigger>, ) -> Vec<TriggerPushLog>

Source

pub fn register_delayed_trigger(&mut self, delayed: DelayedTrigger)

Register a delayed trigger (one-shot, fires once then is removed). Mirrors Java’s TriggerHandler.registerDelayedTrigger().

Source

pub fn clear_delayed_trigger(&mut self)

Source

pub fn register_this_turn_delayed_trigger(&mut self, delayed: DelayedTrigger)

Source

pub fn clear_this_turn_delayed_trigger(&mut self)

Source

pub fn register_player_defined_delayed_trigger( &mut self, player: PlayerId, delayed: DelayedTrigger, )

Source

pub fn clear_player_defined_delayed_trigger(&mut self)

Source

pub fn handle_player_defined_del_triggers(&mut self, player: PlayerId)

Source

pub fn reset_active_triggers(&mut self, game: &GameState)

Mirrors Java’s resetActiveTriggers(). Scans all cards in game, collects active triggers.

Source

pub fn register_active_trigger(&mut self, game: &GameState, card_id: CardId)

Mirrors Java’s registerActiveTrigger(card). Registers a single card’s triggers.

Source

pub fn clear_active_triggers(&mut self)

Java parity wrapper for TriggerHandler.clearActiveTriggers().

Source

pub fn register_active_ltb_trigger(&mut self, game: &GameState, card_id: CardId)

Java parity wrapper for TriggerHandler.registerActiveLTBTrigger(card). Registers all of a card’s triggers as active, using current trigger indices.

Source

pub fn register_one_trigger( &mut self, game: &GameState, card_id: CardId, trigger_index: usize, )

Java parity wrapper for TriggerHandler.registerOneTrigger(…).

Source

pub fn unregister_active_triggers(&mut self, card_id: CardId)

Remove triggers for a card that left a trigger zone.

Source

pub fn clear_waiting_triggers(&mut self)

Source

pub fn on_player_lost(&mut self, player: PlayerId)

Source

pub fn suppress_mode(&mut self, mode: TriggerType)

Source

pub fn set_suppress_all_triggers(&mut self, suppress: bool)

Source

pub fn get_active_trigger( &self, game: &GameState, mode: TriggerType, params: &RunParams, ) -> Vec<Trigger>

Mirrors Java’s TriggerHandler.getActiveTrigger(TriggerType, Map<AbilityKey, Object>). Returns all active triggers that can run for the given mode and params.

Source

pub fn is_trigger_suppressed(&self, mode: TriggerType) -> bool

Source

pub fn clear_suppression(&mut self, mode: TriggerType)

Trait Implementations§

Source§

impl Clone for TriggerHandler

Source§

fn clone(&self) -> TriggerHandler

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 TriggerHandler

Source§

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

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

impl Default for TriggerHandler

Source§

fn default() -> Self

Returns the “default value” for a type. 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