Skip to main content

Module cost

Module cost 

Source

Modules§

cost_add_mana
Add mana to pool as a cost. Mirrors Java’s CostAddMana.
cost_adjustment
Cost adjustment logic for spells and abilities.
cost_behold
Behold (reveal from hand or battlefield) as a cost. Mirrors Java’s CostBehold.
cost_behold_exile
Behold+Exile parity file for Java CostBeholdExile.
cost_blight
Blight as a cost — put -1/-1 counters on creatures you control. Mirrors Java’s CostBlight which extends CostPutCounter.
cost_choose_color
Choose color(s) as a cost. Mirrors Java’s CostChooseColor.
cost_choose_creature_type
Choose a creature type as a cost. Mirrors Java’s CostChooseCreatureType.
cost_collect_evidence
Collect evidence as a cost. Mirrors Java’s CostCollectEvidence.
cost_damage
Deal damage to self as a cost. Mirrors Java’s CostDamage.
cost_discard
Discard cards as a cost. Mirrors Java’s CostDiscard.
cost_draw
Draw cards as a cost. Mirrors Java’s CostDraw.
cost_enlist
Enlist a creature as a cost. Mirrors Java’s CostEnlist.
cost_exert
Exert permanents as a cost. Mirrors Java’s CostExert.
cost_exile
Exile cards as a cost. Mirrors Java’s CostExile.
cost_exile_ctrl_or_grave
Exile from controlled battlefield or graveyard as a combined cost. Used by Craft abilities. No direct Java CostExileCtrlOrGrave class — this is a Rust-side variant that combines CostExile battlefield + graveyard sources.
cost_exile_from_stack
Exile spells from the stack as a cost. Mirrors Java’s CostExileFromStack.
cost_exiled_move_to_grave
Move exiled cards to graveyard as a cost. Mirrors Java’s CostExiledMoveToGrave.
cost_flip_coin
Flip coin(s) as a cost. Mirrors Java’s CostFlipCoin.
cost_forage
Forage as a cost. Mirrors Java’s CostForage.
cost_gain_control
Give control of permanents as a cost. Mirrors Java’s CostGainControl.
cost_gain_life
Have an opponent gain life as a cost. Mirrors Java’s CostGainLife.
cost_mill
Mill cards as a cost. Mirrors Java’s CostMill.
cost_part
Shared helpers for Java CostPart parity on top of enum-based Rust cost parts.
cost_part_mana
Helpers for mana-part parity with Java CostPartMana.
cost_part_with_list
Shared list-payment helpers for parity with Java CostPartWithList.
cost_part_with_trigger
Trigger hooks for parity with Java CostPartWithTrigger.
cost_pay_energy
Pay energy counters as a cost. Mirrors Java’s CostPayEnergy.
cost_pay_life
Pay life as a cost. Mirrors Java’s CostPayLife.
cost_pay_shards
Pay mana shards as a cost. Mirrors Java’s CostPayShards.
cost_payment
cost_promise_gift
Promise a gift to an opponent as a cost. Mirrors Java’s CostPromiseGift.
cost_put_card_to_lib
Put cards to library as a cost. Mirrors Java’s CostPutCardToLib.
cost_put_counter
Put counters on permanents as a cost. Mirrors Java’s CostPutCounter.
cost_remove_any_counter
Remove any counter type from permanents as a cost. Mirrors Java’s CostRemoveAnyCounter.
cost_remove_counter
Parity shim for Java CostRemoveCounter.
cost_return
Return permanents to hand as a cost. Mirrors Java’s CostReturn.
cost_reveal
Reveal cards as a cost. Mirrors Java’s CostReveal.
cost_reveal_chosen
Reveal a previously chosen player or type as a cost. Mirrors Java’s CostRevealChosen.
cost_roll_dice
Roll dice as a cost. Mirrors Java’s CostRollDice.
cost_sacrifice
Sacrifice permanents as a cost. Mirrors Java’s CostSacrifice.
cost_sub_counter
Remove counters from source as a cost. Mirrors Java’s CostRemoveCounter.
cost_tap
Tap the source permanent as a cost. Mirrors Java’s CostTap.
cost_tap_type
Tap other permanents of a type as a cost. Mirrors Java’s CostTapType.
cost_unattach
Unattach equipment as a cost. Mirrors Java’s CostUnattach.
cost_untap
Untap the source permanent as a cost. Mirrors Java’s CostUntap.
cost_untap_type
Untap other permanents of a type as a cost. Mirrors Java’s CostUntapType.
cost_waterbend
Waterbend as a cost. Mirrors Java’s CostWaterbend which extends CostPartMana.
individual_cost_payment_instance
Mirrors Java IndividualCostPaymentInstance.
payment_decision
Payment decision data — the intermediary between deciding and executing cost payment.
selector_domain
trait_cost_decision_maker
Cost decision maker parity wrapper for Java CostDecisionMakerBase.
trait_cost_visitor
Cost visitor abstraction for parity with Java ICostVisitor<T>.

Structs§

Cost
The complete cost to activate an ability.

Enums§

AmountSpec
The amount slot of a CostPart. Replaces the legacy i32 (with DYNAMIC_X_SENTINEL) once consumers are migrated. Mirrors Java’s CostPart.convertAmount + AbilityUtils.calculateAmount split: literals resolve trivially, X reads XPaid / SVar:X, named SVar identifiers walk the host card’s SVar table at call time.
CostPart
RevealFrom
A single component of an ability cost. Mirrors Java’s CostPart hierarchy.

Functions§

add
apply_text_change_effects
can_pay
Check if a cost can be paid by the given player for the given source card. available_mana is the total mana available (pool + untapped sources).
can_pay_ignoring_mana
Check if a cost can be paid ignoring mana requirements. Used for mana ability availability checks (to avoid circular dependency).
can_pay_ignoring_mana_for_spell
Check if a cost can be paid ignoring mana requirements, for a spell. Passes a minimal SpellAbility with is_spell = true so that CantSacrifice checks (e.g. Yasharn) can properly evaluate ValidCause$ Spell restrictions.
can_pay_ignoring_mana_with_ability
Check if a cost can be paid ignoring mana requirements while preserving the full spell/ability context for non-mana legality checks.
can_pay_with_ability
Java parity helper: canPay(cost, ability-context).
can_pay_with_ability_and_reserved
convert_amount_type_to_words
convert_int_and_type_to_words
get_enlist_targets
Find cards available to enlist: untapped, non-attacking, non-summoning-sick creatures you control.
get_exiled_targets
Find cards in exile across all players matching a type filter. Used by ExiledMoveToGrave and can_pay checks.
get_max_for_non_mana_x
get_sacrifice_targets
Find valid sacrifice targets on the battlefield for a player, filtered by type. Mirrors Java’s CostSacrifice.getMaxAmountX() + CardLists.getValidCards().
get_sacrifice_targets_for_cost
Find valid sacrifice targets for a cost, filtered both by type and CantSacrifice-style legality before RNG selection.
get_sub_counter_targets
Find cards that can have counters removed for SubCounter<.../Type/...>.
get_tap_type_targets
Find valid tap-type targets (untapped permanents matching filter, excluding source).
get_zone_targets
Find valid exile/return targets in a given zone for a player, filtered by type.
has_x_in_any_cost_part
matches_exile_from_stack_filter
matches_type_filter
Check if a card matches a type filter string. Thin wrapper around matches_change_type for use by individual cost modules.
merge_to
normalize_exile_base_filter
parse_cost
Parse a Cost$ value from the DSL.
resolve_dynamic_amount
static_ability_source_cards
strip_exile_type_modifiers
to_prompt_string
Cost rendered for a player-facing prompt. Life uses the {LIFE} token so the UI can draw a heart; mana keeps its {...} symbols.
to_simple_string