From 7d5595fbff126fbc2aebc5606995d1a0afd4ab99 Mon Sep 17 00:00:00 2001 From: theelk801 Date: Thu, 10 Jul 2025 09:41:06 -0400 Subject: [PATCH] [EOC] Implement Planetary Annihilation --- .../mage/cards/p/PlanetaryAnnihilation.java | 92 +++++++++++++++++++ .../mage/sets/EdgeOfEternitiesCommander.java | 2 + 2 files changed, 94 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/p/PlanetaryAnnihilation.java diff --git a/Mage.Sets/src/mage/cards/p/PlanetaryAnnihilation.java b/Mage.Sets/src/mage/cards/p/PlanetaryAnnihilation.java new file mode 100644 index 00000000000..20b327efd38 --- /dev/null +++ b/Mage.Sets/src/mage/cards/p/PlanetaryAnnihilation.java @@ -0,0 +1,92 @@ +package mage.cards.p; + +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.DamageAllEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.TargetPermanent; + +import java.util.HashSet; +import java.util.Objects; +import java.util.Set; +import java.util.UUID; +import java.util.stream.Collectors; + +/** + * @author TheElk801 + */ +public final class PlanetaryAnnihilation extends CardImpl { + + public PlanetaryAnnihilation(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{R}{R}"); + + // Each player chooses six lands they control, then sacrifices the rest. Planetary Annihilation deals 6 damage to each creature. + this.getSpellAbility().addEffect(new PlanetaryAnnihilationEffect()); + this.getSpellAbility().addEffect(new DamageAllEffect(6, StaticFilters.FILTER_PERMANENT_CREATURE)); + } + + private PlanetaryAnnihilation(final PlanetaryAnnihilation card) { + super(card); + } + + @Override + public PlanetaryAnnihilation copy() { + return new PlanetaryAnnihilation(this); + } +} + +class PlanetaryAnnihilationEffect extends OneShotEffect { + + PlanetaryAnnihilationEffect() { + super(Outcome.Benefit); + staticText = "each player chooses six lands they control, then sacrifices the rest"; + } + + private PlanetaryAnnihilationEffect(final PlanetaryAnnihilationEffect effect) { + super(effect); + } + + @Override + public PlanetaryAnnihilationEffect copy() { + return new PlanetaryAnnihilationEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Set toSave = new HashSet<>(); + for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { + Player player = game.getPlayer(playerId); + if (player == null || game.getBattlefield().count( + StaticFilters.FILTER_CONTROLLED_PERMANENT_LANDS, playerId, source, game + ) <= 6) { + continue; + } + TargetPermanent target = new TargetPermanent( + 6, 6, StaticFilters.FILTER_CONTROLLED_PERMANENT_LANDS, true + ); + target.withChooseHint("you will sacrifice the rest"); + player.choose(outcome, target, source, game); + toSave.addAll(target + .getTargets() + .stream() + .map(game::getPermanent) + .filter(Objects::nonNull) + .collect(Collectors.toSet())); + } + for (Permanent permanent : game.getBattlefield().getActivePermanents( + StaticFilters.FILTER_LAND, source.getControllerId(), source, game + )) { + if (!toSave.contains(permanent)) { + permanent.sacrifice(source, game); + } + } + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/EdgeOfEternitiesCommander.java b/Mage.Sets/src/mage/sets/EdgeOfEternitiesCommander.java index d51a910919a..a221c472ef7 100644 --- a/Mage.Sets/src/mage/sets/EdgeOfEternitiesCommander.java +++ b/Mage.Sets/src/mage/sets/EdgeOfEternitiesCommander.java @@ -72,6 +72,8 @@ public final class EdgeOfEternitiesCommander extends ExpansionSet { cards.add(new SetCardInfo("Omnath, Locus of Rage", 123, Rarity.MYTHIC, mage.cards.o.OmnathLocusOfRage.class)); cards.add(new SetCardInfo("Oracle of Mul Daya", 102, Rarity.RARE, mage.cards.o.OracleOfMulDaya.class)); cards.add(new SetCardInfo("Pest Infestation", 103, Rarity.RARE, mage.cards.p.PestInfestation.class)); + cards.add(new SetCardInfo("Planetary Annihilation", 12, Rarity.RARE, mage.cards.p.PlanetaryAnnihilation.class, NON_FULL_USE_VARIOUS)); + cards.add(new SetCardInfo("Planetary Annihilation", 32, Rarity.RARE, mage.cards.p.PlanetaryAnnihilation.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Putrefy", 124, Rarity.UNCOMMON, mage.cards.p.Putrefy.class)); cards.add(new SetCardInfo("Rakdos Charm", 125, Rarity.UNCOMMON, mage.cards.r.RakdosCharm.class)); cards.add(new SetCardInfo("Rampaging Baloths", 104, Rarity.RARE, mage.cards.r.RampagingBaloths.class));