From e86a09e9a86e16f391fc599bd70ac468b39001b7 Mon Sep 17 00:00:00 2001 From: sebaschi <74497638+sebaschi@users.noreply.github.com> Date: Fri, 8 Apr 2022 15:14:15 +0200 Subject: [PATCH] Completed "else{}" part in addPlayer() method. If the lobby is full a msg is sent to client stating to join a different lobby a creat a new game. Added todo about the servers response. --- .../java/ch/unibas/dmi/dbis/cs108/sebaschi/Lobby.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/ch/unibas/dmi/dbis/cs108/sebaschi/Lobby.java b/src/main/java/ch/unibas/dmi/dbis/cs108/sebaschi/Lobby.java index 25e09f4..7fb87ac 100644 --- a/src/main/java/ch/unibas/dmi/dbis/cs108/sebaschi/Lobby.java +++ b/src/main/java/ch/unibas/dmi/dbis/cs108/sebaschi/Lobby.java @@ -1,6 +1,7 @@ package ch.unibas.dmi.dbis.cs108.sebaschi; import ch.unibas.dmi.dbis.cs108.BudaLogConfig; +import ch.unibas.dmi.dbis.cs108.multiplayer.helpers.Protocol; import ch.unibas.dmi.dbis.cs108.multiplayer.server.ClientHandler; import java.util.ArrayList; import java.util.List; @@ -72,7 +73,7 @@ public class Lobby { /** * Adds a player to the lobby. - * + * TODO: ad an appropriate response. Currently hardcoded. * @param player who wants to join the lobby. */ public void addPlayer(ClientHandler player) { @@ -82,7 +83,12 @@ public class Lobby { LOGGER.debug(player.getClientUserName() + " has been added to Lobby with ID: " + lobbyID + ". Current number of players in this lobby: " + players.size()); } else { - + LOGGER.debug( + player.getClientUserName() + " could not be added to lobby. No. of players in lobby: " + + numberOfPlayersInLobby); + //TODO: does this have to be formatted in any way to conform to protocol? + player.sendMsgToClient(Protocol.printToClientConsole + + "$The lobby is full. Please try joining a different lobby or create a new game"); } }