[KHM] fixed Draugr Necromancer not allowing snow mana to be used for exiled cards

This commit is contained in:
Evan Kranzler 2021-02-23 13:47:23 -05:00
parent 683d5e7c25
commit bac2585d83
3 changed files with 105 additions and 7 deletions

View file

@ -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

View file

@ -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);
}
}

View file

@ -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<UUID, CardState> 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<UUID, CardState> lkiMap = lkiCardState.get(zone);
if (lkiMap != null) {