1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-01-16 11:08:00 +00:00

Menace fix

This commit is contained in:
L_J 2018-02-17 22:25:27 +00:00 committed by GitHub
parent 3a800dea8e
commit 17800b6df1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -302,7 +302,7 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
Map<UUID, Integer> assigned = new HashMap<>(); Map<UUID, Integer> assigned = new HashMap<>();
if (blocked) { if (blocked) {
boolean excessDamageToDefender = true; boolean excessDamageToDefender = true;
for (UUID blockerId : new ArrayList<>(blockerOrder)) { // prevent ConcurrentModificationException for (UUID blockerId : blockerOrder) {
Permanent blocker = game.getPermanent(blockerId); Permanent blocker = game.getPermanent(blockerId);
if (blocker != null) { if (blocker != null) {
int lethalDamage; int lethalDamage;
@ -732,33 +732,26 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
for (UUID uuid : attackers) { for (UUID uuid : attackers) {
Permanent attacker = game.getPermanent(uuid); Permanent attacker = game.getPermanent(uuid);
if (attacker != null && this.blocked) {
// Check if there are enough blockers to have a legal block // 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()) { if (attacker.getMinBlockedBy() > 1 && !blockers.isEmpty() && blockers.size() < attacker.getMinBlockedBy()) {
for (UUID blockerId : blockers) { for (UUID blockerId : new ArrayList<>(blockers)) {
Permanent blocker = game.getPermanent(blockerId); game.getCombat().removeBlocker(blockerId, game);
if (blocker != null) {
blocker.setBlocking(blocker.getBlocking() - 1);
}
} }
blockers.clear(); blockers.clear();
blockerOrder.clear(); blockerOrder.clear();
this.blocked = false;
if (!game.isSimulation()) { if (!game.isSimulation()) {
game.informPlayers(attacker.getLogName() + " can't be blocked except by " + attacker.getMinBlockedBy() + " or more creatures. Blockers discarded."); game.informPlayers(attacker.getLogName() + " can't be blocked except by " + attacker.getMinBlockedBy() + " or more creatures. Blockers discarded.");
} }
blockWasLegal = false; blockWasLegal = false;
} }
// Check if there are too many blockers (maxBlockedBy = 0 means no restrictions) // Check if there are too many blockers (maxBlockedBy = 0 means no restrictions)
if (attacker != null && this.blocked && attacker.getMaxBlockedBy() > 0 && attacker.getMaxBlockedBy() < blockers.size()) { if (attacker.getMaxBlockedBy() > 0 && attacker.getMaxBlockedBy() < blockers.size()) {
for (UUID blockerId : blockers) { for (UUID blockerId : new ArrayList<>(blockers)) {
Permanent blocker = game.getPermanent(blockerId); game.getCombat().removeBlocker(blockerId, game);
if (blocker != null) {
blocker.setBlocking(blocker.getBlocking() - 1);
}
} }
blockers.clear(); blockers.clear();
blockerOrder.clear(); blockerOrder.clear();
this.blocked = false;
if (!game.isSimulation()) { if (!game.isSimulation()) {
game.informPlayers(new StringBuilder(attacker.getLogName()) game.informPlayers(new StringBuilder(attacker.getLogName())
.append(" can't be blocked by more than ").append(attacker.getMaxBlockedBy()) .append(" can't be blocked by more than ").append(attacker.getMaxBlockedBy())
@ -767,7 +760,7 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
} }
blockWasLegal = false; blockWasLegal = false;
} }
}
} }
return blockWasLegal; return blockWasLegal;
} }