Skip to main content

manabrew_engine/ability/effects/
ascend_effect.rs

1//! Ascend effect — gain the City's Blessing if you control 10+ permanents.
2//!
3//! Ported 1:1 from Java's `AscendEffect.java`.
4//! Ascend: If you control ten or more permanents, you get the city's blessing
5//! for the rest of the game.
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/// `AscendEffect` class extending `SpellAbilityEffect`.
14#[manabrew_engine_macros::spell_effect(AscendEffect)]
15fn resolve(ctx: &mut EffectContext, sa: &crate::spellability::SpellAbility) {
16    let controller = sa.activating_player;
17    let players = if let Some(def) = sa.defined_player() {
18        super::resolve_defined_players(def, controller, ctx.game)
19    } else {
20        vec![controller]
21    };
22
23    for pid in players {
24        if ctx.game.player(pid).has_lost {
25            continue;
26        }
27
28        // Count permanents on battlefield
29        let permanent_count = ctx.game.cards_in_zone(ZoneType::Battlefield, pid).len();
30
31        if permanent_count >= 10 {
32            // Grant city's blessing (permanent for rest of game)
33            // In Java this is Player.setBlessing(true). We track via a flag.
34            // The blessing is checked by card scripts via "Player.hasCityBlessing"
35            ctx.game.player_set_blessing(pid, true);
36        }
37    }
38}