Skip to content
Soarez edited this page Aug 18, 2012 · 8 revisions

ZD Backend API spec

POST /games

Start -- Create a game.

Request
{
  "nickname": "Rulio"
}
Response

The result should be something like this.

{
  "id": "PbDHs",
  "nickname": "Rulio",
  "score": 0,
  
  "rolled": [
    { "color": "red", "face": "shot" },
    { "color": "green", "face": "runner" },
    { "color": "yellow", "face": "brain" }
  ],
  "brains": [],
  "shots": [],
  "runners": []
}

The last three fields are arrays of the dice's colors.

PUT /game/id

Play -- Update the game state.

Request
{
  "id": "PbDHs",
  "nickname": "Rulio",
  "action": "roll",
  
  "score": 0,
  "brains": ["yellow"],
  "shots": ["red"],
  "runners": ["green"]
}

The server only cares about the three first fields. The nickname can be updated. The action, if any, can be either roll or stop. If no action is provided the server returns 400 Bad Request

Response
{
  "id": "PbDHs",
  "nickname": "Rulio",

  "score": 0,
  "rolled": [
    { "color": "red", "face": "shot" },
    { "color": "green", "face": "runner" },
    { "color": "yellow", "face": "brain" }
  ],
  "brains": ["yellow", "green", "yellow"],
  "shots": ["red", "yellow"],
  "runners": ["green"]
}

This is the response in case the specified action was roll. If the specified action was stop, the rolled would be ommited.

Clone this wiki locally