pub trait SpellAbilityEffect {
// Required method
fn resolve(ctx: &mut EffectContext<'_>, sa: &SpellAbility);
// Provided methods
fn get_stack_description(sa: &SpellAbility) -> String { ... }
fn build_spell_ability(_sa: &mut SpellAbility) { ... }
fn tokenize_string(
game: &GameState,
sa: &SpellAbility,
desc: &str,
) -> String { ... }
fn add_forget_on_moved_trigger(
game: &mut GameState,
host_id: CardId,
remembered_card_id: CardId,
) { ... }
fn create_effect(
game: &mut GameState,
sa: &SpellAbility,
name: &str,
image: &str,
) -> CardId { ... }
fn run(ctx: &mut EffectContext<'_>, sa: &SpellAbility) { ... }
fn handle_exiled_with(
game: &mut GameState,
sa: &SpellAbility,
exiled_card_id: CardId,
) { ... }
fn exile_effect_command(
game: &mut GameState,
trigger_handler: &mut TriggerHandler,
sa: &SpellAbility,
card_id: CardId,
) { ... }
fn get_stack_description_with_subs(
game: &GameState,
sa: &SpellAbility,
) -> String { ... }
fn get_new_chooser(
game: &GameState,
agents: &mut [Box<dyn PlayerAgent>],
sa: &SpellAbility,
loser: PlayerId,
) -> Option<PlayerId> { ... }
}Expand description
Base trait for all spell ability effect implementations.
Mirrors Java’s abstract SpellAbilityEffect class.
Each effect type provides a resolve implementation that performs
the actual game-state mutation.
Every effect is a stateless unit struct, so all methods are associated
functions (no self). The trait is therefore not object-safe — runtime
dispatch through dyn SpellAbilityEffect is intentionally unsupported;
dispatch happens via the effect_dispatch! macro at compile time.
Required Methods§
Sourcefn resolve(ctx: &mut EffectContext<'_>, sa: &SpellAbility)
fn resolve(ctx: &mut EffectContext<'_>, sa: &SpellAbility)
Resolve this effect for the given spell ability.
Provided Methods§
Sourcefn get_stack_description(sa: &SpellAbility) -> String
fn get_stack_description(sa: &SpellAbility) -> String
Return the stack description for this effect. Defaults to the spell ability’s own description.
Sourcefn build_spell_ability(_sa: &mut SpellAbility)
fn build_spell_ability(_sa: &mut SpellAbility)
Build/configure the spell ability after construction. Default is a no-op; some effects override this to add parameters.
Sourcefn tokenize_string(game: &GameState, sa: &SpellAbility, desc: &str) -> String
fn tokenize_string(game: &GameState, sa: &SpellAbility, desc: &str) -> String
Tokenize a description string, replacing CARDNAME with the card’s name.
Mirrors Java’s SpellAbilityEffect.tokenizeString(SpellAbility, String).
Sourcefn add_forget_on_moved_trigger(
game: &mut GameState,
host_id: CardId,
remembered_card_id: CardId,
)
fn add_forget_on_moved_trigger( game: &mut GameState, host_id: CardId, remembered_card_id: CardId, )
Add a “forget on moved” trigger for remembered cards.
Mirrors Java’s SpellAbilityEffect.addForgetOnMovedTrigger(SpellAbility, Card, String).
Sourcefn create_effect(
game: &mut GameState,
sa: &SpellAbility,
name: &str,
image: &str,
) -> CardId
fn create_effect( game: &mut GameState, sa: &SpellAbility, name: &str, image: &str, ) -> CardId
Create a temporary effect card in the command zone.
Mirrors Java’s SpellAbilityEffect.createEffect(SpellAbility, Player, String, String).
Sourcefn run(ctx: &mut EffectContext<'_>, sa: &SpellAbility)
fn run(ctx: &mut EffectContext<'_>, sa: &SpellAbility)
Run the effect (resolve entry point).
Mirrors Java’s SpellAbilityEffect.run(SpellAbility).
Sourcefn handle_exiled_with(
game: &mut GameState,
sa: &SpellAbility,
exiled_card_id: CardId,
)
fn handle_exiled_with( game: &mut GameState, sa: &SpellAbility, exiled_card_id: CardId, )
Track which card exiled another card, for “exile until” effects.
Mirrors Java’s SpellAbilityEffect.handleExiledWith(SpellAbility, Card).
Sourcefn exile_effect_command(
game: &mut GameState,
trigger_handler: &mut TriggerHandler,
sa: &SpellAbility,
card_id: CardId,
)
fn exile_effect_command( game: &mut GameState, trigger_handler: &mut TriggerHandler, sa: &SpellAbility, card_id: CardId, )
Execute the exile-with command.
Mirrors Java’s SpellAbilityEffect.exileEffectCommand(Game, SpellAbility, Card).
Sourcefn get_stack_description_with_subs(
game: &GameState,
sa: &SpellAbility,
) -> String
fn get_stack_description_with_subs( game: &GameState, sa: &SpellAbility, ) -> String
Full stack-description with sub-ability concatenation.
Mirrors Java SpellAbilityEffect.getStackDescriptionWithSubs(Map, SpellAbility).
Sourcefn get_new_chooser(
game: &GameState,
agents: &mut [Box<dyn PlayerAgent>],
sa: &SpellAbility,
loser: PlayerId,
) -> Option<PlayerId>
fn get_new_chooser( game: &GameState, agents: &mut [Box<dyn PlayerAgent>], sa: &SpellAbility, loser: PlayerId, ) -> Option<PlayerId>
Resolve a replacement chooser when the original lost the game (CR 800.4g).
Mirrors Java SpellAbilityEffect.getNewChooser(SpellAbility, Player).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".