MatchMaking
The MatchMaking Service is used for locating players to play against when using our Async or One-Way multiplayer features.
A player must be enabled via the EnableMatchMaking method call in order to participate in a match. This is so that you may exclude players from matchmaking while they are in an introductory tutorial for your game.
To use the matchMaking service matchMaking must be enabled from your app on the Multiplayer - MatchMaking page of the brainCloud portal.
The starting Player Rating is also set on this page.
API Summary
MatchMaking
- EnableMatchMaking - Enables match making for player.
- DisableMatchMaking - Disables match making for player.
- Read - Read player match making data.
Finding Matches
- FindPlayers - Finds one or more match candidates.
- FindPlayersWithAttributes - Finds one or more match candidates.
- FindPlayersUsingFilter - Finds one or more match candidates with script filter.
- FindPlayersUsingScript - Finds one or more match candidates with provided script filter and player rating override.
- FindPlayersWithAttributesUsingFilter - Finds one or more match candidates with script filter.
- FindPlayersWithAttributesUsingScript - Finds one or more match candidates with provided script filter and player rating override.
MatchMaking Filters
Players found via matching can be filtered, to ensure players only get matched with certain other players.
Writing and Configuring the Filter
public exampleMatchMakingFilter( data )
{
// This method examines the proposed player, and
// returns true if the match is acceptable.
// For purposes of this demo, we will only accept players
// whose name matches the name provided.
var result = false;
var matchName = data.extraParms.matchPlayerName;
var candidateName = data.matchCandidate.playerName;
if (matchName == candidateName) {
result = true;
}
result;
}
Example filter script parameters
{
"extraParms": {
"matchPlayerName": "Romundo"
},
"matchCandidate": {
"pictureUrl": null,
"playerName": "Romundo",
"playerId": "<profile id>",
"playerRating": 100,
"summaryFriendData": null
}
}
The filter logic must be written in a Cloud Code script, and configured for usage via the Design | Multiplayer | MatchMaking portal page.
The filter script will be invoked individually for each potential candidate. The script will be passed two parameters:
Method Parameters
Parameter | Description |
---|---|
matchCandidate | Information about the candidate being considered |
extraParms | Additional parameters that were passed into the original matchMaking request |
The matchCandidate parameter contains all the same data that is ultimately returned in the FindPlayersUsingFilter()
call for each match candidate.
The script should return true
to allow the candidate to match, or false
to reject it.
Filter vs. Attributes
A new parameter, attributes
, can be added to these calls - that can be optionally used to pre-filter candidates before they are passed to the cloud code filter for evaluation.
As you'd expect, this causes the matchMaking service to examine the attributes
associated with a candidate, and only consider candidates that match the specified attribute values for further consideration.
This facility should be used with caution, as attributes are not indexed for this purpose, and can slow down matchMaking performance. This feature is therefore mean only for cases where the conditions being sought are so rare, that we might need to evaluate thousands of candidates without finding one that satisfies the prescribed conditions (which would be very inefficient to do one-by-one via a filter).
A typical usage of this capability is when looking for cheaters. If you system attempts to match cheaters with cheaters, it would be wise to add this attribute only for those cases when the current player is a cheater, and thus filter the results to only other cheaters. (Since hopefully only a very small portion of your user population will be cheaters.)
Player attributes can optionally be viewed on the dashboard on the Monitoring | User Monitoring | Attributes page.
Player Rating
- SetPlayerRating - Sets player match rating.
- IncrementPlayerRating - Increments player match rating.
- DecrementPlayerRating - Decrements player match rating.
- ResetPlayerRating - Resets player match rating.
Multiplayer Protection
- TurnShieldOff - Turns player shield off.
- TurnShieldOn - Turns player shield on.
- TurnShieldOnFor - Turns player shield on for specified minutes.
- GetShieldExpiry - Retrieves shield expiry time.
- IncrementShieldOnFor - Increment shield on for 'X' minutes.
📄️ DecrementPlayerRating
Decrements player rating.
📄️ DisableMatchMaking
Disables match making for the player.
📄️ EnableMatchMaking
Enables match making for the player.
📄️ FindPlayers
Finds matchmaking enabled players.
📄️ FindPlayersUsingFilter
Finds matchmaking enabled players using a cloud code filter.
📄️ FindPlayersUsingScript
Finds matchmaking enabled players using optionally specified filter script and optional player rating override.
📄️ FindPlayersWithAttributes
Finds matchmaking enabled players with additional attributes
📄️ FindPlayersWithAttributesUsingFilter
Finds matchmaking enabled players using a cloud code filter and additional attributes.
📄️ FindPlayersWithAttributesUsingScript
Finds matchmaking enabled players using optionally specified filter script, optional player rating override and additional attributes.
📄️ GetShieldExpiry
Gets the shield expiry for the given player id. Passing in a null player id will return the shield expiry for the current player. The value returned is the time in UTC millis when the shield will expire.
📄️ IncrementPlayerRating
Increments player rating.
📄️ IncrementShieldOnFor
Increments shield on for the specified number of minutes.
📄️ Read
Read matchmaking record.
📄️ ResetPlayerRating
Resets player rating.
📄️ SetPlayerRating
Sets player rating.
📄️ TurnShieldOff
Turns shield off.
📄️ TurnShieldOn
Turns shield on.
📄️ TurnShieldOnFor
Turns shield on for the specified number of minutes.