substract-game rules micro service
npm install ganomede-substract-gameRules API
---------
This is a protocol to implement by "rules" services.
Rules services use no storage, they should be pure compute services.
A game has the following fields:
* id
* players: Array of players username
* turn: username of the next player
* status: one of
* active
* gameover
* inactive
* gameData:
* total: remaining stones
* nMoves: number of moves
* moveData:
* number: 21
Will substract 21 to the number of remaining stones. Should be less that the total.
+ Parameters
+ type (string) ... Type of game
Generate an initial game state.
{
"id": "string",
"players": [ "some_username" ]
}
{
"id": "string",
"players": [ "some_username" ],
"turn": "some_username",
"status": "active",
"gameData": {
"total": 121,
"nMoves": 0
}
}
+ Parameters
+ type (string) ... Type of game
{
"id": "string",
"players": [ "some_username", "other_username" ],
"turn": "some_username",
"status": "active",
"gameData": {
"total": 121,
"nMoves": 0
},
"moveData": {
"number": 21
}
}
{
"id": "string",
"players": [ "some_username", "other_username" ],
"turn": "other_username",
"status": "active",
"gameData": {
"total": 100,
"nMoves": 1
},
"moveResult" {
}
}
{
"code": "InvalidNumber"
}
If a number > total was selected.