Game information
Terminology:
- game refers to the definition of the product that players play (e.g. 'Noughts and Crosses', 'Chess'). There is one instance of Game for each of these, and it encompasses information which does not change from one session to another, such as the required number of players.
- session refers to an instance of players playing a game (e.g. '2 players playing chess', '4 players playing Wodka'). It encompasses information such as current game environment and who are the current players.
- environment is the current state of the game, encoded as a JSON object. From this object, the server and clients should be able to recreate the current game state.
- user refers to the definition of a user in the database, each login combination is a user.
- player refers to a user who is in a room or a session. One user might be playing multiple games, and thus be associated with multiple players. A player has some additional information associated with it:
- player id is a number unique to a player within a session. Player ids are consecutive from 0 within a session.
- one of the players in a session will be the host and may be afforded extra rights with regard managing the session.
- currency, or whether a player is current, refers to whether a player may make a move in a session. Any number of players may be current at a time.
In all requests {game} refers to the appropriate game name.
Each game may have its own requests, but room and session requests are shared between all games.
List of games
Get a list of games. The game tag is what should be used in all requests which require a game. The name is for display to the user.
Request:
GET games
Response:
[
{
"tag": "noughts",
"name": "Noughts"
"minPlayers": 2,
"maxPlayers": 2
},
...
]
Save/load user-data
Some games support saving user-data. User-data is comprised of a set of key-value pairs which are stored on the server
and associated to a particular user.
Any game which supports user-data must validate any data which a client attempts to save.
The key must match [a-zA-Z0-9_-]+ and be between 1 and 32 characters long.
Request:
GET games/{game}/user-data/{user-id}/{key}
PUT games/{game}/user-data/{user-id}/{key}
Response:
For a GET, the response body contains the value of the data if it exists.
For a PUT, a 204 No Content is expected.
Possible errors:
404 Not Found if the key doesn't exist
400 Bad Request if the game rejected the PUT
403 Forbidden if the user does not have permission to access the give data