closing lobby during game adds game to finished games list.
This commit is contained in:
@@ -83,7 +83,7 @@ public class ChatApp extends Application {
|
||||
Objects.requireNonNull(ChatApp.class.getResource(
|
||||
"splitPaneChatView.fxml")));
|
||||
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);
|
||||
LOGGER.info("3");
|
||||
scene.setRoot(root);
|
||||
|
||||
@@ -217,9 +217,13 @@ public class ClientHandler implements Runnable {
|
||||
*/
|
||||
public void broadcastChatMessageToAll(String msg) {
|
||||
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())) {
|
||||
continue;
|
||||
}
|
||||
*/
|
||||
client.sendMsgToClient(Protocol.printToClientChat + "$" + clientUserName + ": " + msg);
|
||||
}
|
||||
}
|
||||
@@ -459,6 +463,8 @@ public class ClientHandler implements Runnable {
|
||||
Game game = l.getGame();
|
||||
if (game != null) {
|
||||
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
|
||||
*/
|
||||
public void listGames() {
|
||||
if (Lobby.runningGames.isEmpty() && Lobby.finishedGames.isEmpty()) {
|
||||
if (Lobby.runningGames.isEmpty() && Lobby.finishedGames.isEmpty() && Lobby.lobbies.isEmpty()) {
|
||||
sendAnnouncementToClient("No Games");
|
||||
} else {
|
||||
sendAnnouncementToClient("Open Games (i.e. open Lobbies):");
|
||||
for (Lobby l : Lobby.lobbies) {
|
||||
if (l.getLobbyIsOpen()) {
|
||||
sendAnnouncementToClient(" - Lobby Nr. " + l.getLobbyID());
|
||||
}
|
||||
}
|
||||
sendAnnouncementToClient("Running Games:");
|
||||
try {
|
||||
for (Game runningGame : Lobby.runningGames) {
|
||||
|
||||
@@ -31,7 +31,7 @@ public class JServerProtocolParser {
|
||||
try {
|
||||
header = msg.substring(0, 5);
|
||||
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 + ".");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
|
||||
Reference in New Issue
Block a user