Class 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.
    See Also:
    CreateRoomSettings, SFSGameApi.createGame(com.smartfoxserver.v2.entities.Zone, CreateSFSGameSettings, User), Serialized Form
    • Constructor Detail

      • CreateSFSGameSettings

        public CreateSFSGameSettings()
    • Method Detail

      • 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 -