diff --git a/Mage.Sets/src/mage/sets/eldritchmoon/PermeatingMass.java b/Mage.Sets/src/mage/sets/eldritchmoon/PermeatingMass.java index 9990aa09b9c..61461fb5ee9 100644 --- a/Mage.Sets/src/mage/sets/eldritchmoon/PermeatingMass.java +++ b/Mage.Sets/src/mage/sets/eldritchmoon/PermeatingMass.java @@ -88,9 +88,9 @@ class PermeatingMassEffect extends OneShotEffect { public boolean apply(Game game, Ability ability) { Permanent copyTo = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, ability)); if (copyTo != null) { - Permanent copyFrom = game.getPermanent(ability.getSourceId()); + Permanent copyFrom = (Permanent) ability.getSourceObject(game); if (copyFrom != null) { - game.copyPermanent(Duration.WhileOnBattlefield, copyFrom, copyTo.getId(), ability, new EmptyApplyToPermanent()); + game.copyPermanent(Duration.Custom, copyFrom, copyTo.getId(), ability, new EmptyApplyToPermanent()); } } return true; diff --git a/Mage.Sets/src/mage/sets/eldritchmoon/TreeOfPerdition.java b/Mage.Sets/src/mage/sets/eldritchmoon/TreeOfPerdition.java index a6bd9ae4923..b0fb21ace23 100644 --- a/Mage.Sets/src/mage/sets/eldritchmoon/TreeOfPerdition.java +++ b/Mage.Sets/src/mage/sets/eldritchmoon/TreeOfPerdition.java @@ -108,7 +108,7 @@ class TreeOfPerditionEffect extends OneShotEffect { return false; } opponent.setLife(amount, game); - game.addEffect(new SetPowerToughnessSourceEffect(Integer.MIN_VALUE, life, Duration.WhileOnBattlefield, SubLayer.SetPT_7b), source); + game.addEffect(new SetPowerToughnessSourceEffect(Integer.MIN_VALUE, life, Duration.Custom, SubLayer.SetPT_7b), source); return true; } } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/replacement/DiscardEffectsTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/replacement/DiscardEffectsTest.java new file mode 100644 index 00000000000..233bb083c21 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/replacement/DiscardEffectsTest.java @@ -0,0 +1,58 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.mage.test.cards.replacement; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author escplan9 (Derek Monturo - dmontur1 at gmail dot com) + */ +public class DiscardEffectsTest extends CardTestPlayerBase { + + @Test + public void testOpponentDiscardsLoxodonSmiter() { + + addCard(Zone.HAND, playerA, "Thoughtseize"); // {B} target player, discard non-land card, lose two life. + addCard(Zone.BATTLEFIELD, playerA, "Swamp"); + // Loxodon Smiter can't be countered. + // If a spell or ability an opponent controls causes you to discard Loxodon Smiter, put it onto the battlefield instead of putting it into your graveyard. + addCard(Zone.HAND, playerB, "Loxodon Smiter"); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Thoughtseize"); + addTarget(playerA, playerB); + setChoice(playerA, "Loxodon Smiter"); + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertLife(playerA, 18); + assertGraveyardCount(playerA, "Thoughtseize", 1); + assertGraveyardCount(playerB, "Loxodon Smiter", 0); + assertPermanentCount(playerB, "Loxodon Smiter", 1); + } + + @Test + public void testOwnerDiscardsOwnLoxodonSmiter() { + + // Loxodon Smiter can't be countered. + // If a spell or ability an opponent controls causes you to discard Loxodon Smiter, put it onto the battlefield instead of putting it into your graveyard. + addCard(Zone.HAND, playerA, "Loxodon Smiter"); + addCard(Zone.HAND, playerA, "Sift"); // {3}{U} Sorcery - draw 3 discard 1 + addCard(Zone.BATTLEFIELD, playerA, "Island", 4); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Sift"); + setChoice(playerA, "Loxodon Smiter"); + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertGraveyardCount(playerA, "Sift", 1); + assertGraveyardCount(playerA, "Loxodon Smiter", 1); + assertPermanentCount(playerA, "Loxodon Smiter", 0); + } +} diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/emn/PermeatingMassTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/emn/PermeatingMassTest.java index 159f2f5ec9c..e4622437723 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/single/emn/PermeatingMassTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/emn/PermeatingMassTest.java @@ -7,7 +7,6 @@ package org.mage.test.cards.single.emn; import mage.constants.PhaseStep; import mage.constants.Zone; -import mage.game.permanent.Permanent; import org.junit.Test; import org.mage.test.serverside.base.CardTestPlayerBase; @@ -16,24 +15,24 @@ import org.mage.test.serverside.base.CardTestPlayerBase; * @author escplan9 (Derek Monturo - dmontur1 at gmail dot com) */ public class PermeatingMassTest extends CardTestPlayerBase { - + @Test public void testWhenDiesInCombatMakesCopyStill() { - + addCard(Zone.BATTLEFIELD, playerA, "Hill Giant"); // 3/3 - + // Whenever Permeating Mass deals combat damage to a creature, that creature becomes a copy of Permeating Mass. addCard(Zone.BATTLEFIELD, playerB, "Permeating Mass"); // 1/3 - + attack(1, playerA, "Hill Giant"); block(1, playerB, "Permeating Mass", "Hill Giant"); - + setStopAt(1, PhaseStep.END_COMBAT); execute(); - + assertLife(playerB, 20); assertGraveyardCount(playerB, "Permeating Mass", 1); - Permanent hilly = getPermanent("Hill Giant", playerA); - assertPowerToughness(playerA, "Hill Giant", 1, 3); + assertPermanentCount(playerA, "Permeating Mass", 1); + assertPowerToughness(playerA, "Permeating Mass", 1, 3); } }