Class Lobby


  • public class Lobby
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      Lobby​(java.lang.String name, Server server)
      Constructor of the Lobby
    • Constructor Detail

      • Lobby

        public Lobby​(java.lang.String name,
                     Server server)
        Constructor of the Lobby
        Parameters:
        name - name of the lobby
        server - server the lobby is connected to
    • Method Detail

      • getName

        public java.lang.String getName()
        getter for the name of the lobby
        Returns:
        name of the lobby
      • getState

        public LobbyState getState()
        "getter" for the state of the lobby
        Returns:
        state of the lobby
      • setState

        public void setState​(LobbyState state)
        "setter" for the state of the lobby
        Parameters:
        state - lobby status
      • hasPlayer

        public boolean hasPlayer​(java.lang.String playerName)
        method to check if the lobby contains player
        Parameters:
        playerName - nickname of the player
        Returns:
        true if there are players in the lobby, else (if lobby is empty) false
      • addPlayer

        public boolean addPlayer​(ServerThread thread)
        method to add a player to the lobby
        Parameters:
        thread - thread of the server
        Returns:
        true if player was added (if players in lobby are less than 4), else (if there are or more players in a lobby) false
      • removePlayer

        public void removePlayer​(ServerThread thread)
        method to remove a player from the server
        Parameters:
        thread - thread of the server
      • handleMessage

        public void handleMessage​(IMessage gameMsg,
                                  ServerThread thread)
        handles messages of the game
        Parameters:
        gameMsg - message of the game
        thread - thread of the server
      • handleChangeDir

        public void handleChangeDir​(java.lang.String changeDirMsg,
                                    ServerThread thread)
        handles the changing of each players moving direction
        Parameters:
        changeDirMsg - message with the informations about the direction
        thread - the thread of the server
      • getPlayers

        public java.util.ArrayList<Player> getPlayers()
        "getter" of the players
        Returns:
        all players
      • getServerTicks

        public void getServerTicks()
        messure of the server ticks in milli seconds, counts them to be able to analyse them