Class AbstractRoom


  • public abstract class AbstractRoom
    extends java.lang.Object
    A room or simpler is a group of related players, see AbstractPlayer. These players can be played in the same game or in the same location. This class is only for logic handling. You can manage a list of players in a room as well as hold the players' common data for sharing. For simple handling, one room can hold a number of players, but one player only appears in one room at a time. The player can be a free one and no need to join any rooms, there, it is only under the PlayerManager class' management.
    Author:
    kong
    • Constructor Detail

      • AbstractRoom

        public AbstractRoom​(java.lang.String id,
                            java.lang.String name,
                            int capacity)
    • Method Detail

      • contain

        public boolean contain​(java.lang.String playerName)
      • add

        public void add​(AbstractPlayer player)
        Add a player to this room, this action was handled by system logic. Be careful when handling it yourself. You are warned!
        Parameters:
        player - the player (AbstractPlayer) who wants to join this room
      • remove

        public void remove​(AbstractPlayer player)
        Remove a player from this room, this action was handled by system logic. Be careful when handling it yourself. You are warned!
        Parameters:
        player - the player (AbstractPlayer) who wants to leave or be forced to leave this room
      • clear

        public void clear()
        Remove all players from this room
      • isState

        public boolean isState​(int state)
      • getState

        public int getState()
      • setState

        public void setState​(int state)
      • getCapacity

        public int getCapacity()
      • setCapacity

        public void setCapacity​(int capacity)
      • getId

        public java.lang.String getId()
      • getName

        public java.lang.String getName()
      • setName

        public void setName​(java.lang.String name)
      • count

        public int count()
        Returns:
        the number of players in this room
      • getPlayers

        public java.util.Map<java.lang.String,​AbstractPlayer> getPlayers()
      • isFull

        public boolean isFull()
        Returns:
        true if this room is full, false otherwise
      • isEmpty

        public boolean isEmpty()
      • setPlayersState

        public void setPlayersState​(int state)
        Set a new state for all players in this room
        Parameters:
        state - the desired state