diff --git a/Mage.Sets/src/mage/cards/t/TorturedExistence.java b/Mage.Sets/src/mage/cards/t/TorturedExistence.java index 8ff13eb53e..3de0c9747d 100644 --- a/Mage.Sets/src/mage/cards/t/TorturedExistence.java +++ b/Mage.Sets/src/mage/cards/t/TorturedExistence.java @@ -24,7 +24,7 @@ public final class TorturedExistence extends CardImpl { // {B}, Discard a creature card: Return target creature card from your graveyard to your hand. Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ReturnFromGraveyardToHandTargetEffect(), new ManaCostsImpl("{B}")); - ability.addCost(new DiscardCardCost(StaticFilters.FILTER_CARD_CREATURE)); + ability.addCost(new DiscardCardCost(StaticFilters.FILTER_CARD_CREATURE_A)); ability.addTarget(new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD)); this.addAbility(ability); } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/eld/BarteredCowTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/eld/BarteredCowTest.java new file mode 100644 index 0000000000..4e951974c1 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/eld/BarteredCowTest.java @@ -0,0 +1,88 @@ +package org.mage.test.cards.single.eld; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author LevelX2 + */ +public class BarteredCowTest extends CardTestPlayerBase { + + @Test + public void testDiesTrigger() { + setStrictChooseMode(true); + + // When Bartered Cow dies or when you discard it, create a Food token. + addCard(Zone.BATTLEFIELD, playerA, "Bartered Cow"); // Creature {3}{W} 3/3 + + addCard(Zone.HAND, playerB, "Lightning Bolt", 1); + addCard(Zone.BATTLEFIELD, playerB, "Mountain"); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Lightning Bolt", "Bartered Cow"); + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertAllCommandsUsed(); + + assertGraveyardCount(playerB, "Lightning Bolt", 1); + assertGraveyardCount(playerA, "Bartered Cow", 1); + assertPermanentCount(playerA, "Food", 1); + } + + @Test + public void testDiscardTrigger() { + setStrictChooseMode(true); + + // When Bartered Cow dies or when you discard it, create a Food token. + addCard(Zone.HAND, playerA, "Bartered Cow"); // Creature {3}{W} 3/3 + // Choose one — + // • Target player discards a card. + // • Target creature gets +2/-1 until end of turn. + // • Target creature gains swampwalk until end of turn. (It can't be blocked as long as defending player controls a Swamp.) + addCard(Zone.HAND, playerB, "Funeral Charm", 1); // Instant {B} + addCard(Zone.BATTLEFIELD, playerB, "Swamp"); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Funeral Charm"); + setModeChoice(playerB, "1"); + addTarget(playerB, playerA); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertAllCommandsUsed(); + + assertGraveyardCount(playerB, "Funeral Charm", 1); + assertGraveyardCount(playerA, "Bartered Cow", 1); + assertPermanentCount(playerA, "Food", 1); + } + + @Test + public void testDiscardTriggerWithTorturedExistence() { + setStrictChooseMode(true); + + // When Bartered Cow dies or when you discard it, create a Food token. + addCard(Zone.HAND, playerA, "Bartered Cow"); // Creature {3}{W} 3/3 + + // {B}, Discard a creature card: Return target creature card from your graveyard to your hand. + addCard(Zone.BATTLEFIELD, playerA, "Tortured Existence", 1); // Instant {B} + addCard(Zone.BATTLEFIELD, playerA, "Swamp"); + addCard(Zone.GRAVEYARD, playerA, "Silvercoat Lion"); + + activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{B}, Discard a creature card"); + setChoice(playerA, "Bartered Cow"); + addTarget(playerA, "Silvercoat Lion"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertAllCommandsUsed(); + + assertGraveyardCount(playerA, "Bartered Cow", 1); + assertHandCount(playerA, "Silvercoat Lion", 1); + assertPermanentCount(playerA, "Food", 1); + } + +} diff --git a/Mage/src/main/java/mage/abilities/effects/common/DiscardCardControllerTriggeredAbility.java b/Mage/src/main/java/mage/abilities/effects/common/DiscardCardControllerTriggeredAbility.java index 5f5cc1875c..3e96e54f71 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DiscardCardControllerTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DiscardCardControllerTriggeredAbility.java @@ -43,7 +43,7 @@ public class DiscardCardControllerTriggeredAbility extends TriggeredAbilityImpl @Override public boolean checkTrigger(GameEvent event, Game game) { return event.getPlayerId().equals(getControllerId()) - && filter.match(game.getCard(event.getTargetId()), getId(), getControllerId(), game); + && filter.match(game.getCard(event.getTargetId()), getSourceId(), getControllerId(), game); } @Override