mirror of
https://github.com/correl/mage.git
synced 2025-04-12 17:00:08 -09:00
[SNC] Fixed shield counter interaction with damage can't be prevented effects
This commit is contained in:
parent
48552c008a
commit
21a1cfbea9
2 changed files with 32 additions and 7 deletions
Mage.Tests/src/test/java/org/mage/test/cards/replacement
Mage/src/main/java/mage/abilities/effects/keyword
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue