Package com.tenio.entity
Class AbstractRoom
- java.lang.Object
-
- com.tenio.entity.AbstractRoom
-
public abstract class AbstractRoom extends java.lang.Object
A room or simpler is a group of related players, seeAbstractPlayer
. 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 thePlayerManager
class' management.- Author:
- kong
-
-
Constructor Summary
Constructors Constructor Description AbstractRoom(java.lang.String id, java.lang.String name, int capacity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(AbstractPlayer player)
Add a player to this room, this action was handled by system logic.void
clear()
Remove all players from this roomboolean
contain(java.lang.String playerName)
int
count()
int
getCapacity()
AbstractPlayer
getFirstPlayer()
java.lang.String
getId()
java.lang.String
getName()
java.util.Map<java.lang.String,AbstractPlayer>
getPlayers()
int
getState()
boolean
isEmpty()
boolean
isFull()
boolean
isState(int state)
void
remove(AbstractPlayer player)
Remove a player from this room, this action was handled by system logic.void
setCapacity(int capacity)
void
setName(java.lang.String name)
void
setPlayersState(int state)
Set a new state for all players in this roomvoid
setState(int state)
-
-
-
Method Detail
-
contain
public boolean contain(java.lang.String playerName)
-
getFirstPlayer
public AbstractPlayer getFirstPlayer()
-
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
-
-