Added final field MAX_NO_OF_CLIENTS used to not overfill the lobby.

This commit is contained in:
sebaschi 2022-04-08 12:23:51 +02:00
parent 90f844ce6b
commit 052a207822

View File

@ -1,6 +1,7 @@
package ch.unibas.dmi.dbis.cs108.sebaschi;
import ch.unibas.dmi.dbis.cs108.multiplayer.server.ClientHandler;
import java.util.ArrayList;
import java.util.List;
/**
@ -12,11 +13,45 @@ public class Lobby {
* The Person who created the game and can configure it and decide to start once enough players
* have entered the lobby.
*/
private ClientHandler admin;
private final ClientHandler admin;
/**
* Everyone who's in the lobby.
*/
private List<ClientHandler> players;
private List<ClientHandler> players = new ArrayList<>();
private static final int MAX_NO_OF_CLIENTS = 6;
/**
* The admin has to be set in the constructor. The admin is final.
* Every Lobby needs and admin, so no other constructors are needed.
* @param admin the Client who called CRTGM
*/
public Lobby(ClientHandler admin) {
this.admin = admin;
}
/**
* Getter
*
* @return the admin of the lobby.
*/
public ClientHandler getAdmin() {
return this.admin;
}
/**
* Adds a player to the lobby.
* @param player who wants to join the lobby.
*/
public void addPlayer(ClientHandler player) {
players.add(player);
}
}