From b6661ae79d42ca54b34025824f0d261b51f1b3bf Mon Sep 17 00:00:00 2001 From: spjspj Date: Thu, 20 Oct 2016 16:58:18 +1100 Subject: [PATCH] spjspj - Add Evangelize (TSP) - Also possibly a fix for Preacher which could target Narset, Enlightened Master when it shouldn't be able to --- Mage.Sets/src/mage/cards/e/Evangelize.java | 68 +++++++++++++++++++ Mage.Sets/src/mage/sets/TimeSpiral.java | 1 + .../TargetOpponentsChoicePermanent.java | 20 +++++- 3 files changed, 86 insertions(+), 3 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/e/Evangelize.java diff --git a/Mage.Sets/src/mage/cards/e/Evangelize.java b/Mage.Sets/src/mage/cards/e/Evangelize.java new file mode 100644 index 0000000000..4631c3a97c --- /dev/null +++ b/Mage.Sets/src/mage/cards/e/Evangelize.java @@ -0,0 +1,68 @@ +/* + * 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.e; + +import java.util.UUID; +import mage.abilities.effects.common.continuous.GainControlTargetEffect; +import mage.abilities.keyword.BuybackAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.filter.common.FilterControlledCreaturePermanent; +import mage.target.common.TargetOpponentsChoicePermanent; + +/** + * + * @author spjspj + */ +public class Evangelize extends CardImpl { + + private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent(); + private static final String staticText = "Gain control of target creature of an opponent's choice that he or she controls"; + + public Evangelize(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{4}{W}"); + + // Buyback {2}{W}{W} + this.addAbility(new BuybackAbility("{2}{W}{W}")); + + // Gain control of target creature of an opponent's choice that he or she controls. + this.getSpellAbility().addEffect(new GainControlTargetEffect(Duration.EndOfGame)); + this.getSpellAbility().addTarget(new TargetOpponentsChoicePermanent(1, 1, filter, false)); + } + + public Evangelize(final Evangelize card) { + super(card); + } + + @Override + public Evangelize copy() { + return new Evangelize(this); + } +} diff --git a/Mage.Sets/src/mage/sets/TimeSpiral.java b/Mage.Sets/src/mage/sets/TimeSpiral.java index 206faf76ce..89a8cecf56 100644 --- a/Mage.Sets/src/mage/sets/TimeSpiral.java +++ b/Mage.Sets/src/mage/sets/TimeSpiral.java @@ -86,6 +86,7 @@ public class TimeSpiral extends ExpansionSet { cards.add(new SetCardInfo("Errant Doomsayers", 15, Rarity.COMMON, mage.cards.e.ErrantDoomsayers.class)); cards.add(new SetCardInfo("Errant Ephemeron", 60, Rarity.COMMON, mage.cards.e.ErrantEphemeron.class)); cards.add(new SetCardInfo("Eternity Snare", 61, Rarity.COMMON, mage.cards.e.EternitySnare.class)); + cards.add(new SetCardInfo("Evangelize", 16, Rarity.RARE, mage.cards.e.Evangelize.class)); cards.add(new SetCardInfo("Evil Eye of Urborg", 107, Rarity.UNCOMMON, mage.cards.e.EvilEyeOfUrborg.class)); cards.add(new SetCardInfo("Faceless Devourer", 108, Rarity.UNCOMMON, mage.cards.f.FacelessDevourer.class)); cards.add(new SetCardInfo("Fallen Ideal", 109, Rarity.UNCOMMON, mage.cards.f.FallenIdeal.class)); diff --git a/Mage/src/main/java/mage/target/common/TargetOpponentsChoicePermanent.java b/Mage/src/main/java/mage/target/common/TargetOpponentsChoicePermanent.java index 46b934cd72..34cd992cd8 100644 --- a/Mage/src/main/java/mage/target/common/TargetOpponentsChoicePermanent.java +++ b/Mage/src/main/java/mage/target/common/TargetOpponentsChoicePermanent.java @@ -3,7 +3,6 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ - package mage.target.common; import java.util.UUID; @@ -11,6 +10,7 @@ import mage.abilities.Ability; import mage.constants.Outcome; import mage.filter.FilterPermanent; import mage.game.Game; +import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.TargetPermanent; @@ -26,7 +26,7 @@ public class TargetOpponentsChoicePermanent extends TargetPermanent { super(1, 1, filter, false); this.targetName = filter.getMessage(); } - + public TargetOpponentsChoicePermanent(int minNumTargets, int maxNumTargets, FilterPermanent filter, boolean notTarget) { super(minNumTargets, maxNumTargets, filter, notTarget); this.targetName = filter.getMessage(); @@ -47,8 +47,22 @@ public class TargetOpponentsChoicePermanent extends TargetPermanent { @Override public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) { + Permanent permanent = game.getPermanent(id); if (opponentId != null) { - return super.canTarget(opponentId, id, source, game); + if (permanent != null) { + if (source != null) { + boolean canSourceControllerTarget = true; + if (!isNotTarget()) { + if (!permanent.canBeTargetedBy(game.getObject(source.getId()), controllerId, game) + || !permanent.canBeTargetedBy(game.getObject(source.getSourceId()), controllerId, game)) { + canSourceControllerTarget = false; + } + } + canSourceControllerTarget &= super.canTarget(opponentId, id, source, game); + canSourceControllerTarget &= filter.match(permanent, source.getSourceId(), opponentId, game); + return canSourceControllerTarget; + } + } } return false; }