Package com.smartfoxserver.v2.game
Class CreateSFSGameSettings
- java.lang.Object
-
- com.smartfoxserver.v2.api.CreateRoomSettings
-
- com.smartfoxserver.v2.game.CreateSFSGameSettings
-
- All Implemented Interfaces:
java.io.Serializable
public class CreateSFSGameSettings extends CreateRoomSettings
This class provides all the settings required to create an SFSGame. The SFSGame object implements the Room interface and it's part of the SFS2X Game API which provide many advanced features such as Player matching, Game invitations, public and private Games, quick game joining etc...Overview
This is a quick overview of the settings that you can use to setup an SFSGame- isGamePublic: a public game can be joined by any Player whose variables match the SFSGame Player Match Expression. Private games are based on invitations sent by the Game creator.
- minPlayersToStartGame: the minimum number of players to start the game.
- invitedPlayers: (private games only) a list of players invited in the Game
- searchableRooms: (private games only) a list of Rooms where the Game API can search for more players to invite. The API will look for more players if the number of people invited is smaller than the minPlayersToStartGame. This way you can add your friends to the game and let the system find more players to start it.
- leaveLastJoinedRoom: auto-remove players from their previous Room after successful join
- playerMatchExpression: an expression to match players willing to play the game, by default no expression is used
- spectatorMatchExpression: an expression to match spectators willing to play the game, by default no expression is used
- invitationExpiryTime: the amount of time allowed for invited players to accept / refuse
- invitationParameters: optional custom invitation parameters.These could provide details about the inviter, the game, an invitation message etc...
- notifyGameStartedViaRoomVariable: automatically update a reserved Room Variable to signal that the game is started/stopped. The Room variable uses the global setting to be broadcast outside of the Room. This can be used on the client side to show the game state in your game list.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.smartfoxserver.v2.api.CreateRoomSettings
CreateRoomSettings.RoomExtensionSettings
-
-
Constructor Summary
Constructors Constructor Description CreateSFSGameSettings()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getInvitationExpiryTime()
The maximum amount of time for an invited Player to accept/refuse an invitation.ISFSObject
getInvitationParams()
Get optional SFSObject containing custom invitation parameters.java.util.List<User>
getInvitedPlayers()
For private games only: A list of players invited to play in the Game.int
getMinPlayersToStartGame()
Get the minimum number of players required to start the GameMatchExpression
getPlayerMatchExpression()
A match expression to filter Players willing to join the Game.java.util.List<Room>
getSearchableRooms()
A list of Rooms where to search for more players to invite in a private Game.
The players will be matched against the Player Match Expression providedMatchExpression
getSpectatorMatchExpression()
A match expression to filter Spectators willing to join the Game.boolean
isGamePublic()
Check if the Game is public.boolean
isLeaveLastJoinedRoom()
Check if the Player should be removed from its previous Room after he joins the Gameboolean
isNotifyGameStartedViaRoomVariable()
Turn on the notification of the Game state (started, not-started) by the way of a reserved global Room Variable.static CreateSFSGameSettings
newFromRoomSettings(CreateRoomSettings rSettings)
void
setGamePublic(boolean isGamePublic)
void
setInvitationExpiryTime(int invitationExpiryTime)
The maximum amount of time for an invited Player to accept/refuse an invitation.void
setInvitationParams(ISFSObject invitationParams)
Set the custom invitation parameters.void
setInvitedPlayers(java.util.List<User> invitedPlayers)
Set a list of people invited to play a private Gamevoid
setLeaveLastJoinedRoom(boolean leaveLastJoinedRoom)
void
setMinPlayersToStartGame(int minPlayersToStartGame)
void
setNotifyGameStartedViaRoomVariable(boolean notifyGameStartedWithRoomVariable)
void
setPlayerMatchExpression(MatchExpression playerMatchExpression)
A match expression to filter Players willing to join the Game.void
setSearchableRooms(java.util.List<Room> searchableRooms)
Provide a list of Rooms (e.g. all the Rooms from a specific Group in the Zone) that the system will use to search more players to join in a private Game.void
setSpectatorMatchExpression(MatchExpression spectatorMatchExpression)
A match expression to filter Spectators willing to join the Game.java.lang.String
toString()
-
Methods inherited from class com.smartfoxserver.v2.api.CreateRoomSettings
allowOwnerOnlyInvitation, getAutoRemoveMode, getCustomPlayerIdGeneratorClass, getExtension, getGroupId, getMaxSpectators, getMaxUsers, getMaxVariablesAllowed, getName, getPassword, getRoomProperties, getRoomSettings, getRoomVariables, isDynamic, isGame, isHidden, isSuppressUserList, isUseWordsFilter, setAllowOwnerOnlyInvitation, setAutoRemoveMode, setCustomPlayerIdGeneratorClass, setDynamic, setExtension, setGame, setGroupId, setHidden, setMaxSpectators, setMaxUsers, setMaxVariablesAllowed, setName, setPassword, setRoomProperties, setRoomSettings, setRoomVariables, setSuppressUserList, setUseWordsFilter
-
-
-
-
Method Detail
-
newFromRoomSettings
public static CreateSFSGameSettings newFromRoomSettings(CreateRoomSettings rSettings)
-
isGamePublic
public boolean isGamePublic()
Check if the Game is public.- Returns:
- true if the game is public
-
setGamePublic
public void setGamePublic(boolean isGamePublic)
-
getMinPlayersToStartGame
public int getMinPlayersToStartGame()
Get the minimum number of players required to start the Game- Returns:
- the minimum number of players required to start the Game
-
setMinPlayersToStartGame
public void setMinPlayersToStartGame(int minPlayersToStartGame)
-
getInvitedPlayers
public java.util.List<User> getInvitedPlayers()
For private games only: A list of players invited to play in the Game.- Returns:
- the list of invited players
-
setInvitedPlayers
public void setInvitedPlayers(java.util.List<User> invitedPlayers)
Set a list of people invited to play a private Game- Parameters:
invitedPlayers
- the list of invited players
-
getSearchableRooms
public java.util.List<Room> getSearchableRooms()
A list of Rooms where to search for more players to invite in a private Game.
The players will be matched against the Player Match Expression provided- Returns:
- the list of Rooms where to search more players
- See Also:
getPlayerMatchExpression()
-
setSearchableRooms
public void setSearchableRooms(java.util.List<Room> searchableRooms)
Provide a list of Rooms (e.g. all the Rooms from a specific Group in the Zone) that the system will use to search more players to join in a private Game. The players will be matched against the Player Match Expression provided- Parameters:
searchableRooms
- the list of Rooms
-
isLeaveLastJoinedRoom
public boolean isLeaveLastJoinedRoom()
Check if the Player should be removed from its previous Room after he joins the Game- Returns:
- true if the Player should be removed from its previous Room after he joins the Game
-
setLeaveLastJoinedRoom
public void setLeaveLastJoinedRoom(boolean leaveLastJoinedRoom)
-
getPlayerMatchExpression
public MatchExpression getPlayerMatchExpression()
A match expression to filter Players willing to join the Game.- Public Games: The user properties will be checked against the expression and if it's a match they will be allowed to join.
- Private Games: The above applies for private Games provided that the player was invited in the Game by the Game owner.
- Returns:
- the match expression
- See Also:
MatchExpression
-
setPlayerMatchExpression
public void setPlayerMatchExpression(MatchExpression playerMatchExpression)
A match expression to filter Players willing to join the Game.- Public Games: The user properties will be checked against the expression and if it's a match they will be allowed to join.
- Private Games: The above applies for private Games provided that the player was invited in the Game by the Game owner.
- Parameters:
playerMatchExpression
- the match expression- See Also:
MatchExpression
-
getSpectatorMatchExpression
public MatchExpression getSpectatorMatchExpression()
A match expression to filter Spectators willing to join the Game.- Returns:
- the match expression
- See Also:
MatchExpression
-
setSpectatorMatchExpression
public void setSpectatorMatchExpression(MatchExpression spectatorMatchExpression)
A match expression to filter Spectators willing to join the Game.- Parameters:
spectatorMatchExpression
- the match expression- See Also:
MatchExpression
-
getInvitationExpiryTime
public int getInvitationExpiryTime()
The maximum amount of time for an invited Player to accept/refuse an invitation. The invitation will be auto-refused after the time has expired.- Returns:
- the expiration time, expressed in seconds
- See Also:
SFSInvitation
-
setInvitationExpiryTime
public void setInvitationExpiryTime(int invitationExpiryTime)
The maximum amount of time for an invited Player to accept/refuse an invitation. The invitation will be auto-refused after the time has expired.- Parameters:
invitationExpiryTime
- the expiration time, expressed in seconds- See Also:
SFSInvitation
-
isNotifyGameStartedViaRoomVariable
public boolean isNotifyGameStartedViaRoomVariable()
Turn on the notification of the Game state (started, not-started) by the way of a reserved global Room Variable.- Returns:
- true if the notification is active
- See Also:
ReservedRoomVariables.RV_GAME_STARTED
-
setNotifyGameStartedViaRoomVariable
public void setNotifyGameStartedViaRoomVariable(boolean notifyGameStartedWithRoomVariable)
-
getInvitationParams
public ISFSObject getInvitationParams()
Get optional SFSObject containing custom invitation parameters.- Returns:
- the optional invitation parameters
-
setInvitationParams
public void setInvitationParams(ISFSObject invitationParams)
Set the custom invitation parameters. The parameters could provide details about the inviter, the game, an invitation message etc...- Parameters:
invitationParams
-
-
toString
public java.lang.String toString()
- Overrides:
toString
in classCreateRoomSettings
-
-