Now the Game appears when a game is started and disapears again when it is over

This commit is contained in:
Seraina 2022-05-01 13:11:17 +02:00
parent 1b30cd6435
commit f0f4f9142e
7 changed files with 34 additions and 14 deletions

View File

@ -1,3 +1,4 @@
B
serai
serai
serai

View File

@ -170,10 +170,10 @@ public class Game implements Runnable {
if (gameOverCheck.equals(ClientGameInfoHandler.gameOverGhostsWin) && getOgGhost().getIsPlayer()) {
OgGhostHighScore.addOgGhostWinner(getOgGhost().getName());
}
lobby.getAdmin().sendMsgToClientsInLobby(Protocol.printToGUI + "$" + GuiParameters.viewChangeToLobby + "$");
lobby.getAdmin().broadcastAnnouncementToLobby(gameOverCheck);
isOngoing = false;
Timer.ghostAfterVoteTimer();
lobby.getAdmin().sendMsgToClientsInLobby(Protocol.printToGUI + "$" + GuiParameters.viewChangeToLobby + "$");
isOngoing = true;
lobby.removeGameFromRunningGames(this);
lobby.addGameToFinishedGames(this);

View File

@ -383,15 +383,17 @@ public class Client {
case GuiParameters.getMembersInLobby:
updateLobbyMembers(data);
break;
//case GuiParameters.viewChangeToGame: (commented out due to compiling error)
case GuiParameters.viewChangeToGame:
chatApp.getLoungeSceneViewController().addGameView();
//TODO
//break; (commented out due to compiling error)
//case GuiParameters.viewChangeToStart: (commented out due to compiling error)
break;
/*case GuiParameters.viewChangeToStart:
//TODO
//break; (commented out due to compiling error)
//case GuiParameters.viewChangeToLobby: (commented out due to compiling error)
break;*/
case GuiParameters.viewChangeToLobby:
chatApp.getLoungeSceneViewController().removeGameView();
//TODO
//break; (commented out due to compiling error)
break;
case GuiParameters.addNewMemberToLobby:
addPlayerToLobby(data);
break;

View File

@ -99,6 +99,10 @@ public class ChatApp extends Application {
return chatController;
}
public LoungeSceneViewController getLoungeSceneViewController() {
return loungeSceneViewController;
}
public LoungeSceneViewController getlSVController() {
return lSVController;
}

View File

@ -127,6 +127,8 @@ public class LoungeSceneViewController implements Initializable {
@Override
public void run() {
try {
newGameButton.setVisible(false);
startGame.setVisible(false);
gameAnchorPane.getChildren().add(chatApp.game);
} catch (Exception e) {
LOGGER.debug("Not yet initialized");
@ -135,6 +137,21 @@ public class LoungeSceneViewController implements Initializable {
});
}
public void removeGameView(){
Platform.runLater(new Runnable() {
@Override
public void run() {
try {
newGameButton.setVisible(true);
startGame.setVisible(true);
gameAnchorPane.getChildren().clear();
} catch (Exception e) {
LOGGER.debug("Not yet initialized");
}
}
});
}
public void updateClientListView(ObservableList<SimpleStringProperty> names) {
ObservableList<SimpleStringProperty> clientsLeft = ClientListView.getItems();
clientsLeft.removeAll(names);
@ -203,7 +220,7 @@ public class LoungeSceneViewController implements Initializable {
public void startGame() {
client.getClient().sendMsgToServer(Protocol.startANewGame);
addGameView();
//addGameView();
}
public void leaveLobby() {client.getClient().sendMsgToServer(Protocol.leaveLobby);}

View File

@ -48,10 +48,6 @@ public class GuiParameters {
*/
public static final String getMembersInLobby = "LMEMBS";
/**
* Tells Gui, that a new Lobby has been created. Form: {@code NLOBBY$<lobbyID>:<Admin Name>}
*/
public static final String changeToLobby = "LMEMBS";
/**
* Informs the GUI, that a vote is over

View File

@ -104,7 +104,7 @@ public class JServerProtocolParser {
break;
case Protocol.leaveLobby:
h.leaveLobby();
//h.sendMsgToClient(Protocol.printToGUI + "$" + GuiParameters.viewChangeToStart + "$"); (commented out due to compiling error)
h.sendMsgToClient(Protocol.printToGUI + "$" + GuiParameters.viewChangeToStart + "$");
break;
case Protocol.votedFor:
LOGGER.debug("Made it here");
@ -113,7 +113,7 @@ public class JServerProtocolParser {
break;
case Protocol.startANewGame:
h.startNewGame();
//h.sendMsgToClientsInLobby(Protocol.printToGUI + "$" + GuiParameters.viewChangeToGame + "$"); (commented out due to compiling error)
h.sendMsgToClientsInLobby(Protocol.printToGUI + "$" + GuiParameters.viewChangeToGame + "$");
break;
case Protocol.listGames:
h.listGames();