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 GameRngPluggable 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<'_>
impl EffectContext<'_>
Sourcepub fn token_art_variant_count(
&self,
token_script: &str,
edition_code: &str,
) -> usize
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).
Sourcepub fn sync_token_art_rng(&mut self, token_script: &str, sa: &SpellAbility)
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).