From c8a69f3bad277efb09d8aefd899a1acaf2cbc80b Mon Sep 17 00:00:00 2001 From: theelk801 Date: Thu, 13 Apr 2023 09:02:33 -0400 Subject: [PATCH] [MOM] Implement Nahiri's Warcrafting --- .../src/mage/cards/n/NahirisWarcrafting.java | 100 ++++++++++++++++++ .../src/mage/sets/MarchOfTheMachine.java | 1 + 2 files changed, 101 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/n/NahirisWarcrafting.java diff --git a/Mage.Sets/src/mage/cards/n/NahirisWarcrafting.java b/Mage.Sets/src/mage/cards/n/NahirisWarcrafting.java new file mode 100644 index 0000000000..65375b4643 --- /dev/null +++ b/Mage.Sets/src/mage/cards/n/NahirisWarcrafting.java @@ -0,0 +1,100 @@ +package mage.cards.n; + +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.cards.*; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.filter.FilterPermanent; +import mage.filter.StaticFilters; +import mage.filter.predicate.Predicates; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.TargetCard; +import mage.target.TargetPermanent; +import mage.target.common.TargetCardInLibrary; +import mage.util.CardUtil; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class NahirisWarcrafting extends CardImpl { + + private static final FilterPermanent filter + = new FilterPermanent("creature, planeswalker, or battle"); + + static { + filter.add(Predicates.or( + CardType.CREATURE.getPredicate(), + CardType.PLANESWALKER.getPredicate(), + CardType.BATTLE.getPredicate() + )); + } + + public NahirisWarcrafting(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{R}{R}"); + + // Nahiri's Warcrafting deals 5 damage to target creature, planeswalker, or battle. Look at the top X cards of your library, where X is the excess damage dealt this way. You may exile one of those cards. Put the rest on the bottom of your library in a random order. You may play the exiled card this turn. + this.getSpellAbility().addEffect(new NahirisWarcraftingEffect()); + this.getSpellAbility().addTarget(new TargetPermanent(filter)); + } + + private NahirisWarcrafting(final NahirisWarcrafting card) { + super(card); + } + + @Override + public NahirisWarcrafting copy() { + return new NahirisWarcrafting(this); + } +} + +class NahirisWarcraftingEffect extends OneShotEffect { + + NahirisWarcraftingEffect() { + super(Outcome.Benefit); + staticText = "{this} deals 5 damage to target creature, planeswalker, or battle. " + + "Look at the top X cards of your library, where X is the excess damage dealt this way. " + + "You may exile one of those cards. Put the rest on the bottom of your library " + + "in a random order. You may play the exiled card this turn"; + } + + private NahirisWarcraftingEffect(final NahirisWarcraftingEffect effect) { + super(effect); + } + + @Override + public NahirisWarcraftingEffect copy() { + return new NahirisWarcraftingEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source)); + if (player == null || permanent == null) { + return false; + } + int lethal = permanent.getLethalDamage(source.getSourceId(), game); + int excess = permanent.damage(5, source, game) - lethal; + if (excess <= 0) { + return true; + } + Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, excess)); + TargetCard target = new TargetCardInLibrary(0, 1, StaticFilters.FILTER_CARD_A); + player.choose(outcome, cards, target, game); + Card card = game.getCard(target.getFirstTarget()); + if (card != null) { + player.moveCards(card, Zone.EXILED, source, game); + CardUtil.makeCardPlayable(game, source, card, Duration.EndOfTurn, false); + } + cards.retainZone(Zone.LIBRARY, game); + player.putCardsOnBottomOfLibrary(cards, game, source, false); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/MarchOfTheMachine.java b/Mage.Sets/src/mage/sets/MarchOfTheMachine.java index 9d6331edd1..5fc82c8d3e 100644 --- a/Mage.Sets/src/mage/sets/MarchOfTheMachine.java +++ b/Mage.Sets/src/mage/sets/MarchOfTheMachine.java @@ -157,6 +157,7 @@ public final class MarchOfTheMachine extends ExpansionSet { cards.add(new SetCardInfo("Monastery Mentor", 28, Rarity.MYTHIC, mage.cards.m.MonasteryMentor.class)); cards.add(new SetCardInfo("Mountain", 280, Rarity.LAND, mage.cards.basiclands.Mountain.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Mutagen Connoisseur", 248, Rarity.UNCOMMON, mage.cards.m.MutagenConnoisseur.class)); + cards.add(new SetCardInfo("Nahiri's Warcrafting", 155, Rarity.RARE, mage.cards.n.NahirisWarcrafting.class)); cards.add(new SetCardInfo("Negate", 68, Rarity.COMMON, mage.cards.n.Negate.class)); cards.add(new SetCardInfo("Nezumi Freewheeler", 119, Rarity.UNCOMMON, mage.cards.n.NezumiFreewheeler.class)); cards.add(new SetCardInfo("Nezumi Informant", 120, Rarity.COMMON, mage.cards.n.NezumiInformant.class));