Fixed game error on attack order disconnects

This commit is contained in:
Oleg Agafonov 2023-06-09 06:26:47 +04:00
parent b6e87ddcb8
commit ae5bc90915

View file

@ -663,15 +663,15 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
}
public void pickAttackerOrder(UUID playerId, Game game) {
if (attackers.isEmpty()) {
Player player = game.getPlayer(playerId);
if (attackers.isEmpty() || player == null) {
return;
}
Player player = game.getPlayer(playerId);
List<UUID> attackerList = new ArrayList<>(attackers);
attackerOrder.clear();
List<UUID> newAttackerOrder = new ArrayList<>();
while (true) {
if (attackerList.size() == 1) {
attackerOrder.add(attackerList.get(0));
newAttackerOrder.add(attackerList.get(0));
break;
} else {
List<Permanent> attackerPerms = new ArrayList<>();
@ -682,12 +682,19 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
if (attackerId == null) {
break;
}
attackerOrder.add(attackerId);
newAttackerOrder.add(attackerId);
attackerList.remove(attackerId);
}
}
if (!game.isSimulation() && attackerOrder.size() > 1) {
logDamageAssignmentOrder("Creatures blocked by ", blockers, attackerOrder, game);
if (newAttackerOrder.size() == attackerOrder.size()) {
attackerOrder.clear();
attackerOrder.addAll(newAttackerOrder);
if (!game.isSimulation() && attackerOrder.size() > 1) {
logDamageAssignmentOrder("Creatures blocked by ", blockers, attackerOrder, game);
}
} else {
game.informPlayers(player.getLogName() + " try to skip choose attacker order");
}
}