public class SFSGame extends SFSRoom
Each game can be configured to match specific types of Users by providing a User Match Expression. The expression contains criteria that
are checked against each User that wants to join the game and provides a mean for filtering players. The Match Expression can check any User Variable plus
a number of other properties exposed in the UserProperties
class.
Let's see an example: user Peter has two variables set.
CreateSFSGameSettings
Constructor and Description |
---|
SFSGame(java.lang.String name) |
Modifier and Type | Method and Description |
---|---|
void |
addUser(User user,
boolean asSpectator) |
int |
getMinPlayersToStartGame()
This is the minimum number of players that are required for the game to start
|
MatchExpression |
getPlayerMatchExpression()
Get the MatchExpression that is going to be checked against any Player joining this Room.
|
MatchExpression |
getSpectatorMatchExpression()
Get the MatchExpression that is going to be checked against any Spectator joining this Room.
|
boolean |
isGameStarted()
Checks if the minimum amount of players to start the game was reached.
|
boolean |
isGameStateChanged()
This is useful for server side events.
|
boolean |
isLeaveLastRoomOnJoin()
A Game can be configured so that when the Player has joined he auto-leaves the previous Room
|
boolean |
isNotifyGameStarted()
The SFSGame can notify the status of the Game (started/not started) via a reserved RoomVariable
|
void |
removeUser(User user) |
void |
setLeaveLastRoomOnJoin(boolean leaveLastRoomOnJoin) |
void |
setMinPlayersToStartGame(int min)
This is not modifiable at runtime.
|
void |
setNotifyGameStarted(boolean notifyGameStarted) |
void |
setPlayerMatchExpression(MatchExpression exp)
This is not modifiable at runtime.
|
void |
setSpectatorMatchExpression(MatchExpression spectatorMatchExpression)
This is not modifiable at runtime.
|
void |
switchPlayerToSpectator(User user) |
void |
switchSpectatorToPlayer(User user) |
java.lang.String |
toString() |
addUser, containsProperty, containsUser, containsUser, containsVariable, destroy, equals, getAdminHelper, getAutoRemoveMode, getCapacity, getDump, getExtension, getGroupId, getId, getLifeTime, getMaxRoomVariablesAllowed, getMaxSpectators, getMaxUsers, getName, getOwner, getPassword, getPlayerIdGeneratorClassName, getPlayersList, getProperties, getProperty, getRoomVariablesData, getSessionList, getSize, getSpectatorsList, getUserById, getUserByName, getUserByPlayerId, getUserBySession, getUserList, getUserListData, getUserManager, getVariable, getVariables, getVariablesCount, getVariablesCreatedByUser, getZone, isActive, isAllowOwnerInvitations, isDynamic, isEmpty, isFlagSet, isFull, isGame, isHidden, isPasswordProtected, isPublic, isUseWordsFilter, removeProperty, removeVariable, removeVariablesCreatedByUser, removeVariablesCreatedByUser, setActive, setAdminHelper, setAllowOwnerInvitations, setAutoRemoveMode, setCapacity, setDynamic, setExtension, setFlag, setFlags, setGame, setGame, setGroupId, setHidden, setMaxRoomVariablesAllowed, setMaxSpectators, setMaxUsers, setName, setOwner, setPassword, setProperties, setProperty, setUserManager, setUseWordsFilter, setVariable, setVariable, setVariables, setVariables, setZone, toSFSArray
public MatchExpression getPlayerMatchExpression()
MatchExpression
public int getMinPlayersToStartGame()
public void setPlayerMatchExpression(MatchExpression exp)
CreateSFSGameSettings
public MatchExpression getSpectatorMatchExpression()
MatchExpression
public void setSpectatorMatchExpression(MatchExpression spectatorMatchExpression)
CreateSFSGameSettings
public void setMinPlayersToStartGame(int min)
CreateSFSGameSettings
public boolean isLeaveLastRoomOnJoin()
public void setLeaveLastRoomOnJoin(boolean leaveLastRoomOnJoin)
public boolean isNotifyGameStarted()
ReservedRoomVariables.RV_GAME_STARTED
public void setNotifyGameStarted(boolean notifyGameStarted)
public boolean isGameStarted()
public boolean isGameStateChanged()
public void addUser(User user, boolean asSpectator) throws SFSJoinRoomException
SFSRoom
addUser
in interface Room
addUser
in class SFSRoom
SFSJoinRoomException
public void removeUser(User user)
SFSRoom
removeUser
in interface Room
removeUser
in class SFSRoom
public void switchPlayerToSpectator(User user) throws SFSRoomException
SFSRoom
switchPlayerToSpectator
in interface Room
switchPlayerToSpectator
in class SFSRoom
SFSRoomException
public void switchSpectatorToPlayer(User user) throws SFSRoomException
SFSRoom
switchSpectatorToPlayer
in interface Room
switchSpectatorToPlayer
in class SFSRoom
SFSRoomException