manabrew_engine/ability/effects/
internal_radiation_effect.rs1use forge_foundation::ZoneType;
9
10use super::EffectContext;
11use crate::event::RunParams;
12use crate::trigger::TriggerType;
13
14#[manabrew_engine_macros::spell_effect(InternalRadiationEffect)]
18fn resolve(ctx: &mut EffectContext, sa: &crate::spellability::SpellAbility) {
19 let controller = sa.activating_player;
20 let num_rad = ctx.game.player(controller).radiation_counters;
21
22 if num_rad <= 0 {
23 return;
24 }
25
26 let mut non_land_count = 0;
28 for _ in 0..num_rad {
29 let lib = ctx.game.zone(ZoneType::Library, controller);
30 if lib.cards.is_empty() {
31 break;
32 }
33 let top_card = lib.cards[0];
34
35 let is_land = ctx.game.card(top_card).type_line.is_land();
37
38 ctx.game
40 .move_card(top_card, ZoneType::Graveyard, controller);
41 super::emit_zone_trigger(
42 ctx.trigger_handler,
43 top_card,
44 ZoneType::Library,
45 ZoneType::Graveyard,
46 );
47
48 if !is_land {
49 non_land_count += 1;
50 }
51 }
52
53 if non_land_count > 0 {
55 ctx.game.player_lose_life(controller, non_land_count);
56
57 ctx.trigger_handler.run_trigger(
59 TriggerType::LifeLost,
60 RunParams {
61 player: Some(controller),
62 life_amount: Some(non_land_count),
63 ..Default::default()
64 },
65 false,
66 );
67 }
68
69 let current_rad = ctx.game.player(controller).radiation_counters;
71 ctx.game
72 .player_set_radiation(controller, (current_rad - non_land_count).max(0));
73}