closing lobby during game adds game to finished games list.

This commit is contained in:
Jonas 2022-04-18 22:39:10 +02:00
parent 15d342f14b
commit 1247bc2035
5 changed files with 18 additions and 6 deletions

View File

@ -19,7 +19,7 @@ public class BudaLogConfig {
LoggerContext ctx = (LoggerContext) LogManager.getContext(false); LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
Configuration config = ctx.getConfiguration(); Configuration config = ctx.getConfiguration();
LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME); LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME);
loggerConfig.setLevel(Level.INFO); // change level here loggerConfig.setLevel(Level.ERROR); // change level here
ctx.updateLoggers(); // This causes all Loggers to refetch information from their LoggerConfig. ctx.updateLoggers(); // This causes all Loggers to refetch information from their LoggerConfig.
} }

View File

@ -109,7 +109,7 @@ public class Game implements Runnable {
LOGGER.info(gameState.toString()); LOGGER.info(gameState.toString());
i = 0; i = 0;
while (isOngoing == true) { while (isOngoing) {
if (!isDay) { if (!isDay) {
LOGGER.info("NIGHT"); LOGGER.info("NIGHT");
gameOverCheck = voteHandler.ghostVote(gameState.getPassengerTrain(), this); gameOverCheck = voteHandler.ghostVote(gameState.getPassengerTrain(), this);

View File

@ -83,7 +83,7 @@ public class ChatApp extends Application {
Objects.requireNonNull(ChatApp.class.getResource( Objects.requireNonNull(ChatApp.class.getResource(
"splitPaneChatView.fxml"))); "splitPaneChatView.fxml")));
LOGGER.info("2"); LOGGER.info("2");
// TODO bin chatController.getChatPaneRoot() border to root border for rezising // TODO bin chatController.getChatPaneRoot() border to root border for resizing
Scene scene = new Scene(root); Scene scene = new Scene(root);
LOGGER.info("3"); LOGGER.info("3");
scene.setRoot(root); scene.setRoot(root);

View File

@ -217,9 +217,13 @@ public class ClientHandler implements Runnable {
*/ */
public void broadcastChatMessageToAll(String msg) { public void broadcastChatMessageToAll(String msg) {
for (ClientHandler client : connectedClients) { for (ClientHandler client : connectedClients) {
// we can un-comment this if we want broadcast to only send to everyone else, excluding the person who sent it.
/*
if (client.getClientUserName().equals(this.getClientUserName())) { if (client.getClientUserName().equals(this.getClientUserName())) {
continue; continue;
} }
*/
client.sendMsgToClient(Protocol.printToClientChat + "$" + clientUserName + ": " + msg); client.sendMsgToClient(Protocol.printToClientChat + "$" + clientUserName + ": " + msg);
} }
} }
@ -459,6 +463,8 @@ public class ClientHandler implements Runnable {
Game game = l.getGame(); Game game = l.getGame();
if (game != null) { if (game != null) {
l.getGame().getGameState().handleClientDisconnect(this); l.getGame().getGameState().handleClientDisconnect(this);
l.removeGameFromRunningGames(game);
l.addGameToFinishedGames(game);
} }
} }
} }
@ -523,13 +529,19 @@ public class ClientHandler implements Runnable {
} }
/** /**
* Lists all Games currenty running and already finished and displays it to the client handled by * Lists all Games currently running and already finished and displays it to the client handled by
* this * this
*/ */
public void listGames() { public void listGames() {
if (Lobby.runningGames.isEmpty() && Lobby.finishedGames.isEmpty()) { if (Lobby.runningGames.isEmpty() && Lobby.finishedGames.isEmpty() && Lobby.lobbies.isEmpty()) {
sendAnnouncementToClient("No Games"); sendAnnouncementToClient("No Games");
} else { } else {
sendAnnouncementToClient("Open Games (i.e. open Lobbies):");
for (Lobby l : Lobby.lobbies) {
if (l.getLobbyIsOpen()) {
sendAnnouncementToClient(" - Lobby Nr. " + l.getLobbyID());
}
}
sendAnnouncementToClient("Running Games:"); sendAnnouncementToClient("Running Games:");
try { try {
for (Game runningGame : Lobby.runningGames) { for (Game runningGame : Lobby.runningGames) {

View File

@ -31,7 +31,7 @@ public class JServerProtocolParser {
try { try {
header = msg.substring(0, 5); header = msg.substring(0, 5);
if (!header.equals(Protocol.pingBack) && !header.equals( if (!header.equals(Protocol.pingBack) && !header.equals(
Protocol.pingFromClient)) { //for debuging without constant pings Protocol.pingFromClient)) { //for debugging without constant pings
LOGGER.debug("got message: " + msg + "."); LOGGER.debug("got message: " + msg + ".");
} }
} catch (IndexOutOfBoundsException e) { } catch (IndexOutOfBoundsException e) {