Expand description
AbilityUtils — utility functions for ability resolution.
Mirrors Java’s AbilityUtils.java.
This is the single source of truth for helper functions used across effects.
The effects::helpers module re-exports everything from here for backward
compatibility.
Enums§
- Defined
Card Token - Static (non-prefix)
Defined$tokens that refer to a set of cards. Prefix-based tokens (Triggered*,ValidGraveyard <filter>, …) stay as separate branches below since strum can’t match open-ended suffixes. - Defined
Player Token - Resolve a Defined$ parameter to a player ID. Mirrors Java’s AbilityUtils.getDefinedPlayers().
Functions§
- add_
splice_ effect - Add a single splice effect from a card onto a spell ability.
Mirrors Java’s
AbilityUtils.addSpliceEffect(SpellAbility, Card). - add_
splice_ effects - Add splice effects to a spell ability.
Mirrors Java’s
AbilityUtils.addSpliceEffects(SpellAbility). - apply_
ability_ text_ change_ effects - Apply ability text change effects (for non-descriptive ability text).
Mirrors Java’s
AbilityUtils.applyAbilityTextChangeEffects(String, CardTraitBase). - apply_
description_ text_ change_ effects - Apply description text change effects (includes strikethrough in Java UI;
in the Rust engine we just do the replacement).
Mirrors Java’s
AbilityUtils.applyDescriptionTextChangeEffects(String, CardTraitBase). - apply_
keyword_ text_ change_ effects - Apply keyword text change effects.
Mirrors Java’s
AbilityUtils.applyKeywordTextChangeEffects(String, Card). - apply_
mana_ color_ conversion - Apply mana color conversion rules to a mana conversion matrix.
Mirrors Java’s
AbilityUtils.applyManaColorConversion(ManaConversionMatrix, String). - apply_
text_ change_ effects - Apply text change effects from a card’s SVars to a string.
Mirrors Java’s
AbilityUtils.applyTextChangeEffects(String, boolean, Map, Map). - calculate_
amount - Calculate a numeric amount from a parameter string. Handles simple integers and “X” references.
- calculate_
unless_ cost - Calculate the cost for an UnlessCost$ clause.
Mirrors Java’s
AbilityUtils.calculateUnlessCost(SpellAbility, String, boolean). - count_
card_ types_ from_ list - Count distinct card types among a list of cards.
Mirrors Java’s
AbilityUtils.countCardTypesFromList(Iterable<Card>, boolean). - count_
sub_ types_ from_ list - Count distinct subtypes among a list of cards.
Mirrors Java’s
AbilityUtils.countSubTypesFromList(Iterable<Card>). - count_
super_ types_ from_ list - Count distinct supertypes among a list of cards.
Mirrors Java’s
AbilityUtils.countSuperTypesFromList(Iterable<Card>). - do_
x_ math - Apply arithmetic operators to a base value.
Mirrors Java’s
AbilityUtils.doXMath(int num, String operators, Card c, CardTraitBase ctb). - filter_
list_ by_ type - Filter a list of card IDs by a type/valid-cards expression.
Mirrors Java’s
AbilityUtils.filterListByType(CardCollectionView, String, SpellAbility). - get_
basic_ spells_ from_ play_ effect - Collect the basic spell abilities that a Play$ effect could cast from
tgt_card. Mirrors JavaAbilityUtils.getBasicSpellsFromPlayEffect(Card, Player). - get_
defined_ cards - Resolve
Defined$strings to a list of card IDs. Mirrors Java’sAbilityUtils.getDefinedCards(). - get_
defined_ entities - Resolve a
Defined$expression to a combined player + card list. Mirrors JavaAbilityUtils.getDefinedEntities(Card, String, CardTraitBase). - get_
defined_ objects - Resolve a
Defined$expression to a combined list of the targetedGameObjects — cards + players + spell abilities. Mirrors JavaAbilityUtils.getDefinedObjects(Card, String, CardTraitBase). - get_
defined_ players - Resolve
Defined$strings to a list of player IDs. Mirrors Java’sAbilityUtils.getDefinedPlayers(). - get_
defined_ spell_ abilities - Resolve a
Defined$parameter to spell abilities. Mirrors JavaAbilityUtils.getDefinedSpellAbilities(Card, String, CardTraitBase)(AbilityUtils.java:1202). - get_
s_ var - Read an SVar from the SA’s host, applying in-flight text-change effects
when the SA is intrinsic — mirrors Java
AbilityUtils.getSVar(CardTraitBase, String). - get_
spells_ from_ play_ effect - Full variant of
getBasicSpellsFromPlayEffect— whenwith_alt_costistrue, alternative-cost (flashback/overload/…) variants are included. Mirrors JavaAbilityUtils.getSpellsFromPlayEffect(Card, Player, CardStateName, boolean). - handle_
paid - Handle paid-list counting for X-count expressions.
Mirrors Java’s
AbilityUtils.handlePaid(Iterable<Card>, String, Card, CardTraitBase). - handle_
remembering - Handle remembering targets/objects after a spell resolves.
Mirrors Java’s
AbilityUtils.handleRemembering(SpellAbility). - is_
unlinked_ from_ cast_ sa - Returns
truewhen a trait can’t be linked to the cast-SA ofcardbecause the trait originates from a different physical host (transformed / melded / adventure-cast situations). - matches_
change_ type - Check if a card matches a ChangeType$ / ValidCards$ filter string.
- matches_
valid_ cards - Full ValidCards$ filter matching with controller and keyword qualifier support.
- matches_
valid_ cards_ for_ sa - matches_
valid_ cards_ for_ source - matches_
valid_ cards_ selector_ opt - object_
x_ count - Evaluate object-based X-count expressions.
Mirrors Java’s
AbilityUtils.objectXCount(List<?>, String, Card, CardTraitBase). - parse_
counter_ type - Parse a counter type string to CounterType enum (case-insensitive).
Unknown types produce
CounterType::Named(UPPER)instead of silently falling back to P1P1, so cards like Stocking the Pantry get the correct SUPPLY counters. - parse_
num_ dmg - Parse NumDmg$ value from an ability string.
- parse_
param - Parse a numeric parameter from an ability string (e.g. “NumAtt$ 3” → 3).
- parse_
zone_ type - Parse a zone name string to ZoneType.
- player_
x_ count - Evaluate player-based X-count expressions.
Mirrors Java’s
AbilityUtils.playerXCount(List<Player>, String, Card, CardTraitBase). - player_
x_ property - Get a numeric property for a single player.
Mirrors Java’s
AbilityUtils.playerXProperty(Player, String, Card, CardTraitBase). - resolve
- Top-level ability resolution entry point.
Mirrors Java’s
AbilityUtils.resolve(SpellAbility). - resolve_
defined_ player - resolve_
defined_ player_ with_ sa - Resolve a Defined$ parameter to a player ID with spell/trigger context. Mirrors Java’s Triggered* player resolution for trigger SVar chains.
- resolve_
defined_ players - Resolve a Defined$ parameter to a list of player IDs. Supports “You”, “Opponent”, “Each”/“All”/“Player” (all alive players). Mirrors Java’s AbilityUtils.getDefinedPlayers() for multi-player resolution.
- resolve_
defined_ players_ with_ sa - Resolve a Defined$ parameter to a list of player IDs with spell/trigger context.
- x_count
- Evaluate an X-count expression on a card.
Mirrors Java’s
AbilityUtils.xCount(Card c, String s, CardTraitBase ctb).