From 8bebca825779e09ab163d4b6c8fa67ac29b2aa63 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Thu, 26 Jul 2018 15:47:09 -0400 Subject: [PATCH] Implemented Isolated Watchtower --- .../src/mage/cards/i/IsolatedWatchtower.java | 118 ++++++++++++++++++ Mage.Sets/src/mage/sets/Commander2018.java | 1 + 2 files changed, 119 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/i/IsolatedWatchtower.java diff --git a/Mage.Sets/src/mage/cards/i/IsolatedWatchtower.java b/Mage.Sets/src/mage/cards/i/IsolatedWatchtower.java new file mode 100644 index 00000000000..f3307da13fb --- /dev/null +++ b/Mage.Sets/src/mage/cards/i/IsolatedWatchtower.java @@ -0,0 +1,118 @@ +package mage.cards.i; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.condition.Condition; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.decorator.ConditionalActivatedAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.mana.ColorlessManaAbility; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.cards.CardsImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.players.Player; + +/** + * + * @author TheElk801 + */ +public final class IsolatedWatchtower extends CardImpl { + + public IsolatedWatchtower(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.LAND}, ""); + + // {T}: Add {C}. + this.addAbility(new ColorlessManaAbility()); + + // {2}, {T}: Scry 1, then you may reveal the top card of your library. If a basic land card is revealed this way, put it onto the battlefield tapped. Activate this ability only if an opponent controls at least two more lands than you. + Ability ability = new ConditionalActivatedAbility( + Zone.BATTLEFIELD, + new IsolatedWatchtowerEffect(), + new GenericManaCost(2), + new IsolatedWatchtowerCondition() + ); + ability.addCost(new TapSourceCost()); + this.addAbility(ability); + } + + public IsolatedWatchtower(final IsolatedWatchtower card) { + super(card); + } + + @Override + public IsolatedWatchtower copy() { + return new IsolatedWatchtower(this); + } +} + +class IsolatedWatchtowerEffect extends OneShotEffect { + + public IsolatedWatchtowerEffect() { + super(Outcome.Benefit); + this.staticText = "scry 1, then you may reveal the top card " + + "of your library. If a basic land card is revealed this way, " + + "put it onto the battlefield tapped"; + } + + public IsolatedWatchtowerEffect(final IsolatedWatchtowerEffect effect) { + super(effect); + } + + @Override + public IsolatedWatchtowerEffect copy() { + return new IsolatedWatchtowerEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + player.scry(1, source, game); + if (!player.chooseUse( + outcome, "Reveal the top card of your library?", source, game + )) { + return true; + } + Card card = player.getLibrary().getFromTop(game); + player.revealCards(source, new CardsImpl(card), game); + if (card.isBasic() && card.isLand()) { + player.moveCards( + card, Zone.BATTLEFIELD, source, + game, true, false, true, null + ); + } + return true; + } +} + +class IsolatedWatchtowerCondition implements Condition { + + @Override + public boolean apply(Game game, Ability source) { + int numLands = game.getBattlefield().countAll( + StaticFilters.FILTER_LAND, source.getControllerId(), game + ); + for (UUID opponentId : game.getOpponents(source.getControllerId())) { + if (numLands < 1 + game.getBattlefield().countAll( + StaticFilters.FILTER_LAND, opponentId, game + )) { + return true; + } + } + return false; + } + + @Override + public String toString() { + return "an opponent controls at least two more lands than you"; + } +} diff --git a/Mage.Sets/src/mage/sets/Commander2018.java b/Mage.Sets/src/mage/sets/Commander2018.java index 1d5eb0f1cfd..eca1bdfeef7 100644 --- a/Mage.Sets/src/mage/sets/Commander2018.java +++ b/Mage.Sets/src/mage/sets/Commander2018.java @@ -46,6 +46,7 @@ public final class Commander2018 extends ExpansionSet { cards.add(new SetCardInfo("Heavenly Blademaster", 3, Rarity.RARE, mage.cards.h.HeavenlyBlademaster.class)); cards.add(new SetCardInfo("Herald of the Pantheon", 151, Rarity.RARE, mage.cards.h.HeraldOfThePantheon.class)); cards.add(new SetCardInfo("Hydra Omnivore", 153, Rarity.MYTHIC, mage.cards.h.HydraOmnivore.class)); + cards.add(new SetCardInfo("Isolated Watchtower", 59, Rarity.RARE, mage.cards.i.IsolatedWatchtower.class)); cards.add(new SetCardInfo("Kestia, the Cultivator", 42, Rarity.MYTHIC, mage.cards.k.KestiaTheCultivator.class)); cards.add(new SetCardInfo("Lord Windgrace", 43, Rarity.MYTHIC, mage.cards.l.LordWindgrace.class)); cards.add(new SetCardInfo("Loyal Apprentice", 23, Rarity.UNCOMMON, mage.cards.l.LoyalApprentice.class));