diff --git a/Mage.Sets/src/mage/sets/legends/TheAbyss.java b/Mage.Sets/src/mage/sets/legends/TheAbyss.java index 3664e65ad01..2b8e802fe07 100644 --- a/Mage.Sets/src/mage/sets/legends/TheAbyss.java +++ b/Mage.Sets/src/mage/sets/legends/TheAbyss.java @@ -29,11 +29,9 @@ package mage.sets.legends; import java.util.UUID; import mage.abilities.TriggeredAbilityImpl; -import mage.abilities.effects.Effect; import mage.abilities.effects.common.DestroyTargetEffect; import mage.cards.CardImpl; import mage.constants.CardType; -import mage.constants.Outcome; import mage.constants.Rarity; import mage.constants.Zone; import mage.filter.common.FilterCreaturePermanent; @@ -45,7 +43,6 @@ import mage.game.events.GameEvent; import mage.players.Player; import mage.target.Target; import mage.target.common.TargetCreaturePermanent; -import mage.target.targetpointer.FixedTarget; /** * @@ -73,15 +70,15 @@ public class TheAbyss extends CardImpl { } class TheAbyssTriggeredAbility extends TriggeredAbilityImpl { - + TheAbyssTriggeredAbility() { super(Zone.BATTLEFIELD, new DestroyTargetEffect(true), false); } - + TheAbyssTriggeredAbility(final TheAbyssTriggeredAbility ability) { super(ability); } - + @Override public TheAbyssTriggeredAbility copy() { return new TheAbyssTriggeredAbility(this); @@ -91,7 +88,7 @@ class TheAbyssTriggeredAbility extends TriggeredAbilityImpl { public boolean checkEventType(GameEvent event, Game game) { return event.getType() == GameEvent.EventType.UPKEEP_STEP_PRE; } - + @Override public boolean checkTrigger(GameEvent event, Game game) { Player player = game.getPlayer(event.getPlayerId()); @@ -100,18 +97,13 @@ class TheAbyssTriggeredAbility extends TriggeredAbilityImpl { filter.add(Predicates.not(new CardTypePredicate(CardType.ARTIFACT))); filter.add(new ControllerIdPredicate(player.getId())); Target target = new TargetCreaturePermanent(filter); - if (target.canChoose(this.getSourceId(), this.getControllerId(), game) && player.chooseTarget(Outcome.DestroyPermanent, target, this, game)) { - for (Effect effect: this.getEffects()) { - if (effect instanceof DestroyTargetEffect) { - effect.setTargetPointer(new FixedTarget(target.getFirstTarget())); - } - } - return true; - } + this.getTargets().clear(); + this.getTargets().add(target); + return true; } return false; } - + @Override public String getRule() { return "At the beginning of each player's upkeep, destroy target nonartifact creature that player controls of his or her choice. It can't be regenerated."; diff --git a/Mage.Sets/src/mage/sets/riseoftheeldrazi/NotOfThisWorld.java b/Mage.Sets/src/mage/sets/riseoftheeldrazi/NotOfThisWorld.java index a3f6f6e6c1d..558d240f739 100644 --- a/Mage.Sets/src/mage/sets/riseoftheeldrazi/NotOfThisWorld.java +++ b/Mage.Sets/src/mage/sets/riseoftheeldrazi/NotOfThisWorld.java @@ -67,7 +67,7 @@ public class NotOfThisWorld extends CardImpl { // Counter target spell or ability that targets a permanent you control. this.getSpellAbility().addTarget( - new TargetSpellTargetingControlledPermanent()); + new TargetStackObjectTargetingControlledPermanent()); this.getSpellAbility().addEffect(new CounterTargetEffect()); // Not of This World costs {7} less to cast if it targets a spell or ability that targets a creature you control with power 7 or greater. this.addAbility(new SimpleStaticAbility(Zone.STACK, new SpellCostReductionSourceEffect(7, NotOfThisWorldCondition.getInstance()))); @@ -83,17 +83,17 @@ public class NotOfThisWorld extends CardImpl { } } -class TargetSpellTargetingControlledPermanent extends TargetObject { +class TargetStackObjectTargetingControlledPermanent extends TargetObject { - public TargetSpellTargetingControlledPermanent() { + public TargetStackObjectTargetingControlledPermanent() { this.minNumberOfTargets = 1; this.maxNumberOfTargets = 1; this.zone = Zone.STACK; this.targetName = "spell or ability that targets a permanent you control"; } - public TargetSpellTargetingControlledPermanent(final TargetSpellTargetingControlledPermanent target) { + public TargetStackObjectTargetingControlledPermanent(final TargetStackObjectTargetingControlledPermanent target) { super(target); } @@ -164,8 +164,8 @@ class TargetSpellTargetingControlledPermanent extends TargetObject { } @Override - public TargetSpellTargetingControlledPermanent copy() { - return new TargetSpellTargetingControlledPermanent(this); + public TargetStackObjectTargetingControlledPermanent copy() { + return new TargetStackObjectTargetingControlledPermanent(this); } } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/counterspell/NotOfThisWorldTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/counterspell/NotOfThisWorldTest.java new file mode 100644 index 00000000000..41d3992a219 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/counterspell/NotOfThisWorldTest.java @@ -0,0 +1,72 @@ +/* + * 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 org.mage.test.cards.abilities.oneshot.counterspell; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author LevelX2 + */ +public class NotOfThisWorldTest extends CardTestPlayerBase { + + /** + * Not of This World doesn't work when trying to counter a triggerd ability + * from The Abyss targeting your owned and controlled Ruhan of the Fomori . + * At the time I didn't have any mana open, but Ruhan of the Fomori should + * qualify for the alternative casting cost (7 less) or Not of This World. + */ + @Test + public void testCounterFirstSpell() { + // At the beginning of each player's upkeep, destroy target nonartifact creature that player controls of his or her choice. It can't be regenerated. + addCard(Zone.BATTLEFIELD, playerA, "The Abyss", 1); + + addCard(Zone.BATTLEFIELD, playerB, "Island", 7); + // Counter target spell or ability that targets a permanent you control. + // Not of This World costs {7} less to cast if it targets a spell or ability that targets a creature you control with power 7 or greater. + addCard(Zone.HAND, playerB, "Not of This World"); + + // At the beginning of combat on your turn, choose an opponent at random. Ruhan of the Fomori attacks that player this combat if able. + addCard(Zone.BATTLEFIELD, playerB, "Ruhan of the Fomori", 1); // 7/7 + + addTarget(playerB, "Ruhan of the Fomori"); + castSpell(2, PhaseStep.UPKEEP, playerB, "Not of This World", "stack ability (At the beginning of each player's upkeep"); + + setStopAt(2, PhaseStep.PRECOMBAT_MAIN); + execute(); + + assertGraveyardCount(playerB, "Not of This World", 1); + assertPermanentCount(playerB, "Ruhan of the Fomori", 1); + + assertTapped("Island", false); + } + +}