manabrew_engine/ability/effects/camouflage_effect.rs
1//! Camouflage — old-school combat concealment.
2//! Ported from Java's CamouflageEffect: the attacking player divides their
3//! creatures into face-down piles, then combat blockers are randomly assigned.
4//! In digital: we randomize the blocker assignments since the physical
5//! "face-down piles" mechanic can't be faithfully reproduced.
6
7use forge_foundation::ZoneType;
8
9use super::EffectContext;
10
11/// Struct form of this effect so it can participate in the
12/// `SpellAbilityEffect` trait hierarchy — mirrors Java's
13/// `CamouflageEffect` class extending `SpellAbilityEffect`.
14#[manabrew_engine_macros::spell_effect(CamouflageEffect)]
15fn resolve(ctx: &mut EffectContext, sa: &crate::spellability::SpellAbility) {
16 // Camouflage works by randomizing blocker assignments.
17 // In our engine, combat blocking is handled by the combat system.
18 // We mark the source creature so combat resolution knows to randomize.
19 if let Some(source) = sa.source {
20 if ctx.game.card(source).zone == ZoneType::Battlefield {
21 ctx.game
22 .card_mut(source)
23 .svars
24 .insert("Camouflage".to_string(), "True".to_string());
25 }
26 }
27}