Skip to main content
Version: 5.7.0

ProcessStatistics

Apply a set of operations to the specified statistics. User (player) Statistics are defined through the brainCloud portal.

The operations available are much richer than the standard increment operation available via IncrementUserStats().

For example:

{
"INNING": "INC#1", // Increment by one
"INNINGSREM": "DEC#1", // Decrement by one
"OUTS": "RESET", // Reset to the defined initial value
"POINTS": "INC_TO_LIMIT#5#30", // Increment by 5, but to a max of 30
"PLAYERS": "SET#8", // Set to the specified value
"HIGHESTHR": "MAX#3", // Set to the specified value if larger
"ESTIMATE": "MIN#5", // Set to the specified value if smaller
"GAME" : "5" // Missing stat grammar will treat the operation as an increment
}

The above example would:

  • Increment INNING by 1
  • Decrement INNINGSREM by 1
  • Reset OUTS to its pre-defined initial value
  • Increment POINTS by 5, but to a maximum of 30
  • Set PLAYERS to 8
  • Set HIGHESTHR to 3, or remain at current higher value
  • Set ESTIMATE to 5, or remain at current lower value
  • Increment GAME by 5

For the full statistics grammar see the statistics grammar section.

ServiceOperation
playerStatisticsPROCESS_STATISTICS

Method Parameters

ParameterDescription
statisticsThe stats data to be passed to the method

Usage

http://localhost:3000
string statistics = "{\"DEAD_CATS\":\"RESET\",\"LIVES_LEFT\":\"SET#9\",\"MICE_KILLED\":\"INC#2\",\"MICE_MULTIPLIER\":\"INC_TO_LIMIT#2#20\",\"DOG_SCARE_BONUS_POINTS\":\"MAX#20\",\"TREES_CLIMBED_REQ\":\"MIN#5\"}";
SuccessCallback successCallback = (response, cbObject) =>
{
Debug.Log(string.Format("Success | {0}", response));
};
FailureCallback failureCallback = (status, code, error, cbObject) =>
{
Debug.Log(string.Format("Failed | {0} {1} {2}", status, code, error));
};

_bc.PlayerStatisticsService.ProcessStatistics(statistics, successCallback, failureCallback);
JSON Response
{
"status": 200,
"data": {
"statistics": {
"TestStat": 162
}
}
}