From abc931fb87efb3164658db5348d20f40e67d79f1 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Mon, 12 Apr 2021 21:28:00 -0400 Subject: [PATCH] [STX] Implemented Verdant Mastery --- .../src/mage/cards/v/VerdantMastery.java | 114 ++++++++++++++++++ .../mage/sets/StrixhavenSchoolOfMages.java | 1 + 2 files changed, 115 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/v/VerdantMastery.java diff --git a/Mage.Sets/src/mage/cards/v/VerdantMastery.java b/Mage.Sets/src/mage/cards/v/VerdantMastery.java new file mode 100644 index 00000000000..30e5a0c1d7f --- /dev/null +++ b/Mage.Sets/src/mage/cards/v/VerdantMastery.java @@ -0,0 +1,114 @@ +package mage.cards.v; + +import mage.abilities.Ability; +import mage.abilities.costs.AlternativeCostSourceAbility; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.OneShotEffect; +import mage.cards.*; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.players.Player; +import mage.target.common.TargetCardInLibrary; +import mage.target.common.TargetOpponent; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class VerdantMastery extends CardImpl { + + public VerdantMastery(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{5}{G}"); + + // You may pay {3}{G} rather than pay this spell's mana cost. + Ability costAbility = new AlternativeCostSourceAbility(new ManaCostsImpl<>("{3}{G}")); + this.addAbility(costAbility); + + // Search your library for up to four basic land cards and reveal them. Put one of them onto the battlefield tapped under an opponent's control if the {3}{G} cost was paid. Put two of them onto the battlefield tapped under your control and the rest into your hand. Then shuffle. + this.getSpellAbility().addEffect(new VerdantMasteryEffect(costAbility.getOriginalId())); + } + + private VerdantMastery(final VerdantMastery card) { + super(card); + } + + @Override + public VerdantMastery copy() { + return new VerdantMastery(this); + } +} + +class VerdantMasteryEffect extends OneShotEffect { + + private final UUID alternativeCostOriginalID; + + VerdantMasteryEffect(UUID alternativeCostOriginalID) { + super(Outcome.Detriment); + staticText = "search your library for up to four basic land cards and reveal them. Put one of them " + + "onto the battlefield tapped under an opponent's control if the {3}{G} cost was paid. Put two of " + + "them onto the battlefield tapped under your control and the rest into your hand. Then shuffle"; + this.alternativeCostOriginalID = alternativeCostOriginalID; + } + + private VerdantMasteryEffect(VerdantMasteryEffect effect) { + super(effect); + this.alternativeCostOriginalID = effect.alternativeCostOriginalID; + } + + @Override + public VerdantMasteryEffect copy() { + return new VerdantMasteryEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + TargetCardInLibrary target = new TargetCardInLibrary(4, StaticFilters.FILTER_CARD_BASIC_LAND); + player.searchLibrary(target, source, game); + Cards cards = new CardsImpl(target.getTargets()); + player.revealCards(source, cards, game); + if (cards.isEmpty()) { + player.shuffleLibrary(source, game); + return true; + } + if (AlternativeCostSourceAbility.getActivatedStatus( + game, source, this.alternativeCostOriginalID, false + )) { + TargetOpponent targetOpponent = new TargetOpponent(true); + player.chooseTarget(Outcome.DrawCard, targetOpponent, source, game); + Player opponent = game.getPlayer(targetOpponent.getFirstTarget()); + if (opponent != null) { + target = new TargetCardInLibrary(1, StaticFilters.FILTER_CARD_BASIC_LAND); + target.withChooseHint("to give to " + opponent.getName()); + player.choose(outcome, cards, target, game); + Card card = game.getCard(target.getFirstTarget()); + opponent.moveCards( + card, Zone.BATTLEFIELD, source, game, true, + false, false, null + ); + } + } + cards.removeIf(uuid -> game.getState().getZone(uuid) != Zone.LIBRARY); + if (cards.isEmpty()) { + player.shuffleLibrary(source, game); + return true; + } + target = new TargetCardInLibrary(0, 2, StaticFilters.FILTER_CARD_BASIC_LAND); + player.choose(outcome, cards, target, game); + player.moveCards( + new CardsImpl(target.getTargets()).getCards(game), Zone.BATTLEFIELD, source, + game, true, false, false, null + ); + cards.removeIf(uuid -> game.getState().getZone(uuid) != Zone.LIBRARY); + player.moveCards(cards, Zone.HAND, source, game); + player.shuffleLibrary(source, game); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/StrixhavenSchoolOfMages.java b/Mage.Sets/src/mage/sets/StrixhavenSchoolOfMages.java index d3de5cfd125..18dd2f3eb25 100644 --- a/Mage.Sets/src/mage/sets/StrixhavenSchoolOfMages.java +++ b/Mage.Sets/src/mage/sets/StrixhavenSchoolOfMages.java @@ -286,6 +286,7 @@ public final class StrixhavenSchoolOfMages extends ExpansionSet { cards.add(new SetCardInfo("Vanishing Verse", 244, Rarity.RARE, mage.cards.v.VanishingVerse.class)); cards.add(new SetCardInfo("Velomachus Lorehold", 245, Rarity.MYTHIC, mage.cards.v.VelomachusLorehold.class)); cards.add(new SetCardInfo("Venerable Warsinger", 246, Rarity.RARE, mage.cards.v.VenerableWarsinger.class)); + cards.add(new SetCardInfo("Verdant Mastery", 146, Rarity.RARE, mage.cards.v.VerdantMastery.class)); cards.add(new SetCardInfo("Vineglimmer Snarl", 274, Rarity.RARE, mage.cards.v.VineglimmerSnarl.class)); cards.add(new SetCardInfo("Vortex Runner", 60, Rarity.COMMON, mage.cards.v.VortexRunner.class)); cards.add(new SetCardInfo("Wandering Archaic", 6, Rarity.RARE, mage.cards.w.WanderingArchaic.class));