From 17800b6df158a9e0b0b8e585ad47954770987b60 Mon Sep 17 00:00:00 2001 From: L_J Date: Sat, 17 Feb 2018 22:25:27 +0000 Subject: [PATCH] Menace fix --- .../java/mage/game/combat/CombatGroup.java | 57 ++++++++----------- 1 file changed, 25 insertions(+), 32 deletions(-) diff --git a/Mage/src/main/java/mage/game/combat/CombatGroup.java b/Mage/src/main/java/mage/game/combat/CombatGroup.java index 57b9877d491..350dfd4e6f6 100644 --- a/Mage/src/main/java/mage/game/combat/CombatGroup.java +++ b/Mage/src/main/java/mage/game/combat/CombatGroup.java @@ -302,7 +302,7 @@ public class CombatGroup implements Serializable, Copyable { Map assigned = new HashMap<>(); if (blocked) { boolean excessDamageToDefender = true; - for (UUID blockerId : new ArrayList<>(blockerOrder)) { // prevent ConcurrentModificationException + for (UUID blockerId : blockerOrder) { Permanent blocker = game.getPermanent(blockerId); if (blocker != null) { int lethalDamage; @@ -732,42 +732,35 @@ public class CombatGroup implements Serializable, Copyable { for (UUID uuid : attackers) { Permanent attacker = game.getPermanent(uuid); - // Check if there are enough blockers to have a legal block - if (attacker != null && this.blocked && attacker.getMinBlockedBy() > 1 && !blockers.isEmpty() && blockers.size() < attacker.getMinBlockedBy()) { - for (UUID blockerId : blockers) { - Permanent blocker = game.getPermanent(blockerId); - if (blocker != null) { - blocker.setBlocking(blocker.getBlocking() - 1); + if (attacker != null && this.blocked) { + // Check if there are enough blockers to have a legal block + if (attacker.getMinBlockedBy() > 1 && !blockers.isEmpty() && blockers.size() < attacker.getMinBlockedBy()) { + for (UUID blockerId : new ArrayList<>(blockers)) { + game.getCombat().removeBlocker(blockerId, game); } - } - blockers.clear(); - blockerOrder.clear(); - this.blocked = false; - if (!game.isSimulation()) { - game.informPlayers(attacker.getLogName() + " can't be blocked except by " + attacker.getMinBlockedBy() + " or more creatures. Blockers discarded."); - } - blockWasLegal = false; - } - // Check if there are too many blockers (maxBlockedBy = 0 means no restrictions) - if (attacker != null && this.blocked && attacker.getMaxBlockedBy() > 0 && attacker.getMaxBlockedBy() < blockers.size()) { - for (UUID blockerId : blockers) { - Permanent blocker = game.getPermanent(blockerId); - if (blocker != null) { - blocker.setBlocking(blocker.getBlocking() - 1); + blockers.clear(); + blockerOrder.clear(); + if (!game.isSimulation()) { + game.informPlayers(attacker.getLogName() + " can't be blocked except by " + attacker.getMinBlockedBy() + " or more creatures. Blockers discarded."); } + blockWasLegal = false; } - blockers.clear(); - blockerOrder.clear(); - this.blocked = false; - if (!game.isSimulation()) { - game.informPlayers(new StringBuilder(attacker.getLogName()) - .append(" can't be blocked by more than ").append(attacker.getMaxBlockedBy()) - .append(attacker.getMaxBlockedBy() == 1 ? " creature." : " creatures.") - .append(" Blockers discarded.").toString()); + // Check if there are too many blockers (maxBlockedBy = 0 means no restrictions) + if (attacker.getMaxBlockedBy() > 0 && attacker.getMaxBlockedBy() < blockers.size()) { + for (UUID blockerId : new ArrayList<>(blockers)) { + game.getCombat().removeBlocker(blockerId, game); + } + blockers.clear(); + blockerOrder.clear(); + if (!game.isSimulation()) { + game.informPlayers(new StringBuilder(attacker.getLogName()) + .append(" can't be blocked by more than ").append(attacker.getMaxBlockedBy()) + .append(attacker.getMaxBlockedBy() == 1 ? " creature." : " creatures.") + .append(" Blockers discarded.").toString()); + } + blockWasLegal = false; } - blockWasLegal = false; } - } return blockWasLegal; }