From a16f247611f237c6674a2fe4851377a7760298c9 Mon Sep 17 00:00:00 2001 From: Daniel Bomar Date: Wed, 3 Nov 2021 10:18:22 -0500 Subject: [PATCH] [VOW] Implemented Consuming Tide --- Mage.Sets/src/mage/cards/c/ConsumingTide.java | 98 +++++++++++++++++++ .../src/mage/sets/InnistradCrimsonVow.java | 1 + 2 files changed, 99 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/c/ConsumingTide.java diff --git a/Mage.Sets/src/mage/cards/c/ConsumingTide.java b/Mage.Sets/src/mage/cards/c/ConsumingTide.java new file mode 100644 index 0000000000..3e71ee8ec1 --- /dev/null +++ b/Mage.Sets/src/mage/cards/c/ConsumingTide.java @@ -0,0 +1,98 @@ +package mage.cards.c; + +import java.util.HashSet; +import java.util.UUID; + +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.common.TargetNonlandPermanent; + +/** + * + * @author weirddan455 + */ +public final class ConsumingTide extends CardImpl { + + public ConsumingTide(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{U}{U}"); + + // Each player chooses a nonland permanent they control. Return all nonland permanents not chosen this way to their owners' hands. + // Then you draw a card for each opponent who has more cards in their hand than you. + this.getSpellAbility().addEffect(new ConsumingTideEffect()); + } + + private ConsumingTide(final ConsumingTide card) { + super(card); + } + + @Override + public ConsumingTide copy() { + return new ConsumingTide(this); + } +} + +class ConsumingTideEffect extends OneShotEffect { + + public ConsumingTideEffect() { + super(Outcome.ReturnToHand); + staticText = "Each player chooses a nonland permanent they control. Return all nonland permanents not chosen this way to their owners' hands. " + + "Then you draw a card for each opponent who has more cards in their hand than you"; + } + + private ConsumingTideEffect(final ConsumingTideEffect effect) { + super(effect); + } + + @Override + public ConsumingTideEffect copy() { + return new ConsumingTideEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller == null) { + return false; + } + HashSet chosenPermanents = new HashSet<>(); + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { + Player player = game.getPlayer(playerId); + if (player != null) { + TargetNonlandPermanent target = new TargetNonlandPermanent(); + target.setNotTarget(true); + player.choose(Outcome.Benefit, target, source.getSourceId(), game); + UUID permId = target.getFirstTarget(); + if (permId != null) { + chosenPermanents.add(permId); + } + } + } + HashSet permanentsToHand = new HashSet<>(); + for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_NON_LAND, controller.getId(), source.getSourceId(), game)) { + if (!chosenPermanents.contains(permanent.getId())) { + permanentsToHand.add(permanent); + } + } + controller.moveCards(permanentsToHand, Zone.HAND, source, game); + int controllerHandSize = controller.getHand().size(); + int cardsToDraw = 0; + for (UUID opponentId : game.getOpponents(controller.getId())) { + Player opponent = game.getPlayer(opponentId); + if (opponent != null && opponent.getHand().size() > controllerHandSize) { + cardsToDraw++; + } + } + controller.drawCards(cardsToDraw, source, game); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/InnistradCrimsonVow.java b/Mage.Sets/src/mage/sets/InnistradCrimsonVow.java index 6317c45b04..4d09e29191 100644 --- a/Mage.Sets/src/mage/sets/InnistradCrimsonVow.java +++ b/Mage.Sets/src/mage/sets/InnistradCrimsonVow.java @@ -51,6 +51,7 @@ public final class InnistradCrimsonVow extends ExpansionSet { cards.add(new SetCardInfo("Change of Fortune", 150, Rarity.RARE, mage.cards.c.ChangeOfFortune.class)); cards.add(new SetCardInfo("Clever Distraction", 9, Rarity.UNCOMMON, mage.cards.c.CleverDistraction.class)); cards.add(new SetCardInfo("Cloaked Cadet", 192, Rarity.UNCOMMON, mage.cards.c.CloakedCadet.class)); + cards.add(new SetCardInfo("Consuming Tide", 53, Rarity.RARE, mage.cards.c.ConsumingTide.class)); cards.add(new SetCardInfo("Dawnhart Geist", 8, Rarity.UNCOMMON, mage.cards.d.DawnhartGeist.class)); cards.add(new SetCardInfo("Deathcap Glade", 261, Rarity.RARE, mage.cards.d.DeathcapGlade.class)); cards.add(new SetCardInfo("Demonic Bargain", 103, Rarity.RARE, mage.cards.d.DemonicBargain.class));