Scores¶
The scoring system needs a bit of explanation.
There are currently 3 levels of scores maintained:
- profile scores
- session scores
- round scores
Profile scores¶
Each user profile has an associated score with it which maintains the cumulative count of total games played, games won and games lost.
Please note that a game in this context is a full session - which may internally run for multiple rounds.
When a session/game is flushed, played count in the profile scores of all the users participating in that session is incremented by 1 and correspondingly, the win count for the winner is incremented by 1; whereas, the loss count of the loser is incremented by 1.
In the context of real steel where the session is closed at the end of the week, these counts are incremented at the end of such period.
Now, the profile scores also track overall health points (hp) and experience points (xp). (added on 2013-01-19).
Session scores¶
The session is started when the 1st challenge is sent to a particular user OR when sessions are cleared at the end of closure period (end of week).
In the second case, the same users are then joined into the newly created session.
Right now, there are 3 scoring attributes defined for a session:
- score
- xp
- hp
However, this is most likely to change in the future. Instead, we plan to provide templates for different scoring patterns which can be enabled at the time of configuring the application.
Round scores¶
A session may comprise of multiple rounds of play - each requiring its own scoring. Think of the rounds as Innings in a game of cricket or as rounds in a boxing match.
Like session scores, right now, there are 3 scoring attributes defined:
- score
- xp
- hp
Again, this is up for update and most likely will be converted to a template based system.
Playblazer platform exposes API as part of the scoring module to set both session as well as round scores as either incr/decr or absolute values.
API: Get Profile Score¶
Get Profile Score API
URL: {BASE_URL}/app/<APP_ID>/scores/profile/<MODE>/<USER_ID>
Request Method: HTTP GET
Parameter | Mandatory | Type | Description |
---|---|---|---|
APP_ID | Yes | Alpha-numeric | The application ID issued by the Playblazer platform when the app was created |
secret_key | Yes | Alpha-numeric | The secret key issued by the Playblazer platform when the app was created |
MODE | Yes | String | The mode for user ID interpretation |
USER_ID | Yes | Alpha-numeric | The user ID whose profile scores are being requested. |
fmt | No | String | One of (json | xml) - the format of output |
On success, the API returns status=ok along with the dictionary called “profile_scores”.
Instead, if the requesting user’s profile is not found, it returns an error with status=error and code_str=E_NO_PROFILE
Example¶
1. Successful request:
URL Call:
curl "http://api.playblazer.com/v1/app/1/scores/profile/fb/kunalg?secret_key=cb8d878989b9478e96d1b1574a1bf4ec"
Output:
{
"status": "ok",
"profile_scores": {
"played": 124,
"level": 6,
"wins": 38,
"hp": 8,
"losses": 14,
"rp": 1564.88,
"xp": 0,
"level_completion": 44.232,
}
}
API: Set Profile Score¶
Set Profile Score API
URL: {BASE_URL}/app/<APP_ID>/scores/profile/<MODE>/<USER_ID>/set
Request Method: HTTP POST
Parameter | Mandatory | Type | Description |
---|---|---|---|
APP_ID | Yes | Alpha-numeric | The application ID issued by the Playblazer platform when the app was created |
secret_key | Yes | Alpha-numeric | The secret key issued by the Playblazer platform when the app was created |
MODE | Yes | String | The mode for user ID interpretation |
USER_ID | Yes | Alpha-numeric | The user ID whose profile scores are being requested. |
level | No | Numeric | The value of the level to be set. This can be specified either as an increment/decrement (with a +/- sign prefix, - for example, +45 or -18) or as an absolute value (for example, 100). |
xp | No | Numeric | The value of the XP (Experience points) to be set. This can be specified either as an increment/decrement (with a +/- sign prefix, - for example, +45 or -18) or as an absolute value (for example, 100). |
hp | No | Numeric | The value of the HP (Health Points) to be set. This can be specified either as an increment/decrement (with a +/- sign prefix, - for example, +45 or -18) or as an absolute value (for example, 100). |
rp | No | Numeric | The value of the RP (Respect Points) to be set. This can be specified either as an increment/decrement (with a +/- sign prefix, - for example, +45 or -18) or as an absolute value (for example, 100). |
fmt | No | String | One of (json | xml) - the format of output |
On success, the API returns status=ok.
Instead, if the requesting user’s profile is not found, it returns an error with status=error and code_str=E_NO_PROFILE
Note
The values to set can be combined together into a single call as explained in example below.
Example¶
1. Successful request - to set the level:
URL Call:
curl -X POST \
-F "secret_key=cb8d878989b9478e96d1b1574a1bf4ec" \
-F "level=+1" \
"http://api.playblazer.com/v1/app/1/scores/profile/fb/kunalg/set"
Output:
{
"status": "ok"
}
2. Successful request - to set the RP:
URL Call:
curl -X POST \
-F "secret_key=cb8d878989b9478e96d1b1574a1bf4ec" \
-F "rp=+75" \
"http://api.playblazer.com/v1/app/1/scores/profile/fb/kunalg/set"
Output:
{
"status": "ok"
}
3. Successful request - to set the XP and HP in one go:
URL Call:
curl -X POST \
-F "secret_key=cb8d878989b9478e96d1b1574a1bf4ec" \
-F "hp=+10" \
-F "xp=+34" \
"http://api.playblazer.com/v1/app/1/scores/profile/fb/kunalg/set"
Output:
{
"status": "ok"
}
API: Get Session Score¶
Get Session Score API
URL: {BASE_URL}/app/<APP_ID>/scores/<SESSION_ID>
Request Method: HTTP GET
Parameter | Mandatory | Type | Description |
---|---|---|---|
APP_ID | Yes | Alpha-numeric | The application ID issued by the Playblazer platform when the app was created |
secret_key | Yes | Alpha-numeric | The secret key issued by the Playblazer platform when the app was created |
SESSION_ID | Yes | Alpha-numeric | The session ID for which the scores are being requested. |
fmt | No | String | One of (json | xml) - the format of output |
On success, the API returns status=ok along with the dictionary called “scores”.
In case of error, the output will contain status=error and error details encoded as explained earlier.
Each entry in the “scores” dictionary will contain following attributes:
sessid - the session id to which this score object belongs
user - the details about the user for whom this score object is tracked. This internally has two attributes:
- mode - login mode of the user
- id - login ID of the user (say, FB id if the user is logged in using Facebook connect)
score - the score value
xp - the XP value
hp - the HP value
Example¶
1. Successful request:
URL Call:
curl "http://api.playblazer.com/v1/app/1/scores/f0690292d000419fbbed5d5134d528e1?secret_key=cb8d878989b9478e96d1b1574a1bf4ec"
Output:
{
"status": "ok",
"scores": [{
"score": {
"score": 11.0,
"xp": 0.0,
"sessid": "f0690292d000419fbbed5d5134d528e1",
"hp": 0.0,
"user": {
"mode": "fb",
"id": "test_profile"
}
}
},
{
"score": {
"score": 0.0,
"xp": 0.0,
"sessid": "f0690292d000419fbbed5d5134d528e1",
"hp": 0.0,
"user": {
"mode": "fb",
"id": "kunalg"
}
}
}]
}
API: Set Session Score¶
Set Session Score API
URL: {BASE_URL}/app/<APP_ID>/scores/<SESSION_ID>/<MODE>/<USER_ID>/session
Request Method: HTTP POST
Parameter | Mandatory | Type | Description |
---|---|---|---|
APP_ID | Yes | Alpha-numeric | The application ID issued by the Playblazer platform when the app was created |
secret_key | Yes | Alpha-numeric | The secret key issued by the Playblazer platform when the app was created |
SESSION_ID | Yes | Alpha-numeric | The session ID for which the scores need to be updated. |
MODE | Yes | String | The mode for user ID interpretation |
USER_ID | Yes | Alpha-numeric | The user ID whose session scores should be updated. |
score | Yes | Numeric | The value of the score to be set. This can be specified either as an increment/decrement (with a +/- sign prefix, - for example, +45 or -18) or as an absolute value (for example, 100). |
fmt | No | String | One of (json | xml) - the format of output |
On success, the API returns status=ok.
In case of error, the output will contain status=error and error details encoded as explained earlier.
Example¶
1. Successful request:
URL Call:
curl -X POST \
-F "secret_key=cb8d878989b9478e96d1b1574a1bf4ec" \
-F "score=+11" \
"http://api.playblazer.com/v1/app/1/scores/f0690292d000419fbbed5d5134d528e1/fb/test_profile/session"
Output:
{
"status": "ok"
}
API: Set Round Score¶
Set Round Score API
URL: {BASE_URL}/app/<APP_ID>/scores/<SESSION_ID>/<MODE>/<USER_ID>/round
Request Method: HTTP POST
Parameter | Mandatory | Type | Description |
---|---|---|---|
APP_ID | Yes | Alpha-numeric | The application ID issued by the Playblazer platform when the app was created |
secret_key | Yes | Alpha-numeric | The secret key issued by the Playblazer platform when the app was created |
SESSION_ID | Yes | Alpha-numeric | The session ID for which the scores need to be updated. |
MODE | Yes | String | The mode for user ID interpretation |
USER_ID | Yes | Alpha-numeric | The user ID whose session scores should be updated. |
score | Yes | Numeric | The value of the score to be set. This can be specified either as an increment/decrement (with a +/- sign prefix, - for example, +45 or -18) or as an absolute value (for example, 100). |
fmt | No | String | One of (json | xml) - the format of output |
On success, the API returns status=ok.
In case of error, the output will contain status=error and error details encoded as explained earlier.
This API works exactly like the Set Session Score API.
Example¶
1. Successful request:
URL Call:
curl -X POST \
-F "secret_key=cb8d878989b9478e96d1b1574a1bf4ec" \
-F "score=+30" \
"http://api.playblazer.com/v1/app/1/scores/f0690292d000419fbbed5d5134d528e1/fb/kunalg/round"
Output:
{
"status": "ok"
}