diff --git a/Mage.Sets/src/mage/cards/n/NascentMetamorph.java b/Mage.Sets/src/mage/cards/n/NascentMetamorph.java new file mode 100644 index 00000000000..c4e62962a92 --- /dev/null +++ b/Mage.Sets/src/mage/cards/n/NascentMetamorph.java @@ -0,0 +1,95 @@ +package mage.cards.n; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.AttacksOrBlocksTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.cards.*; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.game.permanent.PermanentCard; +import mage.players.Player; +import mage.target.common.TargetOpponent; +import mage.util.functions.EmptyApplyToPermanent; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class NascentMetamorph extends CardImpl { + + public NascentMetamorph(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{U}"); + + this.subtype.add(SubType.SHAPESHIFTER); + this.power = new MageInt(1); + this.toughness = new MageInt(1); + + // Whenever Nascent Metamorph attacks or blocks, target opponent reveals cards from the top of their library until they reveal a creature card. Nascent Metamorph becomes a copy of that card until end of turn. Then that player puts all cards revealed this way on the bottom of their library in a random order. + Ability ability = new AttacksOrBlocksTriggeredAbility( + new NascentMetamorphEffect(), false + ); + ability.addTarget(new TargetOpponent()); + this.addAbility(ability); + } + + private NascentMetamorph(final NascentMetamorph card) { + super(card); + } + + @Override + public NascentMetamorph copy() { + return new NascentMetamorph(this); + } +} + +class NascentMetamorphEffect extends OneShotEffect { + + NascentMetamorphEffect() { + super(Outcome.Benefit); + staticText = "target opponent reveals cards from the top of their library until they reveal a creature card. " + + "{this} becomes a copy of that card until end of turn. " + + "Then that player puts all cards revealed this way on the bottom of their library in a random order."; + } + + private NascentMetamorphEffect(final NascentMetamorphEffect effect) { + super(effect); + } + + @Override + public NascentMetamorphEffect copy() { + return new NascentMetamorphEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getFirstTarget()); + if (player == null) { + return false; + } + Cards toReveal = new CardsImpl(); + Card toCopy = null; + for (Card card : player.getLibrary().getCards(game)) { + toReveal.add(card); + if (card == null || !card.isCreature()) { + continue; + } + toCopy = card; + break; + } + Permanent permanent = game.getPermanent(source.getFirstTarget()); + if (toCopy != null && permanent != null) { + game.copyPermanent(Duration.EndOfTurn, new PermanentCard( + toCopy, source.getControllerId(), game + ), permanent.getId(), source, new EmptyApplyToPermanent()); + } + player.revealCards(source, toReveal, game); + player.putCardsOnBottomOfLibrary(toReveal, game, source, false); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/Commander2020Edition.java b/Mage.Sets/src/mage/sets/Commander2020Edition.java index dba4d172a59..6cd48308acc 100644 --- a/Mage.Sets/src/mage/sets/Commander2020Edition.java +++ b/Mage.Sets/src/mage/sets/Commander2020Edition.java @@ -206,6 +206,7 @@ public final class Commander2020Edition extends ExpansionSet { cards.add(new SetCardInfo("Myriad Landscape", 292, Rarity.UNCOMMON, mage.cards.m.MyriadLandscape.class)); cards.add(new SetCardInfo("Mystic Monastery", 293, Rarity.UNCOMMON, mage.cards.m.MysticMonastery.class)); cards.add(new SetCardInfo("Nahiri, the Harbinger", 223, Rarity.MYTHIC, mage.cards.n.NahiriTheHarbinger.class)); + cards.add(new SetCardInfo("Nascent Metamorph", 36, Rarity.RARE, mage.cards.n.NascentMetamorph.class)); cards.add(new SetCardInfo("Natural Connection", 184, Rarity.COMMON, mage.cards.n.NaturalConnection.class)); cards.add(new SetCardInfo("Nesting Grounds", 71, Rarity.RARE, mage.cards.n.NestingGrounds.class)); cards.add(new SetCardInfo("Netherborn Altar", 45, Rarity.RARE, mage.cards.n.NetherbornAltar.class));