From 1e8cdd0ce1fac01faaa8bb270ce05800acf06848 Mon Sep 17 00:00:00 2001 From: "richard.coates" Date: Wed, 18 Apr 2018 16:35:37 +0200 Subject: [PATCH 1/4] Implement Precognition Field. CAN NOT TEST. --- .../src/mage/cards/p/PrecognitionField.java | 189 ++++++++++++++++++ Mage.Sets/src/mage/sets/Dominaria.java | 1 + 2 files changed, 190 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/p/PrecognitionField.java diff --git a/Mage.Sets/src/mage/cards/p/PrecognitionField.java b/Mage.Sets/src/mage/cards/p/PrecognitionField.java new file mode 100644 index 0000000000..2fbe568797 --- /dev/null +++ b/Mage.Sets/src/mage/cards/p/PrecognitionField.java @@ -0,0 +1,189 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.cards.p; + +import java.util.UUID; + +import mage.MageObject; +import mage.MageObjectReference; +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.effects.AsThoughEffectImpl; +import mage.abilities.effects.ContinuousEffectImpl; +import mage.abilities.effects.Effect; +import mage.abilities.effects.OneShotEffect; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.cards.o.OraclesVaultEffect; +import mage.cards.o.OraclesVaultPlayEffect; +import mage.cards.v.VizierOfTheMenagerieTopCardCastEffect; +import mage.cards.v.VizierOfTheMenagerieTopCardRevealedEffect; +import mage.constants.*; +import mage.game.Game; +import mage.players.Library; +import mage.players.Player; + +/** + * @author rscoates + */ +public class PrecognitionField extends CardImpl { + + public PrecognitionField(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{U}"); + + + // You may look at the top card of your library. + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PrecognitionFieldTopCardRevealedEffect())); + // You may cast the top card of your library if it's an instant or sorcery card. + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PrecognitionFieldTopCardCastEffect())); + // {3}: Exile the top card of your library. + Effect effect = new PrecognitionFieldExileEffect(); + effect.setText("Exile the top card of your library."); + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new GenericManaCost(3)); + } + + public PrecognitionField(final PrecognitionField card) { + super(card); + } + + @Override + public PrecognitionField copy() { + return new PrecognitionField(this); + } +} + +class PrecognitionFieldTopCardRevealedEffect extends ContinuousEffectImpl { + + public PrecognitionFieldTopCardRevealedEffect() { + super(Duration.WhileOnBattlefield, Layer.PlayerEffects, SubLayer.NA, Outcome.Benefit); + staticText = "You may look at the top card of your library. (You may do this at any time.)"; + } + + public PrecognitionFieldTopCardRevealedEffect(final PrecognitionFieldTopCardRevealedEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + Card topCard = controller.getLibrary().getFromTop(game); + if (topCard != null) { + MageObject precognitionField = source.getSourceObject(game); + if (precognitionField != null) { + controller.lookAtCards("Top card of " + precognitionField.getIdName() + " controller's library", topCard, game); + } + } + } + return true; + } + + @Override + public PrecognitionFieldTopCardRevealedEffect copy() { + return new PrecognitionFieldTopCardRevealedEffect(this); + } +} + +class PrecognitionFieldTopCardCastEffect extends AsThoughEffectImpl { + + public PrecognitionFieldTopCardCastEffect() { + super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, Duration.WhileOnBattlefield, Outcome.Benefit); + staticText = "You may cast the top card of your library if it’s an instant or sorcery card.; + } + + public PrecognitionFieldTopCardCastEffect(final PrecognitionFieldTopCardCastEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public PrecognitionFieldTopCardCastEffect copy() { + return new PrecognitionFieldTopCardCastEffect(this); + } + + @Override + public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { + if (affectedControllerId.equals(source.getControllerId())) { + Card card = game.getCard(objectId); + if (card != null) { + Player controller = game.getPlayer(affectedControllerId); + if (controller != null) { + Card topCard = controller.getLibrary().getFromTop(game); + MageObject vizierOfTheMenagerie = game.getObject(source.getSourceId()); + if (vizierOfTheMenagerie != null + && topCard != null) { + return topCard == card + && (topCard.isInstant() || topCard.isSorcery()) + && topCard.getSpellAbility() != null + && topCard.getSpellAbility().spellCanBeActivatedRegularlyNow(controller.getId(), game); + } + } + } + } + return false; + } +} + +class PrecognitionFieldExileEffect extends OneShotEffect { + + public PrecognitionFieldExileEffect() { + super(Outcome.Benefit); + } + + public PrecognitionFieldExileEffect(final PrecognitionFieldExileEffect effect) { + super(effect); + } + + @Override + public PrecognitionFieldExileEffect copy() { + return new PrecognitionFieldExileEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + MageObject sourceObject = source.getSourceObject(game); + if (controller != null && sourceObject != null && controller.getLibrary().hasCards()) { + Library library = controller.getLibrary(); + Card card = library.removeFromTop(game); + if (card != null) { + card.moveToExile(id, "Precognition Field Exile", source.getSourceId(), game); + } + return true; + } + return false; + } +} diff --git a/Mage.Sets/src/mage/sets/Dominaria.java b/Mage.Sets/src/mage/sets/Dominaria.java index b34740b60e..17c06eb889 100644 --- a/Mage.Sets/src/mage/sets/Dominaria.java +++ b/Mage.Sets/src/mage/sets/Dominaria.java @@ -220,6 +220,7 @@ public class Dominaria extends ExpansionSet { cards.add(new SetCardInfo("Plains", 252, Rarity.LAND, mage.cards.basiclands.Plains.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Plains", 253, Rarity.LAND, mage.cards.basiclands.Plains.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Powerstone Shard", 227, Rarity.COMMON, mage.cards.p.PowerstoneShard.class)); + cards.add(new SetCardInfo("Precognition Field", 61, Rarity.RARE, mage.cards.p.PrecognitionField.class)); cards.add(new SetCardInfo("Primevals' Glorious Rebirth", 201, Rarity.RARE, mage.cards.p.PrimevalsGloriousRebirth.class)); cards.add(new SetCardInfo("Primordial Wurm", 177, Rarity.COMMON, mage.cards.p.PrimordialWurm.class)); cards.add(new SetCardInfo("Pyromantic Pilgrim", 278, Rarity.COMMON, mage.cards.p.PyromanticPilgrim.class)); From 98d135df45ff94114ad6e39e1452a67a35297bcf Mon Sep 17 00:00:00 2001 From: "richard.coates" Date: Wed, 18 Apr 2018 16:38:14 +0200 Subject: [PATCH 2/4] Rename functionality. --- Mage.Sets/src/mage/cards/p/PrecognitionField.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Mage.Sets/src/mage/cards/p/PrecognitionField.java b/Mage.Sets/src/mage/cards/p/PrecognitionField.java index 2fbe568797..35bcd71b5f 100644 --- a/Mage.Sets/src/mage/cards/p/PrecognitionField.java +++ b/Mage.Sets/src/mage/cards/p/PrecognitionField.java @@ -142,8 +142,8 @@ class PrecognitionFieldTopCardCastEffect extends AsThoughEffectImpl { Player controller = game.getPlayer(affectedControllerId); if (controller != null) { Card topCard = controller.getLibrary().getFromTop(game); - MageObject vizierOfTheMenagerie = game.getObject(source.getSourceId()); - if (vizierOfTheMenagerie != null + MageObject precognitionField = game.getObject(source.getSourceId()); + if (precognitionField != null && topCard != null) { return topCard == card && (topCard.isInstant() || topCard.isSorcery()) From fde9eb62e9ca217af8c118f57180e61632723051 Mon Sep 17 00:00:00 2001 From: "richard.coates" Date: Wed, 18 Apr 2018 16:40:23 +0200 Subject: [PATCH 3/4] Remove imports --- Mage.Sets/src/mage/cards/p/PrecognitionField.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Mage.Sets/src/mage/cards/p/PrecognitionField.java b/Mage.Sets/src/mage/cards/p/PrecognitionField.java index 35bcd71b5f..91edbe8b8a 100644 --- a/Mage.Sets/src/mage/cards/p/PrecognitionField.java +++ b/Mage.Sets/src/mage/cards/p/PrecognitionField.java @@ -30,11 +30,9 @@ package mage.cards.p; import java.util.UUID; import mage.MageObject; -import mage.MageObjectReference; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.effects.AsThoughEffectImpl; import mage.abilities.effects.ContinuousEffectImpl; @@ -43,10 +41,6 @@ import mage.abilities.effects.OneShotEffect; import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.cards.o.OraclesVaultEffect; -import mage.cards.o.OraclesVaultPlayEffect; -import mage.cards.v.VizierOfTheMenagerieTopCardCastEffect; -import mage.cards.v.VizierOfTheMenagerieTopCardRevealedEffect; import mage.constants.*; import mage.game.Game; import mage.players.Library; From 1dde98fcc21d6c3adcdb53bd86ac09d75b802bfe Mon Sep 17 00:00:00 2001 From: "richard.coates" Date: Wed, 18 Apr 2018 17:50:19 +0200 Subject: [PATCH 4/4] feedback from Comments --- Mage.Sets/src/mage/cards/p/PrecognitionField.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mage.Sets/src/mage/cards/p/PrecognitionField.java b/Mage.Sets/src/mage/cards/p/PrecognitionField.java index 91edbe8b8a..ef071052b2 100644 --- a/Mage.Sets/src/mage/cards/p/PrecognitionField.java +++ b/Mage.Sets/src/mage/cards/p/PrecognitionField.java @@ -111,7 +111,7 @@ class PrecognitionFieldTopCardCastEffect extends AsThoughEffectImpl { public PrecognitionFieldTopCardCastEffect() { super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, Duration.WhileOnBattlefield, Outcome.Benefit); - staticText = "You may cast the top card of your library if it’s an instant or sorcery card.; + staticText = "You may cast the top card of your library if it’s an instant or sorcery card."; } public PrecognitionFieldTopCardCastEffect(final PrecognitionFieldTopCardCastEffect effect) {