Made sure the start button only has functionality when in a lobby

This commit is contained in:
Seraina 2022-05-16 19:47:01 +02:00
parent 126a2c21d3
commit ec661365bd
4 changed files with 10 additions and 3 deletions

View File

@ -416,8 +416,12 @@ public class Client {
removeLobbyFromGui(data);
break;
case GuiParameters.updateLobbyString:
if(!data.isEmpty()) {
lobbyDisplayHandler.updateLobbies(data);
ChatApp.getListController().updateList();
} else {
ChatApp.getListController().clearVBox();
}
break;
default:
notificationTextDisplay(data);

View File

@ -415,6 +415,7 @@ public class ClientHandler implements Runnable {
Thread t = new Thread(game);
t.start();
l.addGameToRunningGames(game);
sendMsgToClientsInLobby(Protocol.printToGUI + "$" + GuiParameters.viewChangeToGame + "$");
} else {
sendAnnouncementToClient("Only the admin can start the game");
}

View File

@ -115,7 +115,6 @@ public class JServerProtocolParser {
break;
case Protocol.startANewGame:
h.startNewGame();
h.sendMsgToClientsInLobby(Protocol.printToGUI + "$" + GuiParameters.viewChangeToGame + "$");
break;
case Protocol.listGames:
h.listGames();

View File

@ -27,6 +27,9 @@ public class LobbyUpdater implements Runnable{
if (!Lobby.lobbies.isEmpty()) {
client.sendMsgToClient(
Protocol.printToGUI + "$" + GuiParameters.updateLobbyString + "$" + lobbiesAsString);
} else{
client.sendMsgToClient(
Protocol.printToGUI + "$" + GuiParameters.updateLobbyString + "$");
}
}
}