Added view change printToGui parameter for Start, Lobby and Game
This commit is contained in:
parent
1246c8e4ea
commit
3aca60d8ee
@ -152,18 +152,19 @@ public class Game implements Runnable {
|
||||
LOGGER.info("NIGHT");
|
||||
gameOverCheck = voteHandler.ghostVote(gameState.getPassengerTrain(), this);
|
||||
setDay(true);
|
||||
lobby.getAdmin().sendMsgToClientsInLobby(Protocol.printToGUI + "$" + ClientGameInfoHandler.itsDayTime);
|
||||
lobby.getAdmin().sendMsgToClientsInLobby(Protocol.printToGUI + "$" + ClientGameInfoHandler.itsDayTime + "$");
|
||||
} else {
|
||||
LOGGER.info("DAY");
|
||||
gameOverCheck = voteHandler.humanVote(gameState.getPassengerTrain(), this);
|
||||
setDay(false);
|
||||
lobby.getAdmin().sendMsgToClientsInLobby(Protocol.printToGUI + "$" + ClientGameInfoHandler.itsNightTime);
|
||||
lobby.getAdmin().sendMsgToClientsInLobby(Protocol.printToGUI + "$" + ClientGameInfoHandler.itsNightTime + "$");
|
||||
}
|
||||
if (gameOverCheck.equals(ClientGameInfoHandler.gameOverGhostsWin) || gameOverCheck.equals(
|
||||
ClientGameInfoHandler.gameOverHumansWin)) {
|
||||
if (gameOverCheck.equals(ClientGameInfoHandler.gameOverGhostsWin) && getOgGhost().getIsPlayer()) {
|
||||
OgGhostHighScore.addOgGhostWinner(getOgGhost().getName());
|
||||
}
|
||||
lobby.getAdmin().sendMsgToClientsInLobby(Protocol.printToGUI + "$" + GuiParameters.viewChangeToLobby + "$");
|
||||
lobby.getAdmin().broadcastAnnouncementToLobby(gameOverCheck);
|
||||
lobby.removeGameFromRunningGames(this);
|
||||
lobby.addGameToFinishedGames(this);
|
||||
|
||||
@ -338,8 +338,19 @@ public class Client {
|
||||
}
|
||||
break;
|
||||
case GuiParameters.listOfLobbies:
|
||||
//TODO
|
||||
break;
|
||||
case GuiParameters.listOfPLayers:
|
||||
//TODO
|
||||
break;
|
||||
case GuiParameters.viewChangeToGame:
|
||||
//TODO
|
||||
break;
|
||||
case GuiParameters.viewChangeToStart:
|
||||
//TODO
|
||||
break;
|
||||
case GuiParameters.viewChangeToLobby:
|
||||
//TODO
|
||||
break;
|
||||
default:
|
||||
notificationTextDisplay(data);
|
||||
|
||||
@ -23,7 +23,7 @@ public class GameStateModel {
|
||||
* can take the values h/g/s for human/ghost/spectator. Safes the role the client this GamesStateModel
|
||||
* lives on currently has
|
||||
*/
|
||||
private String yourRole;
|
||||
private String yourRole; //TODO: Maybe add a GUI field to show this in
|
||||
|
||||
/**
|
||||
* A primitive clone of the passengerTrain in the GameState of the server.
|
||||
|
||||
@ -25,6 +25,21 @@ public class GuiParameters {
|
||||
*/
|
||||
public static final String noiseHeardAtPosition = "NOISE";
|
||||
|
||||
/**
|
||||
* Tells Gui, that the start view should be displayed
|
||||
*/
|
||||
public static final String viewChangeToStart = "VCSTART";
|
||||
|
||||
/**
|
||||
* Tells Gui, that the lobby view should be displayed
|
||||
*/
|
||||
public static final String viewChangeToLobby = "VCLOBBY";
|
||||
|
||||
/**
|
||||
* Tells Gui, that the game view should be displayed
|
||||
*/
|
||||
public static final String viewChangeToGame = "VCGAME";
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ package ch.unibas.dmi.dbis.cs108.multiplayer.server;
|
||||
|
||||
|
||||
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.helpers.GuiParameters;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.helpers.Protocol;
|
||||
@ -81,6 +82,7 @@ public class JServerProtocolParser {
|
||||
try {
|
||||
int i = Integer.parseInt(msg.substring(6, 7));
|
||||
h.joinLobby(i);
|
||||
h.sendMsgToClient(Protocol.printToGUI + "$" + GuiParameters.viewChangeToLobby + "$");
|
||||
} catch (Exception e) {
|
||||
h.sendMsgToClient(Protocol.printToClientConsole
|
||||
+ "$Invalid input. Please use JOINL$1 to join Lobby 1, for example.");
|
||||
@ -88,6 +90,7 @@ public class JServerProtocolParser {
|
||||
break;
|
||||
case Protocol.createNewLobby:
|
||||
h.createNewLobby();
|
||||
h.sendMsgToClient(Protocol.printToGUI + "$" + GuiParameters.viewChangeToLobby+ "$");
|
||||
break;
|
||||
case Protocol.listLobbies:
|
||||
h.listLobbies();
|
||||
@ -97,6 +100,7 @@ public class JServerProtocolParser {
|
||||
break;
|
||||
case Protocol.leaveLobby:
|
||||
h.leaveLobby();
|
||||
h.sendMsgToClient(Protocol.printToGUI + "$" + GuiParameters.viewChangeToStart + "$");
|
||||
break;
|
||||
case Protocol.votedFor:
|
||||
LOGGER.debug("Made it here");
|
||||
@ -105,6 +109,7 @@ public class JServerProtocolParser {
|
||||
break;
|
||||
case Protocol.startANewGame:
|
||||
h.startNewGame();
|
||||
h.sendMsgToClientsInLobby(Protocol.printToGUI + "$" + GuiParameters.viewChangeToGame + "$");
|
||||
break;
|
||||
case Protocol.listGames:
|
||||
h.listGames();
|
||||
|
||||
Reference in New Issue
Block a user