Skip to main content

Module replacement_handler

Module replacement_handler 

Source
Expand description

Replacement effect dispatcher.

Mirrors the Java Forge ReplacementHandler.java in forge/game/replacement/.

The entry point is apply_replacements, which accepts a mutable ReplacementEvent and iterates through the five CR 616 layers (CantHappen → Control → Copy → Transform → Other), applying the first matching effect in each layer.

Structs§

CounterMapValue
ReplacementHandler
Struct-based replacement handler with loop prevention and optional agent access.
ReplacementRuntime

Enums§

ReplacementEvent
A game event that may be subject to one or more replacement effects.

Functions§

apply_moved_replacement
Apply Moved replacement effects (Rest in Peace, Leyline of the Void) for a card being moved to the Graveyard. Uses agents for proper RNG consumption when multiple effects apply. Returns the final destination zone.
apply_replacements
Apply all applicable replacement effects to a game event.
apply_replacements_with_agents
apply_replacements_with_agents_and_runtime
cant_happen_check
Check if any CantHappen-layer replacement effect would prevent this event.
parse_replacement
Parse a raw R$ replacement-effect line. Re-export of replacement_effect::parse_replacement_effect for scan parity.
run_replace_damage
Apply replacement effects specifically for damage events.
visit
Walk all battlefield cards and collect (card_id, effect_index) pairs for replacement effects matching the given event type and optional layer.
would_extra_turn_be_skipped
Check if any BeginTurn replacement effect in the Other layer would skip an extra turn for the given player.
would_phase_be_skipped
Check if any BeginPhase replacement effect in the Control layer would skip the given phase for the given player.