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<>();
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<CombatGroup> {
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;
}