From bac2585d8399e5c2040971eec1a6ef3444b7b54a Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Tue, 23 Feb 2021 13:47:23 -0500 Subject: [PATCH] [KHM] fixed Draugr Necromancer not allowing snow mana to be used for exiled cards --- .../src/mage/cards/d/DraugrNecromancer.java | 14 ++- .../single/khm/DraugrNecromancerTest.java | 94 +++++++++++++++++++ Mage/src/main/java/mage/game/GameImpl.java | 4 +- 3 files changed, 105 insertions(+), 7 deletions(-) create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/single/khm/DraugrNecromancerTest.java diff --git a/Mage.Sets/src/mage/cards/d/DraugrNecromancer.java b/Mage.Sets/src/mage/cards/d/DraugrNecromancer.java index 7e17180d3c..d9588ce913 100644 --- a/Mage.Sets/src/mage/cards/d/DraugrNecromancer.java +++ b/Mage.Sets/src/mage/cards/d/DraugrNecromancer.java @@ -11,6 +11,7 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.*; import mage.counters.CounterType; +import mage.game.CardState; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.events.ZoneChangeEvent; @@ -159,14 +160,17 @@ class DraugrNecromancerSpendAnyManaEffect extends AsThoughEffectImpl implements @Override public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) { if (!source.isControlledBy(affectedControllerId) - || game.getState().getZone(sourceId) != Zone.EXILED) { + || !game.getOpponents(game.getOwnerId(sourceId)).contains(source.getControllerId())) { return false; } Card card = game.getCard(sourceId); - return card != null - && !card.isLand() - && game.getOpponents(card.getOwnerId()).contains(source.getControllerId()) - && card.getCounters(game).getCount(CounterType.ICE) > 0; + if (card != null + && game.getState().getZone(sourceId) == Zone.EXILED + && card.getCounters(game).getCount(CounterType.ICE) > 0) { + return true; + } + CardState cardState = game.getLastKnownInformationCard(sourceId, Zone.EXILED); + return cardState != null && cardState.getCounters().getCount(CounterType.ICE) > 0; } @Override diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/khm/DraugrNecromancerTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/khm/DraugrNecromancerTest.java new file mode 100644 index 0000000000..a92426078c --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/khm/DraugrNecromancerTest.java @@ -0,0 +1,94 @@ +package org.mage.test.cards.single.khm; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import mage.counters.CounterType; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * @author TheElk801 + */ +public class DraugrNecromancerTest extends CardTestPlayerBase { + + private static final String necromancer = "Draugr Necromancer"; + private static final String bolt = "Lightning Bolt"; + private static final String bear = "Grizzly Bears"; + + @Test + public void testExilesWithCounter() { + addCard(Zone.BATTLEFIELD, playerA, necromancer); + addCard(Zone.BATTLEFIELD, playerA, "Mountain"); + addCard(Zone.HAND, playerA, bolt); + addCard(Zone.BATTLEFIELD, playerB, bear); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, bolt, bear); + + setStopAt(1, PhaseStep.END_TURN); + execute(); + + assertExileCount(playerB, bear, 1); + assertCounterOnExiledCardCount(bear, CounterType.ICE, 1); + } + + @Test + public void testCastFromExile() { + addCard(Zone.BATTLEFIELD, playerA, necromancer); + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2); + addCard(Zone.BATTLEFIELD, playerA, "Forest"); + addCard(Zone.HAND, playerA, bolt); + addCard(Zone.BATTLEFIELD, playerB, bear); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, bolt, bear); + castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, bear); + + setStrictChooseMode(true); + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertExileCount(playerB, bear, 0); + assertPermanentCount(playerA, bear, 1); + } + + @Test + public void testCastFromExileWithSnow() { + addCard(Zone.BATTLEFIELD, playerA, necromancer); + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2); + addCard(Zone.BATTLEFIELD, playerA, "Snow-Covered Swamp"); + addCard(Zone.HAND, playerA, bolt); + addCard(Zone.BATTLEFIELD, playerB, bear); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, bolt, bear); + + castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, bear); + + setStrictChooseMode(true); + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertExileCount(playerB, bear, 0); + assertPermanentCount(playerA, bear, 1); + } + + @Test + public void testCastFromExileWithoutSnow() { + addCard(Zone.BATTLEFIELD, playerA, necromancer); + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2); + addCard(Zone.BATTLEFIELD, playerA, "Swamp"); + addCard(Zone.HAND, playerA, bolt); + addCard(Zone.BATTLEFIELD, playerB, bear); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, bolt, bear); + + castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, bear); + + setStopAt(1, PhaseStep.END_TURN); + execute(); + + assertExileCount(playerB, bear, 1); + assertCounterOnExiledCardCount(bear, CounterType.ICE, 1); + assertPermanentCount(playerA, bear, 0); + } +} diff --git a/Mage/src/main/java/mage/game/GameImpl.java b/Mage/src/main/java/mage/game/GameImpl.java index bcb196150d..c73a583fd8 100644 --- a/Mage/src/main/java/mage/game/GameImpl.java +++ b/Mage/src/main/java/mage/game/GameImpl.java @@ -2954,7 +2954,7 @@ public abstract class GameImpl implements Game, Serializable { @Override public CardState getLastKnownInformationCard(UUID objectId, Zone zone) { - if (zone == Zone.GRAVEYARD) { + if (zone.isPublicZone()) { Map lkiCardStateMap = lkiCardState.get(zone); if (lkiCardStateMap != null) { CardState cardState = lkiCardStateMap.get(objectId); @@ -3008,7 +3008,7 @@ public abstract class GameImpl implements Game, Serializable { lkiExtended.put(objectId, lkiExtendedMap); } } - } else if (Zone.GRAVEYARD.equals(zone)) { + } else if (zone.isPublicZone()) { // Remember card state in this public zone (mainly removed/gained abilities) Map lkiMap = lkiCardState.get(zone); if (lkiMap != null) {