Skip to main content

manabrew_engine/ability/effects/
life_exchange_variant_effect.rs

1//! LifeExchangeVariant effect — variant life total exchange.
2//!
3//! Ported from Java's `LifeExchangeVariantEffect.java`.
4//! Exchange life totals with specific modifications.
5
6use super::EffectContext;
7
8/// Struct form of this effect so it can participate in the
9/// `SpellAbilityEffect` trait hierarchy — mirrors Java's
10/// `LifeExchangeVariantEffect` class extending `SpellAbilityEffect`.
11#[manabrew_engine_macros::spell_effect(LifeExchangeVariantEffect)]
12fn resolve(ctx: &mut EffectContext, sa: &crate::spellability::SpellAbility) {
13    let controller = sa.activating_player;
14
15    let target = sa
16        .target_chosen
17        .target_player
18        .unwrap_or_else(|| ctx.game.opponent_of(controller));
19
20    ctx.game.player_exchange_life_totals(controller, target);
21}