From aa854c8537fab7057f5bd54bc1c45d51aca1140e Mon Sep 17 00:00:00 2001 From: theelk801 Date: Thu, 4 May 2023 09:38:39 -0400 Subject: [PATCH] [MAT] Implement Vesuvan Drifter --- .../src/mage/cards/v/VesuvanDrifter.java | 103 ++++++++++++++++++ .../sets/MarchOfTheMachineTheAftermath.java | 1 + 2 files changed, 104 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/v/VesuvanDrifter.java diff --git a/Mage.Sets/src/mage/cards/v/VesuvanDrifter.java b/Mage.Sets/src/mage/cards/v/VesuvanDrifter.java new file mode 100644 index 0000000000..ae33f68748 --- /dev/null +++ b/Mage.Sets/src/mage/cards/v/VesuvanDrifter.java @@ -0,0 +1,103 @@ +package mage.cards.v; + +import mage.MageInt; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.common.BeginningOfCombatTriggeredAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.continuous.LookAtTopCardOfLibraryAnyTimeEffect; +import mage.abilities.keyword.FlyingAbility; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.cards.CardsImpl; +import mage.constants.*; +import mage.game.Game; +import mage.game.permanent.PermanentCard; +import mage.players.Player; +import mage.util.functions.CopyApplier; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class VesuvanDrifter extends CardImpl { + + public VesuvanDrifter(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{U}"); + + this.subtype.add(SubType.SHAPESHIFTER); + this.power = new MageInt(2); + this.toughness = new MageInt(4); + + // Flying + this.addAbility(FlyingAbility.getInstance()); + + // You may look at the top card of your library any time. + this.addAbility(new SimpleStaticAbility(new LookAtTopCardOfLibraryAnyTimeEffect())); + + // At the beginning of each combat, you may reveal the top card of your library. If you reveal a creature card this way, Vesuvan Drifter becomes a copy of that card until end of turn, except it has flying. + this.addAbility(new BeginningOfCombatTriggeredAbility( + new VesuvanDrifterEffect(), TargetController.ANY, true + )); + } + + private VesuvanDrifter(final VesuvanDrifter card) { + super(card); + } + + @Override + public VesuvanDrifter copy() { + return new VesuvanDrifter(this); + } +} + +class VesuvanDrifterEffect extends OneShotEffect { + + private static final CopyApplier applier = new CopyApplier() { + @Override + public boolean apply(Game game, MageObject blueprint, Ability source, UUID targetObjectId) { + blueprint.getAbilities().add(FlyingAbility.getInstance()); + return true; + } + }; + + VesuvanDrifterEffect() { + super(Outcome.Benefit); + staticText = "reveal the top card of your library. If you reveal a creature card this way, " + + "{this} becomes a copy of that card until end of turn, except it has flying"; + } + + private VesuvanDrifterEffect(final VesuvanDrifterEffect effect) { + super(effect); + } + + @Override + public VesuvanDrifterEffect copy() { + return new VesuvanDrifterEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + Card card = player.getLibrary().getFromTop(game); + if (card == null) { + return false; + } + player.revealCards(source, new CardsImpl(card), game); + if (!card.isCreature(game) || source.getSourcePermanentIfItStillExists(game) == null) { + return true; + } + game.copyPermanent( + Duration.EndOfTurn, + new PermanentCard(card, source.getControllerId(), game), + source.getSourceId(), source, applier + ); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/MarchOfTheMachineTheAftermath.java b/Mage.Sets/src/mage/sets/MarchOfTheMachineTheAftermath.java index 414cb6b122..3edcde2565 100644 --- a/Mage.Sets/src/mage/sets/MarchOfTheMachineTheAftermath.java +++ b/Mage.Sets/src/mage/sets/MarchOfTheMachineTheAftermath.java @@ -50,5 +50,6 @@ public final class MarchOfTheMachineTheAftermath extends ExpansionSet { cards.add(new SetCardInfo("Training Grounds", 9, Rarity.RARE, mage.cards.t.TrainingGrounds.class)); cards.add(new SetCardInfo("Tyvar the Bellicose", 48, Rarity.MYTHIC, mage.cards.t.TyvarTheBellicose.class)); cards.add(new SetCardInfo("Undercity Upheaval", 25, Rarity.UNCOMMON, mage.cards.u.UndercityUpheaval.class)); + cards.add(new SetCardInfo("Vesuvan Drifter", 10, Rarity.RARE, mage.cards.v.VesuvanDrifter.class)); } }