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
by1
- Decrement
INNINGSREM
by1
- Reset
OUTS
to its pre-defined initial value - Increment
POINTS
by5
, but to a maximum of30
- Set
PLAYERS
to8
- Set
HIGHESTHR
to3
, or remain at current higher value - Set
ESTIMATE
to5
, or remain at current lower value - Increment
GAME
by5
For the full statistics grammar see the statistics grammar section.
Service | Operation |
---|---|
globalGameStatistics | PROCESS_STATISTICS |
Method Parameters
Parameter | Description |
---|---|
statistics | A collection containing the statistics to process. |
Usage
http://localhost:3000
- C#
- C++
- Objective-C
- Java
- JavaScript
- Dart
- Cloud Code
- Raw
// S2S call: to view example, switch to the Cloud Code or Raw tab.
// S2S call: to view example, switch to the Cloud Code or Raw tab.
// S2S call: to view example, switch to the Cloud Code or Raw tab.
// S2S call: to view example, switch to the Cloud Code or Raw tab.
// S2S call: to view example, switch to the Cloud Code or Raw tab.
// S2S call: to view example, switch to the Cloud Code or Raw tab.
var statistics = {
"INNING": "INC#1",
"INNINGSREM": "DEC#1",
"OUTS": "RESET",
"POINTS": "INC_TO_LIMIT#5#30",
"PLAYERS": "SET#8",
"HIGHESTHR": "MAX#3",
"ESTIMATE": "MIN#5"
};
var globalStatisticsProxy = bridge.getGlobalStatisticsServiceProxy();
var postResult = globalStatisticsProxy.processStatistics(statistics);
if (postResult.status == 200) {
// Success!
}
{
"service": "globalGameStatistics",
"operation": "PROCESS_STATISTICS",
"data": {
"statistics": {
"INNING": "INC#1",
"INNINGSREM": "DEC#1",
"OUTS": "RESET",
"POINTS": "INC_TO_LIMIT#5#30",
"PLAYERS": "SET#8",
"HIGHESTHR": "MAX#3",
"ESTIMATE": "MIN#5"
}
}
}
JSON Response
{
"data": {
"statisticsExceptions": {
"INNINGSREM": "minApplied"
},
"statistics": {
"OUTS": 0,
"HIGHESTHR": 4,
"PLAYERS": 8,
"INNINGSREM": 0,
"INNING": 2,
"POINTS": 11,
"ESTIMATE": 5
}
},
"status": 200
}