1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//! Draft — draft a card from a spellbook (Conspiracy/Arena).
//! Ported from Java's DraftEffect: picks cards from a spellbook list,
//! presents 3 random options, player chooses one, it goes to hand.
use super::EffectContext;
use crate::parsing::keys;
/// Struct form of this effect so it can participate in the
/// `SpellAbilityEffect` trait hierarchy — mirrors Java's
/// `DraftEffect` class extending `SpellAbilityEffect`.
#[manabrew_engine_macros::spell_effect(DraftEffect)]
fn resolve(ctx: &mut EffectContext, sa: &crate::spellability::SpellAbility) {
let source = match sa.source {
Some(s) => s,
None => return,
};
let controller = sa.activating_player;
// Get spellbook names
let spellbook = match sa.ir.spellbook_text.as_deref() {
Some(sb) => sb
.split(',')
.map(|s| s.trim().replace(';', ","))
.collect::<Vec<_>>(),
None => return,
};
let num_to_draft = super::resolve_numeric_svar(ctx.game, sa, "DraftNum", 1).max(1) as usize;
for _ in 0..num_to_draft {
if spellbook.is_empty() {
break;
}
// In full implementation: present 3 random options from spellbook to player
// For now, auto-select first option (agent would choose)
let chosen_name =
&spellbook[ctx.rng.next_int(spellbook.len() as i32) as usize % spellbook.len()];
// Remember the drafted card name on source
if sa.param_is_true(keys::REMEMBER_DRAFTED) {
ctx.game
.card_mut(source)
.set_s_var("DraftedCard", chosen_name.clone());
}
}
let _ = controller; // used in full impl for zone changes
}