Skip to main content
Version: 5.7.0

ProcessStatistics

Apply statistics grammar to a partial set of statistics. Global statistics are defined through the brainCloud portal.

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

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
globalGameStatisticsPROCESS_STATISTICS

Method Parameters

ParameterDescription
statisticsA collection containing the statistics to process

Usage

http://localhost:3000
string statistics = "{\"INNING\":\"INC#1\",\"INNINGSREM\":\"DEC#1\",\"OUTS\":\"RESET\",\"POINTS\":\"INC_TO_LIMIT#5#30\",\"PLAYERS\":\"SET#8\",\"HIGHESTHR\":\"MAX#3\",\"ESTIMATE\":\"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.GlobalGameStatisticsService.ProcessStatistics(statistics, successCallback, failureCallback);
JSON Response
{
"data": {
"statisticsExceptions": {
"INNINGSREM": "minApplied"
},
"statistics": {
"OUTS": 0,
"HIGHESTHR": 4,
"PLAYERS": 8,
"INNINGSREM": 0,
"INNING": 2,
"POINTS": 11,
"ESTIMATE": 5
}
},
"status": 200
}