From 88dd1a8a33e2f4e67d90f0765d15e9e29ea8772b Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Wed, 13 Jun 2018 08:42:16 -0400 Subject: [PATCH] Implemented Patient Rebuilding --- .../src/mage/cards/p/PatientRebuilding.java | 85 +++++++++++++++++++ Mage.Sets/src/mage/sets/CoreSet2019.java | 1 + 2 files changed, 86 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/p/PatientRebuilding.java diff --git a/Mage.Sets/src/mage/cards/p/PatientRebuilding.java b/Mage.Sets/src/mage/cards/p/PatientRebuilding.java new file mode 100644 index 00000000000..a884bf96150 --- /dev/null +++ b/Mage.Sets/src/mage/cards/p/PatientRebuilding.java @@ -0,0 +1,85 @@ +package mage.cards.p; + +import java.util.Set; +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; +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.TargetController; +import mage.constants.Zone; +import mage.game.Game; +import mage.players.Player; +import mage.target.common.TargetOpponent; + +/** + * + * @author TheElk801 + */ +public final class PatientRebuilding extends CardImpl { + + public PatientRebuilding(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{U}{U}"); + + // At the beginning of your upkeep, target opponent puts the top three cards of their library into their graveyard, then you draw a card for each land card put into that graveyard this way. + Ability ability = new BeginningOfUpkeepTriggeredAbility( + new PatientRebuildingEffect(), + TargetController.YOU, + false + ); + ability.addTarget(new TargetOpponent()); + this.addAbility(ability); + } + + public PatientRebuilding(final PatientRebuilding card) { + super(card); + } + + @Override + public PatientRebuilding copy() { + return new PatientRebuilding(this); + } +} + +class PatientRebuildingEffect extends OneShotEffect { + + public PatientRebuildingEffect() { + super(Outcome.DrawCard); + this.staticText = "target opponent puts the top three cards of their library into their graveyard, " + + "then you draw a card for each land card put into that graveyard this way"; + } + + public PatientRebuildingEffect(final PatientRebuildingEffect effect) { + super(effect); + } + + @Override + public PatientRebuildingEffect copy() { + return new PatientRebuildingEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getFirstTarget()); + Player controller = game.getPlayer(source.getControllerId()); + if (controller == null || player == null) { + return false; + } + int numberOfLandCards = 0; + Set movedCards = player.moveCardsToGraveyardWithInfo(player.getLibrary().getTopCards(game, 3), source, game, Zone.LIBRARY); + for (Card card : movedCards) { + if (card.isLand()) { + numberOfLandCards++; + } + } + if (numberOfLandCards > 0) { + return controller.drawCards(numberOfLandCards, game) > 0; + } + return true; + } + +} diff --git a/Mage.Sets/src/mage/sets/CoreSet2019.java b/Mage.Sets/src/mage/sets/CoreSet2019.java index 351c5adb9b4..de295f5b398 100644 --- a/Mage.Sets/src/mage/sets/CoreSet2019.java +++ b/Mage.Sets/src/mage/sets/CoreSet2019.java @@ -87,6 +87,7 @@ public final class CoreSet2019 extends ExpansionSet { cards.add(new SetCardInfo("Omenspeaker", 64, Rarity.COMMON, mage.cards.o.Omenspeaker.class)); cards.add(new SetCardInfo("Onakke Ogre", 153, Rarity.COMMON, mage.cards.o.OnakkeOgre.class)); cards.add(new SetCardInfo("Oreskos Swiftclaw", 31, Rarity.COMMON, mage.cards.o.OreskosSwiftclaw.class)); + cards.add(new SetCardInfo("Patient Rebuilding", 67, Rarity.RARE, mage.cards.p.PatientRebuilding.class)); cards.add(new SetCardInfo("Pegasus Courser", 32, Rarity.COMMON, mage.cards.p.PegasusCourser.class)); cards.add(new SetCardInfo("Plummet", 193, Rarity.COMMON, mage.cards.p.Plummet.class)); cards.add(new SetCardInfo("Rabid Bite", 195, Rarity.COMMON, mage.cards.r.RabidBite.class));