Class SFSGame

java.lang.Object
com.smartfoxserver.entities.SFSRoom
com.smartfoxserver.game.SFSGame
All Implemented Interfaces:
Room

public class SFSGame extends SFSRoom

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
Peter wants to jump into a game play, so he chooses an SFSGame and joins it.
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: