[SNC] Fixed shield counter interaction with damage can't be prevented effects

This commit is contained in:
Daniel Bomar 2022-04-15 08:25:51 -05:00
parent 48552c008a
commit 21a1cfbea9
No known key found for this signature in database
GPG key ID: C86C8658F4023918
2 changed files with 32 additions and 7 deletions

View file

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