Fixed: Recreate the game if the only player in the waiting queue crashs
This commit is contained in:
@@ -93,7 +93,7 @@ public class RMIServer extends UnicastRemoteObject implements IGameServer {
|
||||
|
||||
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));
|
||||
playerList.setLimit(preferredInt);
|
||||
System.out.println("Game Created With :"+preferredInt+" Players");
|
||||
|
||||
@@ -160,7 +160,7 @@ public class TCPServer {
|
||||
synchronized (controller) {
|
||||
String username = eventAddPlayer.getUsername();
|
||||
//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());
|
||||
controller.setModel(model);
|
||||
playerList.setLimit(eventAddPlayer.getProposedNPlayer());
|
||||
|
||||
Reference in New Issue
Block a user