Skip to main content

manabrew_engine/ability/effects/
plot_effect.rs

1use super::EffectContext;
2use crate::card::make_plotted_keyword;
3use forge_foundation::ZoneType;
4
5/// `AB$ Plot` — exile the source card from hand and mark it as plotted.
6/// Plotted cards can later be cast from exile for free.
7///
8/// Mirrors Java's AbilityStatic resolve() for the Plot keyword
9/// (CardFactoryUtil.java:3426-3437).
10/// Struct form of this effect so it can participate in the
11/// `SpellAbilityEffect` trait hierarchy — mirrors Java's
12/// `PlotEffect` class extending `SpellAbilityEffect`.
13#[manabrew_engine_macros::spell_effect(PlotEffect)]
14fn resolve(ctx: &mut EffectContext, sa: &crate::spellability::SpellAbility) {
15    let card_id = match sa.source {
16        Some(id) => id,
17        None => return,
18    };
19    let player = sa.activating_player;
20    let card_name = ctx.game.card(card_id).card_name.clone();
21    let turn = ctx.game.turn.turn_number;
22
23    ctx.move_card(card_id, ZoneType::Exile, player);
24    ctx.game
25        .card_mut(card_id)
26        .keywords
27        .add(&make_plotted_keyword(turn));
28
29    crate::agent::notify_all_agents(
30        ctx.agents,
31        crate::agent::GameLogEvent::action(format!("Plotted: {}", card_name))
32            .with_player(player)
33            .with_card(card_id),
34    );
35}