Fixed: Recreate the game if the only player in the waiting queue crashs

This commit is contained in:
rubenpirreram
2026-06-19 18:03:48 +02:00
parent 6a1b66aa9d
commit 9bca2b969f
2 changed files with 2 additions and 2 deletions
@@ -93,7 +93,7 @@ public class RMIServer extends UnicastRemoteObject implements IGameServer {
synchronized (controller) { synchronized (controller) {
if (playerList.isEmpty() && controller.getModel()==null) { if (playerList.isEmpty() &&(controller.getModel()==null || controller.getModel().getCurrentState().getGameStage().equals(GameStages.WAITING))) {
controller.setModel(new Game(preferredInt)); controller.setModel(new Game(preferredInt));
playerList.setLimit(preferredInt); playerList.setLimit(preferredInt);
System.out.println("Game Created With :"+preferredInt+" Players"); System.out.println("Game Created With :"+preferredInt+" Players");
@@ -160,7 +160,7 @@ public class TCPServer {
synchronized (controller) { synchronized (controller) {
String username = eventAddPlayer.getUsername(); String username = eventAddPlayer.getUsername();
//reconnect players after a server crash //reconnect players after a server crash
if (playerList.isEmpty()&& controller.getModel()==null) { if (playerList.isEmpty() &&(controller.getModel()==null || controller.getModel().getCurrentState().getGameStage().equals(GameStages.WAITING))) {
Game model = new Game(eventAddPlayer.getProposedNPlayer()); Game model = new Game(eventAddPlayer.getProposedNPlayer());
controller.setModel(model); controller.setModel(model);
playerList.setLimit(eventAddPlayer.getProposedNPlayer()); playerList.setLimit(eventAddPlayer.getProposedNPlayer());