CotC C# SDK for Unity  v1.4.0.1
Making social games is easy !
Properties | Public Member Functions | List of all members

Description

Represents a match with which you can interact through high level functionality. A match object is returned when you create a match, join it and so on. You should subscribe to ReceivedEvent right after you got this object.

Properties

GamerInfo Creator [get]
 Describes the creator of the match. More...
 
Bundle CustomProperties [get]
 Custom properties, as passed at the creation of the match. More...
 
string Domain [get]
 The domain to which the match belongs (default is private). More...
 
string Description [get]
 Description of the match, as defined by the user upon creation. More...
 
Gamer Gamer [get]
 Parent gamer object. More...
 
Bundle GlobalState [get]
 The global state of the game, which may be modified using a move. More...
 
bool IsCreator [get]
 
string LastEventId [get]
 The ID of the last event happened during this game; keep this for later, you might need it for some calls. More...
 
string MatchId [get]
 The ID of the match. Keep this for later as it is useful to continue a match. More...
 
int MaxPlayers [get]
 Maximum number of players, as passed. More...
 
List< MatchMoveMoves [get]
 List of existing events, which may be used to reproduce the state of the game. More...
 
Action< Match, MatchFinishEventOnMatchFinished
 Event raised when the match is marked as finished. As with most match events, this event is delivered to all users currently participating to the match except the user who initiated it (that is, oneself). More...
 
Action< Match, MatchJoinEventOnPlayerJoined
 Event raised when a player joins the match (excluding us obviously). More...
 
Action< Match, MatchLeaveEventOnPlayerLeft
 Event raised when a player leaves the match (excluding us obviously). More...
 
Action< Match, MatchMoveEventOnMovePosted
 Event raised when a move is posted by any player except us in the match. More...
 
Action< Match, MatchShoeDrawnEventOnShoeDrawn
 Event raised when an element is drawn from the shoe. More...
 
List< GamerInfoPlayers [get]
 IDs of players participating to the match, including the creator (which is reported alone there at creation). More...
 
int Seed [get]
 A random seed that can be used to ensure consistent state across players of the game. This is a 31 bit number. More...
 
MatchStatus Status [get]
 The current state of the match (running, finished). More...
 
Bundle Shoe [get]
 An array of objects that are shuffled when the match starts. You can put anything you want inside and use it as values for your next game. This field is only returned when finishing a match. More...
 
- Properties inherited from CotcSdk.PropertiesObject
Bundle this[string key] [get]
 Allows to query additional properties via an indexer (can be enriched via hooks). More...
 

Public Member Functions

void DiscardEventHandlers ()
 Clears all event handlers subscribed, ensuring that a match object can be dismissed without causing further actions in the background. More...
 
Promise< DrawnItemsResultDrawFromShoe (int count=1, PushNotification notification=null)
 Draws an item from the shoe. More...
 
Promise< DoneFinish (bool deleteToo=false, PushNotification notification=null)
 Terminates the match. You need to be the creator of the match to perform this operation. More...
 
Promise< DoneInvitePlayer (string playerId, PushNotification notification=null)
 Allows to invite a player to join a match. You need to be part of the match to send an invitation. This can be used to invite an opponent to a match that is not shown publicly. More...
 
Promise< DoneLeave (PushNotification notification=null)
 Leaves the match. More...
 
void Lock (Action block)
 Protects the match against concurrent modification. Please look at the tutorial for more information on this subject. Basically, you should use it to protect your game state from race conditions. More...
 
Promise< DonePostMove (Bundle moveData, Bundle updatedGameState=null, PushNotification notification=null)
 Posts a move to other players. More...
 
- Public Member Functions inherited from CotcSdk.PropertiesObject
Bundle AsBundle ()
 Gets the underlying Bundle. Dangerous, only use internally, when you want to put the contents of a properties object into an existing bundle. More...
 
Dictionary< string, Bundle >.KeyCollection Keys ()
 Allows to browse all keys (might include some that are already exposed as typed properties in the object). More...
 
Dictionary< string, Bundle >.Enumerator GetEnumerator ()
 Allows to browse all keys (might include some that are already exposed as typed properties in the object). More...
 
override string ToString ()
 You may use this to debug what is inside this property object. More...
 
string ToJson ()
 Builds a JSON representation of this object, same as ToString actually. More...
 

Additional Inherited Members

- Protected Member Functions inherited from CotcSdk.PropertiesObject
 PropertiesObject (Bundle baseData)
 
- Protected Attributes inherited from CotcSdk.PropertiesObject
Bundle Props
 
Inheritance diagram for CotcSdk.Match:
CotcSdk.PropertiesObject

Property Documentation

◆ Creator

GamerInfo CotcSdk.Match.Creator
get

Describes the creator of the match.

◆ CustomProperties

Bundle CotcSdk.Match.CustomProperties
get

Custom properties, as passed at the creation of the match.

◆ Description

string CotcSdk.Match.Description
get

Description of the match, as defined by the user upon creation.

◆ Domain

string CotcSdk.Match.Domain
get

The domain to which the match belongs (default is private).

◆ Gamer

Gamer CotcSdk.Match.Gamer
get

Parent gamer object.

◆ GlobalState

Bundle CotcSdk.Match.GlobalState
get

The global state of the game, which may be modified using a move.

◆ IsCreator

bool CotcSdk.Match.IsCreator
get

Returns
Whether you are the creator of the match, and as such have special privileges (like the ability to finish and delete a match).

◆ LastEventId

string CotcSdk.Match.LastEventId
get

The ID of the last event happened during this game; keep this for later, you might need it for some calls.

◆ MatchId

string CotcSdk.Match.MatchId
get

The ID of the match. Keep this for later as it is useful to continue a match.

◆ MaxPlayers

int CotcSdk.Match.MaxPlayers
get

Maximum number of players, as passed.

◆ Moves

List<MatchMove> CotcSdk.Match.Moves
get

List of existing events, which may be used to reproduce the state of the game.

◆ OnMatchFinished

Action<Match, MatchFinishEvent> CotcSdk.Match.OnMatchFinished
addremove

Event raised when the match is marked as finished. As with most match events, this event is delivered to all users currently participating to the match except the user who initiated it (that is, oneself).

◆ OnMovePosted

Action<Match, MatchMoveEvent> CotcSdk.Match.OnMovePosted
addremove

Event raised when a move is posted by any player except us in the match.

◆ OnPlayerJoined

Action<Match, MatchJoinEvent> CotcSdk.Match.OnPlayerJoined
addremove

Event raised when a player joins the match (excluding us obviously).

◆ OnPlayerLeft

Action<Match, MatchLeaveEvent> CotcSdk.Match.OnPlayerLeft
addremove

Event raised when a player leaves the match (excluding us obviously).

◆ OnShoeDrawn

Action<Match, MatchShoeDrawnEvent> CotcSdk.Match.OnShoeDrawn
addremove

Event raised when an element is drawn from the shoe.

◆ Players

List<GamerInfo> CotcSdk.Match.Players
get

IDs of players participating to the match, including the creator (which is reported alone there at creation).

◆ Seed

int CotcSdk.Match.Seed
get

A random seed that can be used to ensure consistent state across players of the game. This is a 31 bit number.

◆ Shoe

Bundle CotcSdk.Match.Shoe
get

An array of objects that are shuffled when the match starts. You can put anything you want inside and use it as values for your next game. This field is only returned when finishing a match.

◆ Status

MatchStatus CotcSdk.Match.Status
get

The current state of the match (running, finished).

Member Function Documentation

◆ DiscardEventHandlers()

void CotcSdk.Match.DiscardEventHandlers ( )

Clears all event handlers subscribed, ensuring that a match object can be dismissed without causing further actions in the background.

◆ DrawFromShoe()

Promise<DrawnItemsResult> CotcSdk.Match.DrawFromShoe ( int  count = 1,
PushNotification  notification = null 
)

Draws an item from the shoe.

Returns
Promise resolved when the operation has completed. The attached bundle contains an array of items drawn from the shoe. You may do (int)result.Value[0] to fetch the first value as integer.
Parameters
countThe number of items to draw from the shoe.
notificationA notification that can be sent to all players currently playing the match (except you).

◆ Finish()

Promise<Done> CotcSdk.Match.Finish ( bool  deleteToo = false,
PushNotification  notification = null 
)

Terminates the match. You need to be the creator of the match to perform this operation.

Returns
Promise resolved when the operation has completed.
Parameters
deleteTooIf true, deletes the match if it finishes successfully or is already finished.
notificationA notification that can be sent to all players currently playing the match (except you).

◆ InvitePlayer()

Promise<Done> CotcSdk.Match.InvitePlayer ( string  playerId,
PushNotification  notification = null 
)

Allows to invite a player to join a match. You need to be part of the match to send an invitation. This can be used to invite an opponent to a match that is not shown publicly.

Returns
Promise resolved when the operation has completed.
Parameters
playerIdID of the player to invite to the match. Player IDs can be found in the properties of the match (GamerInfo.GamerId).
notificationA push notification that can be sent to the invitee.

◆ Leave()

Promise<Done> CotcSdk.Match.Leave ( PushNotification  notification = null)

Leaves the match.

Returns
Promise resolved when the operation has completed.
Parameters
notificationA push notification that can be sent to all players except you.

◆ Lock()

void CotcSdk.Match.Lock ( Action  block)

Protects the match against concurrent modification. Please look at the tutorial for more information on this subject. Basically, you should use it to protect your game state from race conditions.

◆ PostMove()

Promise<Done> CotcSdk.Match.PostMove ( Bundle  moveData,
Bundle  updatedGameState = null,
PushNotification  notification = null 
)

Posts a move to other players.

Returns
Promise resolved when the operation has completed.
Parameters
moveDataA freeform object indicating the move data to be posted and transfered to other players. This move data will be kept in the events, and new players should be able to use it to reproduce the local game state.
updatedGameStateA freeform object replacing the global game state, to be used by players who join from now on. Passing a non null value clears the pending events in the match.
notificationA push notification that can be sent to all players except you.