Skip to main content

Module spell_ability_effect

Module spell_ability_effect 

Source
Expand description

SpellAbilityEffect — base trait and utility free functions for effects.

Mirrors Java’s SpellAbilityEffect.java. In Java this is an abstract class with many protected static helpers; in Rust we keep the trait for interface parity and provide the utility methods as free functions that take (&GameState, &SpellAbility).

Enums§

AtEotAction
AtEOT$ <action> — delayed-trigger action token. Mirrors Java’s SpellAbilityEffect.registerDelayedTrigger location arg.

Traits§

SpellAbilityEffect
Base trait for all spell ability effect implementations.

Functions§

add_forget_on_moved_trigger
Add a “forget on moved” trigger to a card — when the card changes zones, it is removed from its host’s remembered list. Mirrors Java’s SpellAbilityEffect.addForgetOnMovedTrigger(SpellAbility, Card, String).
add_self_trigger_at_eot
check_valid_duration
Validate a Duration$ param against the host card’s current state. Mirrors Java’s SpellAbilityEffect.checkValidDuration(String, SpellAbility).
create_effect
Create a temporary “effect” card in the command zone. Mirrors Java’s SpellAbilityEffect.createEffect(SpellAbility, Player, String, String).
exile_effect_command
Execute the “exile with” command — exile a card and track the exile source. Mirrors Java’s SpellAbilityEffect.exileEffectCommand(Game, SpellAbility, Card).
get_defined_cards_or_targeted
Get defined cards, falling back to targeted cards if no Defined$ param.
get_defined_cards_or_targeted_param
Get defined cards with a custom param name, falling back to targeted.
get_defined_players_or_targeted
Get defined players, falling back to targeted players if no Defined$ param.
get_new_chooser
Ask the activator’s controller to pick a replacement chooser when the original chooser has lost the game mid-effect (CR 800.4g).
get_stack_description_with_subs
Render the stack description for a SpellAbility, including sub-ability text. Mirrors Java SpellAbilityEffect.getStackDescriptionWithSubs(Map, SpellAbility).
get_target_cards
Get target cards for a spell ability. If the SA uses targeting, returns the chosen target card(s). Otherwise, resolves the Defined$ parameter (defaulting to “Self”).
get_target_players
Get target players for a spell ability. If the SA uses targeting, returns the chosen target player(s). Otherwise, resolves the Defined$ parameter (defaulting to “You”).
handle_exiled_with
Track which card exiled another card, for “exile until” effects. Mirrors Java’s SpellAbilityEffect.handleExiledWith(SpellAbility, Card).
register_at_eot
Register a delayed trigger that fires at end of turn and performs action on remembered cards. Mirrors Java SpellAbilityEffect.registerDelayedTrigger(sa, location, iterable).
replace_dying
Set up the “replace dying” replacement effect for cards that should be exiled instead of dying this turn.
run
Run/resolve a spell ability effect (the main entry point for effect dispatch). Mirrors Java’s SpellAbilityEffect.run(SpellAbility) which calls resolve().
tokenize_string
Tokenize a description string, replacing CARDNAME with the actual card name and NICKNAME with a short version. Mirrors Java’s SpellAbilityEffect.tokenizeString(SpellAbility, String).