Skip to main content

manabrew_engine/ability/effects/
assign_group_effect.rs

1//! AssignGroup — assign creatures to groups (Conspiracy draft).
2//! Ported from Java's AssignGroupEffect: assigns defined objects to groups
3//! chosen by the player, then resolves sub-abilities for each group.
4
5use super::EffectContext;
6use crate::ids::CardId;
7
8/// Struct form of this effect so it can participate in the
9/// `SpellAbilityEffect` trait hierarchy — mirrors Java's
10/// `AssignGroupEffect` class extending `SpellAbilityEffect`.
11#[manabrew_engine_macros::spell_effect(AssignGroupEffect)]
12fn resolve(ctx: &mut EffectContext, sa: &crate::spellability::SpellAbility) {
13    let source = match sa.source {
14        Some(s) => s,
15        None => return,
16    };
17
18    // Get defined cards to assign
19    let targets: Vec<CardId> = if let Some(target) = sa.target_chosen.target_card {
20        vec![target]
21    } else {
22        ctx.game.card(source).remembered_cards.clone()
23    };
24
25    if targets.is_empty() {
26        return;
27    }
28
29    // Auto-assign all to group 1 (agent would choose in full implementation)
30    // Remember the assigned cards
31    for card_id in &targets {
32        ctx.game.card_mut(source).add_remembered_card(*card_id);
33    }
34}