manabrew-engine 0.6.0

Magic: The Gathering rules engine — a Rust port of Forge
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! ChooseSector — choose a sector (Unfinity attraction board).
//! Ported from Java's ChooseSectorEffect: stores chosen sector on host card.

use super::EffectContext;

/// Struct form of this effect so it can participate in the
/// `SpellAbilityEffect` trait hierarchy — mirrors Java's
/// `ChooseSectorEffect` class extending `SpellAbilityEffect`.
#[manabrew_engine_macros::spell_effect(ChooseSectorEffect)]
fn resolve(ctx: &mut EffectContext, sa: &crate::spellability::SpellAbility) {
    if let Some(source) = sa.source {
        // Auto-choose sector 1 (in full implementation, agent would choose)
        let sector = ctx.rng.next_int(6) + 1;
        ctx.game
            .card_mut(source)
            .set_s_var("ChosenSector", format!("Number${}", sector));
    }
}