diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/replacement/ShieldCounterTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/replacement/ShieldCounterTest.java index 56a3c575887..3353ec7c9a4 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/replacement/ShieldCounterTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/replacement/ShieldCounterTest.java @@ -65,4 +65,23 @@ public class ShieldCounterTest extends CardTestPlayerBase { assertPermanentCount(playerA, "Disciplined Duelist", 1); assertCounterCount("Disciplined Duelist", CounterType.SHIELD, 0); } + + // Effects that say "Damage can't be prevented" should both remove the shield counter and deal damage + // TODO: Find a high toughness creature with a shield counter to test this better + @Test + public void testDamagePrevention() { + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 3); + addCard(Zone.BATTLEFIELD, playerA, "Disciplined Duelist"); + addCard(Zone.HAND, playerA, "Call In a Professional", 1); + setStrictChooseMode(true); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Call In a Professional"); + addTarget(playerA, "Disciplined Duelist"); + + setStopAt(1, PhaseStep.END_TURN); + execute(); + + assertAllCommandsUsed(); + assertGraveyardCount(playerA, "Disciplined Duelist", 1); + } } diff --git a/Mage/src/main/java/mage/abilities/effects/keyword/ShieldCounterEffect.java b/Mage/src/main/java/mage/abilities/effects/keyword/ShieldCounterEffect.java index 1670b714c0f..07a218188bd 100644 --- a/Mage/src/main/java/mage/abilities/effects/keyword/ShieldCounterEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/keyword/ShieldCounterEffect.java @@ -32,14 +32,20 @@ public class ShieldCounterEffect extends ReplacementEffectImpl { @Override public boolean replaceEvent(GameEvent event, Ability source, Game game) { Permanent permanent = game.getPermanent(event.getTargetId()); - if (permanent != null && permanent.getCounters(game).getCount(CounterType.SHIELD) > 0) { - permanent.removeCounters(CounterType.SHIELD.getName(), 1, source, game); - if (!game.isSimulation()) { - game.informPlayers("Removed a shield counter from " + permanent.getLogName()); - } - return true; + if (permanent == null || permanent.getCounters(game).getCount(CounterType.SHIELD) < 1) { + return false; } - return false; + permanent.removeCounters(CounterType.SHIELD.getName(), 1, source, game); + if (!game.isSimulation()) { + game.informPlayers("Removed a shield counter from " + permanent.getLogName()); + } + // Damage should be prevented rather than replacing the event. + // Effects that say "damage can't be prevented" will have the creature both take the damage and remove a shield counter. + if (event.getType() == GameEvent.EventType.DAMAGE_PERMANENT) { + game.preventDamage(event, source, game, Integer.MAX_VALUE); + return false; + } + return true; } @Override