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); removeLobbyFromGui(data);
break; break;
case GuiParameters.updateLobbyString: case GuiParameters.updateLobbyString:
lobbyDisplayHandler.updateLobbies(data); if(!data.isEmpty()) {
ChatApp.getListController().updateList(); lobbyDisplayHandler.updateLobbies(data);
ChatApp.getListController().updateList();
} else {
ChatApp.getListController().clearVBox();
}
break; break;
default: default:
notificationTextDisplay(data); notificationTextDisplay(data);

View File

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

View File

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

View File

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