diff --git a/Server/src/main/java/uulm/teamname/marvelous/server/lobbymanager/LobbyConnection.java b/Server/src/main/java/uulm/teamname/marvelous/server/lobbymanager/LobbyConnection.java index eb235ae..5ac3885 100644 --- a/Server/src/main/java/uulm/teamname/marvelous/server/lobbymanager/LobbyConnection.java +++ b/Server/src/main/java/uulm/teamname/marvelous/server/lobbymanager/LobbyConnection.java @@ -20,7 +20,6 @@ import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; public class LobbyConnection implements Runnable { - public final String lobbyID; public final String gameID; public LobbyConnectionState state = LobbyConnectionState.Waiting; @@ -34,9 +33,8 @@ public class LobbyConnection implements Runnable { private Lobby lobby; /** Creates a new LobbyConnection */ - public LobbyConnection(String lobbyID) { - this.lobbyID = lobbyID; - this.gameID = UUID.randomUUID().toString(); + public LobbyConnection(String gameID) { + this.gameID = gameID; Tuple picked = Server.getCharacterConfig().getDisjointSetsOfPropertiesOfSize(12); this.options.put(ParticipantType.PlayerOne, picked.item1); @@ -81,6 +79,7 @@ public class LobbyConnection implements Runnable { } } + /** Returns the next free slot in the lobby as a {@link ParticipantType} */ public ParticipantType freeSlot() { if(player1 == null) { return ParticipantType.PlayerOne; @@ -91,6 +90,11 @@ public class LobbyConnection implements Runnable { } } + /** Returns whether there is a player slot available in the lobby */ + public boolean hasFreePlayerSlot() { + return player1 == null || player2 == null; + } + public Participant getPlayer1() { return player1; @@ -117,6 +121,7 @@ public class LobbyConnection implements Runnable { } } + /** Handles disconnect of a Participant. Hereby, the participant is made ready for reconnection */ public void handleDisconnect(Participant participant) { participant.disconnected = true; if(state == LobbyConnectionState.Started) { @@ -124,6 +129,7 @@ public class LobbyConnection implements Runnable { } } + /** Handles reconnect of a Participant. Hereby, the participant is made ready for reconnection */ public void handleReconnect(Participant participant) { participant.disconnected = false; if(state == LobbyConnectionState.Started) {