Package com.smartfoxserver.game
Class SFSGame
java.lang.Object
com.smartfoxserver.entities.SFSRoom
com.smartfoxserver.game.SFSGame
- All Implemented Interfaces:
Room
Introduction
The SFSGame class is part of the SFS Game API which offers advanced tools for setting up matches, invite and challenge Users, quick jump into a game, etc... An SFSGame extends the normal capabilities of a Room making it possible to set a Game as public or private and to provide a list of invitations that the will be sent to other players to join the Game.
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.
- Rank: 10
- BestScore: 25000
Unfortunately the SFSGame expression is set as follows: (Rank > 10) OR (BestScore > 30000)
Any attempt to join a Game will be refused if the player doesn't match the Room's criteria.
Public SFSGame
A public game can be joined by any Player whose variables match the SFSGame User Match Expression.Private SFSGame
A private game will only be accessible to invited players. The list of invited users is passed to the API at the creation of the Game. It is also possible to let the server find more players to invite automatically, if necessary.Game State
The SFSGame object can also automatically notify the game state (started / not started) via a reserved RoomVariable. The variable is set to global so it can be notified to all Users in the Zone.- See Also:
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidintThis is the minimum number of players that are required for the game to startGet the MatchExpression that is going to be checked against any Player joining this Room.
By default this is null and no matching is performed.Get the MatchExpression that is going to be checked against any Spectator joining this Room.
By default this is null and no matching is performed.booleanChecks if the minimum amount of players to start the game was reached.booleanbooleanbooleanvoidremoveUser(User user) voidsetLeaveLastRoomOnJoin(boolean leaveLastRoomOnJoin) voidsetMinPlayersToStartGame(int min) voidsetNotifyGameStarted(boolean notifyGameStarted) voidvoidsetSpectatorMatchExpression(MatchExpression spectatorMatchExpression) voidswitchPlayerToSpectator(User user) voidswitchSpectatorToPlayer(User user) toString()Methods inherited from class com.smartfoxserver.entities.SFSRoom
addUser, banUser, containsProperty, containsUser, containsUser, containsVariable, destroy, enableAudioManager, equals, getAdminHelper, getAudioManager, getAutoRemoveMode, getBannedUserIds, getCapacity, getDump, getExtension, getGroupId, getId, getLifeTime, getMaxRoomVariablesAllowed, getMaxSpectators, getMaxUsers, getName, getOwner, getOwnerName, getPassword, getPlayerIdGeneratorClassName, getPlayersList, getProperties, getProperty, getRoomVariablesData, getSessionList, getSize, getSpectatorsList, getUserById, getUserByName, getUserByPlayerId, getUserBySession, getUserList, getUserListData, getUserManager, getVariable, getVariables, getVariablesCount, getVariablesCreatedByUser, getZone, isActive, isAllowOwnerInvitations, isAudioStreamingAllowed, isDynamic, isEmpty, isFlagSet, isFull, isGame, isHidden, isJoinAllowed, isOwnedBy, isPasswordProtected, isPublic, isSuppressUserList, 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, setSuppressUserList, setUserManager, setUseWordsFilter, setVariable, setVariable, setVariables, setVariables, setZone, toSFSArray, unbanUser
-
Constructor Details
-
SFSGame
-
-
Method Details
-
getPlayerMatchExpression
Get the MatchExpression that is going to be checked against any Player joining this Room.
By default this is null and no matching is performed.- Returns:
- the MatchExpression
- See Also:
-
getMinPlayersToStartGame
public int getMinPlayersToStartGame()This is the minimum number of players that are required for the game to start- Returns:
- the amoung of players required to start the game
-
setPlayerMatchExpression
- Internal
-
getSpectatorMatchExpression
Get the MatchExpression that is going to be checked against any Spectator joining this Room.
By default this is null and no matching is performed.- Returns:
- the MatchExpression
- See Also:
-
setSpectatorMatchExpression
- Internal
-
setMinPlayersToStartGame
public void setMinPlayersToStartGame(int min) - Internal
-
isLeaveLastRoomOnJoin
public boolean isLeaveLastRoomOnJoin()- Internal
-
setLeaveLastRoomOnJoin
public void setLeaveLastRoomOnJoin(boolean leaveLastRoomOnJoin) - Internal
-
isNotifyGameStarted
public boolean isNotifyGameStarted()- Internal
-
setNotifyGameStarted
public void setNotifyGameStarted(boolean notifyGameStarted) - Internal
-
isGameStarted
public boolean isGameStarted()Checks if the minimum amount of players to start the game was reached.- Returns:
- true, if the minimum amount of players to start the game was reached
-
isGameStateChanged
public boolean isGameStateChanged()- Internal
-
addUser
Description copied from class:SFSRoom- Specified by:
addUserin interfaceRoom- Overrides:
addUserin classSFSRoom- Throws:
SFSJoinRoomException- Internal
- Instead use
SFSApi.joinRoom(User, com.smartfoxserver.entities.Room)
-
removeUser
Description copied from class:SFSRoom- Specified by:
removeUserin interfaceRoom- Overrides:
removeUserin classSFSRoom- Internal
- Instead use
SFSApi.leaveRoom(User, com.smartfoxserver.entities.Room)
-
toString
-
switchPlayerToSpectator
Description copied from class:SFSRoom- Specified by:
switchPlayerToSpectatorin interfaceRoom- Overrides:
switchPlayerToSpectatorin classSFSRoom- Throws:
SFSRoomException- Internal
- Instead use
SFSApi.playerToSpectator(User, com.smartfoxserver.entities.Room, boolean, boolean)
-
switchSpectatorToPlayer
Description copied from class:SFSRoom- Specified by:
switchSpectatorToPlayerin interfaceRoom- Overrides:
switchSpectatorToPlayerin classSFSRoom- Throws:
SFSRoomException- Internal
- Instead use
SFSApi.spectatorToPlayer(User, com.smartfoxserver.entities.Room, boolean, boolean)
-