From 1cd107cbe9b2ceba2c28472029f73026f407ddd6 Mon Sep 17 00:00:00 2001 From: theelk801 Date: Thu, 4 May 2023 22:53:52 -0400 Subject: [PATCH] [MAT] Implement Plargg and Nassari --- .../src/mage/cards/p/PlarggAndNassari.java | 112 ++++++++++++++++++ .../sets/MarchOfTheMachineTheAftermath.java | 1 + 2 files changed, 113 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/p/PlarggAndNassari.java diff --git a/Mage.Sets/src/mage/cards/p/PlarggAndNassari.java b/Mage.Sets/src/mage/cards/p/PlarggAndNassari.java new file mode 100644 index 00000000000..6add111c39d --- /dev/null +++ b/Mage.Sets/src/mage/cards/p/PlarggAndNassari.java @@ -0,0 +1,112 @@ +package mage.cards.p; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.cards.*; +import mage.constants.*; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.players.Player; +import mage.target.TargetCard; +import mage.target.common.TargetCardInExile; +import mage.target.common.TargetOpponent; +import mage.util.CardUtil; +import mage.util.RandomUtil; + +import java.util.Set; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class PlarggAndNassari extends CardImpl { + + public PlarggAndNassari(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{R}{R}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.ORC); + this.subtype.add(SubType.EFREET); + this.power = new MageInt(5); + this.toughness = new MageInt(4); + + // At the beginning of your upkeep, each player exiles cards from the top of their library until they exile a nonland card. An opponent chooses a nonland card exiled this way. You may cast up to two spells from among the other cards exiled this way without paying their mana costs. + this.addAbility(new BeginningOfUpkeepTriggeredAbility( + new PlarggAndNassariEffect(), TargetController.YOU, false + )); + } + + private PlarggAndNassari(final PlarggAndNassari card) { + super(card); + } + + @Override + public PlarggAndNassari copy() { + return new PlarggAndNassari(this); + } +} + +class PlarggAndNassariEffect extends OneShotEffect { + + PlarggAndNassariEffect() { + super(Outcome.Benefit); + staticText = "each player exiles cards from the top of their library until they exile a nonland card. " + + "An opponent chooses a nonland card exiled this way. You may cast up to two spells " + + "from among the other cards exiled this way without paying their mana costs"; + } + + private PlarggAndNassariEffect(final PlarggAndNassariEffect effect) { + super(effect); + } + + @Override + public PlarggAndNassariEffect copy() { + return new PlarggAndNassariEffect(this); + } + + private static Player getOpponent(Player controller, Ability source, Game game) { + Set opponents = game.getOpponents(controller.getId()); + if (opponents.size() < 2) { + return game.getPlayer(RandomUtil.randomFromCollection(opponents)); + } + TargetOpponent target = new TargetOpponent(true); + controller.choose(Outcome.Neutral, target, source, game); + return game.getPlayer(target.getFirstTarget()); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller == null) { + return false; + } + Cards cards = new CardsImpl(); + for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { + Player player = game.getPlayer(playerId); + if (player == null) { + continue; + } + for (Card card : player.getLibrary().getCards(game)) { + cards.add(card); + player.moveCards(card, Zone.EXILED, source, game); + if (!card.isLand(game)) { + break; + } + } + } + if (cards.isEmpty()) { + return false; + } + Player opponent = getOpponent(controller, source, game); + if (opponent != null) { + TargetCard target = new TargetCardInExile(StaticFilters.FILTER_CARD_NON_LAND); + target.setNotTarget(true); + opponent.choose(outcome, cards, target, source, game); + cards.remove(game.getCard(target.getFirstTarget())); + } + CardUtil.castMultipleWithAttributeForFree(controller, source, game, cards, StaticFilters.FILTER_CARD, 2); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/MarchOfTheMachineTheAftermath.java b/Mage.Sets/src/mage/sets/MarchOfTheMachineTheAftermath.java index 70a5a94efac..bd5bd7f6065 100644 --- a/Mage.Sets/src/mage/sets/MarchOfTheMachineTheAftermath.java +++ b/Mage.Sets/src/mage/sets/MarchOfTheMachineTheAftermath.java @@ -42,6 +42,7 @@ public final class MarchOfTheMachineTheAftermath extends ExpansionSet { cards.add(new SetCardInfo("Nissa, Resurgent Animist", 22, Rarity.MYTHIC, mage.cards.n.NissaResurgentAnimist.class)); cards.add(new SetCardInfo("Niv-Mizzet, Supreme", 40, Rarity.RARE, mage.cards.n.NivMizzetSupreme.class)); cards.add(new SetCardInfo("Open the Way", 23, Rarity.RARE, mage.cards.o.OpenTheWay.class)); + cards.add(new SetCardInfo("Plargg and Nassari", 18, Rarity.RARE, mage.cards.p.PlarggAndNassari.class)); cards.add(new SetCardInfo("Rebuild the City", 43, Rarity.RARE, mage.cards.r.RebuildTheCity.class)); cards.add(new SetCardInfo("Reckless Handling", 19, Rarity.UNCOMMON, mage.cards.r.RecklessHandling.class)); cards.add(new SetCardInfo("Samut, Vizier of Naktamun", 45, Rarity.MYTHIC, mage.cards.s.SamutVizierOfNaktamun.class));