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 419b18d..f98e664 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 @@ -9,6 +9,9 @@ import java.util.List; */ public class Lobby { + private static final int MAX_NO_OF_CLIENTS = 6; + private static int lobbies; + /** * The Person who created the game and can configure it and decide to start once enough players * have entered the lobby. @@ -18,23 +21,29 @@ public class Lobby { /** * Everyone who's in the lobby. */ - private List players = new ArrayList<>(); - - private static final int MAX_NO_OF_CLIENTS = 6; - + private List players = new ArrayList<>(6); + private int numberOfPlayersInLobby; + private final int lobbyID = lobbies++; + static { + lobbies = 0; + } /** - * The admin has to be set in the constructor. The admin is final. - * Every Lobby needs and admin, so no other constructors are needed. + * Constructor. Sets the admin to who created the lobby. Adds the admin to the list of players. + * Increases the number of players from 0 to 1. + * * @param admin the Client who called CRTGM */ public Lobby(ClientHandler admin) { this.admin = admin; + this.players.add(admin); + this.numberOfPlayersInLobby = 1; + lobbies++; } /** @@ -48,6 +57,7 @@ public class Lobby { /** * Adds a player to the lobby. + * * @param player who wants to join the lobby. */ public void addPlayer(ClientHandler player) {