Skip to main content

manabrew_engine/ability/effects/
remove_from_match_effect.rs

1//! RemoveFromMatch — remove cards from the entire match (Conspiracy).
2//! Ported from Java's RemoveFromMatchEffect: permanently removes cards
3//! from all game zones, ceasing to exist.
4
5use forge_foundation::ZoneType;
6
7use super::EffectContext;
8use crate::ids::CardId;
9
10/// Struct form of this effect so it can participate in the
11/// `SpellAbilityEffect` trait hierarchy — mirrors Java's
12/// `RemoveFromMatchEffect` class extending `SpellAbilityEffect`.
13#[manabrew_engine_macros::spell_effect(RemoveFromMatchEffect)]
14fn resolve(ctx: &mut EffectContext, sa: &crate::spellability::SpellAbility) {
15    let targets: Vec<CardId> = if let Some(target) = sa.target_chosen.target_card {
16        vec![target]
17    } else if let Some(source) = sa.source {
18        ctx.game.card(source).remembered_cards.clone()
19    } else {
20        return;
21    };
22
23    for card_id in targets {
24        // Move to None zone — card ceases to exist
25        let old_zone = ctx.game.card(card_id).zone;
26        let owner = ctx.game.card(card_id).owner;
27        ctx.move_card(card_id, ZoneType::None, owner);
28        super::emit_zone_trigger(ctx.trigger_handler, card_id, old_zone, ZoneType::None);
29    }
30}