Skip to main content

EffectContext

Struct EffectContext 

Source
pub struct EffectContext<'a> {
    pub game: &'a mut GameState,
    pub combat: Option<&'a mut CombatState>,
    pub agents: &'a mut [Box<dyn PlayerAgent>],
    pub trigger_handler: &'a mut TriggerHandler,
    pub token_templates: &'a HashMap<String, Card>,
    pub token_art_variants: &'a HashMap<(String, String), usize>,
    pub token_fallback: &'a HashMap<String, String>,
    pub edition_dates: &'a HashMap<String, String>,
    pub mana_pools: &'a mut Vec<ManaPool>,
    pub parent_target_card: Option<CardId>,
    pub rng: &'a mut dyn GameRng,
}
Expand description

Everything an effect needs to resolve.

Fields§

§game: &'a mut GameState§combat: Option<&'a mut CombatState>§agents: &'a mut [Box<dyn PlayerAgent>]§trigger_handler: &'a mut TriggerHandler§token_templates: &'a HashMap<String, Card>§token_art_variants: &'a HashMap<(String, String), usize>

Token art variant counts for game-RNG parity with Java.

§token_fallback: &'a HashMap<String, String>

Token fallback codes: edition_code → fallback_edition_code.

§edition_dates: &'a HashMap<String, String>

Edition release dates: edition_code → “YYYY-MM-DD”. Used to sort editions newest-first for token fallback (Java parity).

§mana_pools: &'a mut Vec<ManaPool>§parent_target_card: Option<CardId>

CardId of the parent SA’s chosen target card, propagated through the sub-ability chain so that Defined$ ParentTarget effects can resolve it. Mirrors Java’s SpellAbility.getParentTargetCard() (via getRootAbility()).

§rng: &'a mut dyn GameRng

Pluggable RNG for game effects (shuffles, coin flips, dice rolls). Parity tests inject a JavaRandom-backed implementation; normal gameplay uses the default ThreadRngAdapter.

Implementations§

Source§

impl EffectContext<'_>

Source

pub fn token_art_variant_count( &self, token_script: &str, edition_code: &str, ) -> usize

Get the number of art variants for a token in a given edition, following TokenFallbackCode chains. Returns 1 if not found. When edition_code is empty, scans all editions and returns the first match (mirrors Java’s fallbackToken which iterates all editions).

Source

pub fn sync_token_art_rng(&mut self, token_script: &str, sa: &SpellAbility)

Consume game-RNG calls to match Java’s token prototype creation. Java calls Aggregates.random(Set) which does nextInt() per element, plus PaperToken.getImageKey() which does nextInt(artIndex).

Source

pub fn move_card( &mut self, card_id: CardId, dest_zone: ZoneType, dest_owner: PlayerId, )

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for EffectContext<'a>

§

impl<'a> !Send for EffectContext<'a>

§

impl<'a> !Sync for EffectContext<'a>

§

impl<'a> !UnwindSafe for EffectContext<'a>

§

impl<'a> Freeze for EffectContext<'a>

§

impl<'a> Unpin for EffectContext<'a>

§

impl<'a> UnsafeUnpin for EffectContext<'a>

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<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> 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, 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