diff --git a/Mage.Sets/src/mage/sets/khansoftarkir/IcefeatherAven.java b/Mage.Sets/src/mage/sets/khansoftarkir/IcefeatherAven.java index dd3000c012..6071e276db 100644 --- a/Mage.Sets/src/mage/sets/khansoftarkir/IcefeatherAven.java +++ b/Mage.Sets/src/mage/sets/khansoftarkir/IcefeatherAven.java @@ -70,7 +70,7 @@ public class IcefeatherAven extends CardImpl { // Morph {1}{G}{U} this.addAbility(new MorphAbility(this, new ManaCostsImpl("{1}{G}{U}"))); // When Icefeather Aven is turned face up, you may return another target creature to its owner's hand. - Ability ability = new TurnedFaceUpSourceTriggeredAbility(new ReturnToHandTargetEffect()); + Ability ability = new TurnedFaceUpSourceTriggeredAbility(new ReturnToHandTargetEffect(), false, true); ability.addTarget(new TargetCreaturePermanent(filter)); this.addAbility(ability); diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/MorphTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/MorphTest.java index 1c8325675d..153c7b91ff 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/MorphTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/MorphTest.java @@ -89,7 +89,7 @@ public class MorphTest extends CardTestPlayerBase { * Test triggered turn face up ability of Pine Walker */ @Test - public void testCopyFaceDwonMorphCreature() { + public void testTurnFaceUpTrigger() { addCard(Zone.HAND, playerA, "Pine Walker"); addCard(Zone.BATTLEFIELD, playerA, "Forest", 5); @@ -110,6 +110,42 @@ public class MorphTest extends CardTestPlayerBase { assertTapped("Pine Walker", false); } + + /** + * Test triggered turn face up ability of Pine Walker did not trigger as + * long as Pine Walker is not turned face up. + * + */ + @Test + public void testDoesNotTriggerFaceDown() { + addCard(Zone.HAND, playerA, "Pine Walker"); + addCard(Zone.HAND, playerA, "Icefeather Aven"); + addCard(Zone.BATTLEFIELD, playerA, "Forest", 3); + addCard(Zone.BATTLEFIELD, playerA, "Island", 3); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Pine Walker"); + setChoice(playerA, "Yes"); // cast it face down as 2/2 creature + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Icefeather Aven"); + setChoice(playerA, "Yes"); // cast it face down as 2/2 creature + + attack(3, playerA, ""); + attack(3, playerA, ""); + activateAbility(3, PhaseStep.DECLARE_BLOCKERS, playerA, "{1}{G}{U}: Turn this face-down permanent face up."); + setChoice(playerA, "No"); // Don't use return permanent to hand effect + + setStopAt(3, PhaseStep.POSTCOMBAT_MAIN); + execute(); + + assertLife(playerB, 16); + + assertHandCount(playerA, "Pine Walker", 0); + assertHandCount(playerA, "Icefeather Aven", 0); + assertPermanentCount(playerA, "", 1); + assertPermanentCount(playerA, "Icefeather Aven", 1); + assertTapped("Icefeather Aven", true); + + } + /** * Test that Morph creature do not trigger abilities with their face up attributes * diff --git a/Mage/src/mage/abilities/common/TurnFaceUpAbility.java b/Mage/src/mage/abilities/common/TurnFaceUpAbility.java index a6fb365c00..0b24e5edda 100644 --- a/Mage/src/mage/abilities/common/TurnFaceUpAbility.java +++ b/Mage/src/mage/abilities/common/TurnFaceUpAbility.java @@ -30,9 +30,11 @@ package mage.abilities.common; import mage.abilities.Ability; import mage.abilities.ActivatedAbilityImpl; +import mage.abilities.costs.Cost; import mage.abilities.costs.Costs; import mage.abilities.effects.OneShotEffect; import mage.cards.Card; +import mage.constants.AbilityType; import mage.constants.Outcome; import mage.constants.Zone; import mage.game.Game; @@ -46,9 +48,10 @@ import mage.players.Player; public class TurnFaceUpAbility extends ActivatedAbilityImpl { - public TurnFaceUpAbility(Costs costs) { + public TurnFaceUpAbility(Costs costs) { super(Zone.BATTLEFIELD, new TurnFaceUpEffect(), costs); this.usesStack = false; + this.abilityType = AbilityType.SPECIAL_ACTION; this.setRuleVisible(false); // will be made visible only to controller in CardView } diff --git a/Mage/src/mage/abilities/common/TurnedFaceUpAllTriggeredAbility.java b/Mage/src/mage/abilities/common/TurnedFaceUpAllTriggeredAbility.java index 64e5cfcf08..a32e0d3ae2 100644 --- a/Mage/src/mage/abilities/common/TurnedFaceUpAllTriggeredAbility.java +++ b/Mage/src/mage/abilities/common/TurnedFaceUpAllTriggeredAbility.java @@ -54,7 +54,7 @@ public class TurnedFaceUpAllTriggeredAbility extends TriggeredAbilityImpl { public TurnedFaceUpAllTriggeredAbility(Effect effect, FilterPermanent filter, boolean setTargetPointer) { super(Zone.BATTLEFIELD, effect); - // has to be set so the ability triggers if card is turn faced up + // has to be set so the ability triggers if card itself is turn faced up this.setWorksFaceDown(true); this.filter = filter; this.setTargetPointer = setTargetPointer; @@ -75,6 +75,18 @@ public class TurnedFaceUpAllTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { if (EventType.TURNEDFACEUP.equals(event.getType())) { + if (!event.getTargetId().equals(getSourceId())) { + Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(getSourceId()); + if (sourcePermanent != null) { + if (sourcePermanent.isFaceDown()) { + // if face down and it's not itself that is turned face up, it does not trigger + return false; + } + } else { + // Permanent is and was not on the battlefield + return false; + } + } Permanent permanent = game.getPermanent(event.getTargetId()); if (filter.match(permanent, getSourceId(), getControllerId(), game)) { if (setTargetPointer) { diff --git a/Mage/src/mage/abilities/common/TurnedFaceUpSourceTriggeredAbility.java b/Mage/src/mage/abilities/common/TurnedFaceUpSourceTriggeredAbility.java index 43312a0d0d..25ffceefdb 100644 --- a/Mage/src/mage/abilities/common/TurnedFaceUpSourceTriggeredAbility.java +++ b/Mage/src/mage/abilities/common/TurnedFaceUpSourceTriggeredAbility.java @@ -26,9 +26,13 @@ public class TurnedFaceUpSourceTriggeredAbility extends TriggeredAbilityImpl { public TurnedFaceUpSourceTriggeredAbility(Effect effect) { this(effect, false); } - + public TurnedFaceUpSourceTriggeredAbility(Effect effect, boolean setTargetPointer) { - super(Zone.BATTLEFIELD, effect); + this(effect, setTargetPointer, false); + } + + public TurnedFaceUpSourceTriggeredAbility(Effect effect, boolean setTargetPointer, boolean optional) { + super(Zone.BATTLEFIELD, effect, optional); // has to be set so the ability triggers if card is turn faced up this.setWorksFaceDown(true); this.setTargetPointer = setTargetPointer;