manabrew_engine/ability/effects/replace_effect.rs
1//! Replace effect — generic replacement effect registration.
2//!
3//! Ported from Java's `ReplaceEffect.java`.
4//! Registers or modifies a replacement effect on the game state.
5
6use super::EffectContext;
7
8/// Struct form of this effect so it can participate in the
9/// `SpellAbilityEffect` trait hierarchy — mirrors Java's
10/// `ReplaceEffect` class extending `SpellAbilityEffect`.
11#[manabrew_engine_macros::spell_effect(ReplaceEffect)]
12fn resolve(ctx: &mut EffectContext, sa: &crate::spellability::SpellAbility) {
13 // Generic replacement effects are handled by the replacement handler system.
14 // This effect type is primarily a marker — the actual replacement logic
15 // is defined by the ReplacementEffect on the source card and processed
16 // by the replacement_handler module.
17
18 // Some Replace effects store values for their replacement:
19 if let Some(source_id) = sa.source {
20 if let Some(val) = sa.ir.replace_with_text.as_deref() {
21 ctx.game
22 .card_mut(source_id)
23 .svars
24 .insert("ReplaceWith".to_string(), val.to_string());
25 }
26 }
27}