Added: now if the server crash when there is only one player, at the restart the server will forgive the old game. (Probably also the remaining player is disconnected)

This commit is contained in:
rubenpirreram
2026-05-20 17:16:48 +02:00
parent 986196a52f
commit 7ebce2e968
2 changed files with 9 additions and 2 deletions
@@ -129,8 +129,8 @@ public class Inventor extends Character {
*/
@Override
public void insert(Player player) {
player.buildingCards.stream().filter(b -> b.getEffectId() == 4).forEach(b4 -> b4.applyEffect(player));
player.inventors.add(this);
player.buildingCards.stream().filter(b -> b.getEffectId() == 4).forEach(b4 -> b4.applyEffect(player));
player.buildingCards.stream().filter(x->x.getEffectId()==0).forEach(x->x.applyEffect(player));
}
}
@@ -86,7 +86,13 @@ public class ServerLauncher {
this.actionQueue = actionQueue;
this.serverRMI = serverRMI;
this.gameController = gameController;
this.gameController.setModel(loadSave());
Game game= loadSave();
if(gameController.getModel().disconnetedPlayers.entrySet().stream().filter(Map.Entry::getValue).count() >gameController.getModel().getNPlayers()-1){
gameController.setModel(null);
this.deleteSave();
}
else
this.gameController.setModel(game);
this.serverTCP = serverTCP;
}
@@ -237,6 +243,7 @@ public class ServerLauncher {
}
}
serverCrashed = true;
} else {
serverCrashed = false;
}