SmartFoxServer 2X C++ API
Sfs2X::Requests::Game::CreateSFSGameRequest Class Reference

The request launches a new public or private game, including game invitations, player matching and a lot more. More...

#include <CreateSFSGameRequest.h>

Inherits Sfs2X::Requests::BaseRequest.

Public Member Functions

 CreateSFSGameRequest (boost::shared_ptr< SFSGameSettings > settings)
 Constructor More...
 

Detailed Description

The request launches a new public or private game, including game invitations, player matching and a lot more.

The game is launched via the creation of an SFSGame, a specialized Room type that provides advanced features during the creation phase of a game.

A more in-depth overview of the SFS2X Game API is provided in the general documentation

See also
SFSGameSettings

Constructor & Destructor Documentation

◆ CreateSFSGameRequest()

Sfs2X::Requests::Game::CreateSFSGameRequest::CreateSFSGameRequest ( boost::shared_ptr< SFSGameSettings settings)

Constructor

Parameters
settingsthe game Room settings
// Prepare the settings for a public game
boost::shared_ptr<vector<boost::shared_ptr<RoomVariable>>> collectionRoomVariables (new vector<boost::shared_ptr<RoomVariable>>());
boost::shared_ptr<RoomVariable> variable (new SFSRoomVariable("desc", boost::shared_ptr<string>(new string("Darts game, public, bestScore > 100")), VARIABLETYPE_STRING));
collectionRoomVariables->push_back(variable);
boost::shared_ptr<SFSGameSettings> settings (new SFSGameSettings("DartsGame"));
settings->MaxUsers(2);
settings->MaxSpectators(8);
settings->IsPublic(true);
settings->MinPlayersToStartGame(2);
settings->NotifyGameStarted(true);
settings->Variables(collectionRoomVariables);
// The Match expression for filtering users joining the Room
boost::shared_ptr<long int> value (new long int());
*value = 100;
boost::shared_ptr<MatchExpression> expression (new MatchExpression("bestScore", NumberMatch::GREATER_THAN, value, MatchExpression::MatchExpressionValueType::MatchExpression_ValueOther));
settings->PlayerMatchExpression(expression);
boost::shared_ptr<IRequest> request (new CreateSFSGameRequest(settings));
ptrSmartFox->Send(request);
See also
SFSGameSettings, Entities.Match.MatchExpression, Entities.Invitation.SFSInvitation, Core.SFSEvent.ROOM_ADD, Core.SFSEvent.ROOM_CREATION_ERROR