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");
|
LOGGER.info("NIGHT");
|
||||||
gameOverCheck = voteHandler.ghostVote(gameState.getPassengerTrain(), this);
|
gameOverCheck = voteHandler.ghostVote(gameState.getPassengerTrain(), this);
|
||||||
setDay(true);
|
setDay(true);
|
||||||
lobby.getAdmin().sendMsgToClientsInLobby(Protocol.printToGUI + "$" + ClientGameInfoHandler.itsDayTime);
|
lobby.getAdmin().sendMsgToClientsInLobby(Protocol.printToGUI + "$" + ClientGameInfoHandler.itsDayTime + "$");
|
||||||
} else {
|
} else {
|
||||||
LOGGER.info("DAY");
|
LOGGER.info("DAY");
|
||||||
gameOverCheck = voteHandler.humanVote(gameState.getPassengerTrain(), this);
|
gameOverCheck = voteHandler.humanVote(gameState.getPassengerTrain(), this);
|
||||||
setDay(false);
|
setDay(false);
|
||||||
lobby.getAdmin().sendMsgToClientsInLobby(Protocol.printToGUI + "$" + ClientGameInfoHandler.itsNightTime);
|
lobby.getAdmin().sendMsgToClientsInLobby(Protocol.printToGUI + "$" + ClientGameInfoHandler.itsNightTime + "$");
|
||||||
}
|
}
|
||||||
if (gameOverCheck.equals(ClientGameInfoHandler.gameOverGhostsWin) || gameOverCheck.equals(
|
if (gameOverCheck.equals(ClientGameInfoHandler.gameOverGhostsWin) || gameOverCheck.equals(
|
||||||
ClientGameInfoHandler.gameOverHumansWin)) {
|
ClientGameInfoHandler.gameOverHumansWin)) {
|
||||||
if (gameOverCheck.equals(ClientGameInfoHandler.gameOverGhostsWin) && getOgGhost().getIsPlayer()) {
|
if (gameOverCheck.equals(ClientGameInfoHandler.gameOverGhostsWin) && getOgGhost().getIsPlayer()) {
|
||||||
OgGhostHighScore.addOgGhostWinner(getOgGhost().getName());
|
OgGhostHighScore.addOgGhostWinner(getOgGhost().getName());
|
||||||
}
|
}
|
||||||
|
lobby.getAdmin().sendMsgToClientsInLobby(Protocol.printToGUI + "$" + GuiParameters.viewChangeToLobby + "$");
|
||||||
lobby.getAdmin().broadcastAnnouncementToLobby(gameOverCheck);
|
lobby.getAdmin().broadcastAnnouncementToLobby(gameOverCheck);
|
||||||
lobby.removeGameFromRunningGames(this);
|
lobby.removeGameFromRunningGames(this);
|
||||||
lobby.addGameToFinishedGames(this);
|
lobby.addGameToFinishedGames(this);
|
||||||
|
|||||||
@ -338,8 +338,19 @@ public class Client {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GuiParameters.listOfLobbies:
|
case GuiParameters.listOfLobbies:
|
||||||
|
//TODO
|
||||||
break;
|
break;
|
||||||
case GuiParameters.listOfPLayers:
|
case GuiParameters.listOfPLayers:
|
||||||
|
//TODO
|
||||||
|
break;
|
||||||
|
case GuiParameters.viewChangeToGame:
|
||||||
|
//TODO
|
||||||
|
break;
|
||||||
|
case GuiParameters.viewChangeToStart:
|
||||||
|
//TODO
|
||||||
|
break;
|
||||||
|
case GuiParameters.viewChangeToLobby:
|
||||||
|
//TODO
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
notificationTextDisplay(data);
|
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
|
* can take the values h/g/s for human/ghost/spectator. Safes the role the client this GamesStateModel
|
||||||
* lives on currently has
|
* 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.
|
* 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";
|
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.BudaLogConfig;
|
||||||
|
import ch.unibas.dmi.dbis.cs108.multiplayer.helpers.GuiParameters;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import ch.unibas.dmi.dbis.cs108.multiplayer.helpers.Protocol;
|
import ch.unibas.dmi.dbis.cs108.multiplayer.helpers.Protocol;
|
||||||
@ -81,6 +82,7 @@ public class JServerProtocolParser {
|
|||||||
try {
|
try {
|
||||||
int i = Integer.parseInt(msg.substring(6, 7));
|
int i = Integer.parseInt(msg.substring(6, 7));
|
||||||
h.joinLobby(i);
|
h.joinLobby(i);
|
||||||
|
h.sendMsgToClient(Protocol.printToGUI + "$" + GuiParameters.viewChangeToLobby + "$");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
h.sendMsgToClient(Protocol.printToClientConsole
|
h.sendMsgToClient(Protocol.printToClientConsole
|
||||||
+ "$Invalid input. Please use JOINL$1 to join Lobby 1, for example.");
|
+ "$Invalid input. Please use JOINL$1 to join Lobby 1, for example.");
|
||||||
@ -88,6 +90,7 @@ public class JServerProtocolParser {
|
|||||||
break;
|
break;
|
||||||
case Protocol.createNewLobby:
|
case Protocol.createNewLobby:
|
||||||
h.createNewLobby();
|
h.createNewLobby();
|
||||||
|
h.sendMsgToClient(Protocol.printToGUI + "$" + GuiParameters.viewChangeToLobby+ "$");
|
||||||
break;
|
break;
|
||||||
case Protocol.listLobbies:
|
case Protocol.listLobbies:
|
||||||
h.listLobbies();
|
h.listLobbies();
|
||||||
@ -97,6 +100,7 @@ public class JServerProtocolParser {
|
|||||||
break;
|
break;
|
||||||
case Protocol.leaveLobby:
|
case Protocol.leaveLobby:
|
||||||
h.leaveLobby();
|
h.leaveLobby();
|
||||||
|
h.sendMsgToClient(Protocol.printToGUI + "$" + GuiParameters.viewChangeToStart + "$");
|
||||||
break;
|
break;
|
||||||
case Protocol.votedFor:
|
case Protocol.votedFor:
|
||||||
LOGGER.debug("Made it here");
|
LOGGER.debug("Made it here");
|
||||||
@ -105,6 +109,7 @@ 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();
|
||||||
|
|||||||
Reference in New Issue
Block a user