turngame
v1.2.4
Published
Ganomede turngame micro service
Downloads
30
Readme
Turn-Game
Manage a turn based game session.
Relations
The turn-game module will:
- Manage in-progress games in the
redis_games
redis database. - Perform moves requested by clients using rules-api services, update
redis_games
. - Use the
redis_auth
database to check requester identity.
Configuration
RULES_PORT_8080_TCP_ADDR
- IP of the rules serviceRULES_PORT_8080_TCP_PORT
- Port of the rules serviceCHAT_PORT_8080_TCP_ADDR
- IP of the chat service (optional)CHAT_PORT_8080_TCP_PORT
- Port of the chat service (optional)NOTIFICATIONS_PORT_8080_TCP_ADDR
- IP of the notifications serviceNOTIFICATIONS_PORT_8080_TCP_PORT
- Port of the notifications serviceAPI_SECRET
- Secret key used to send notificationsREDIS_AUTH_PORT_6379_TCP_ADDR
- IP of the AuthDB redisREDIS_AUTH_PORT_6379_TCP_PORT
- Port of the AuthDB redisREDIS_GAMES_PORT_6379_TCP_ADDR
- IP of the games redisREDIS_GAMES_PORT_6379_TCP_PORT
- Port of the games redis
API
All requests made to the turngame API require an auth token, passed in the request URL.
Single Game [/turngame/v1/auth/:token/games/:id]
+ Parameters
+ token (string) ... User authentication token
+ id (string) ... ID of the game
Retrieve a game state [GET]
response [200] OK
{
"id": "ab12345789",
"type": "triominos/v1",
"players": [ "some_username_1", "some_username_2" ],
"turn": "some_username_1",
"status": "active",
"gameData": { ... }
}
Possible status:
inactive
active
gameover
Create a game [POST]
Use the appropriate rules-api
service to initiate a new game.
body (application/json)
{
"type": "triominos/v1",
"players": [ "some_username_1", "some_username_2" ],
"gameConfig": {
... game specific data to be passed to the rules-api ...
}
}
response [200] OK
{
"id": "1234",
"type": "triominos/v1",
"players": [ "some_username", "other_username" ],
"turn": "some_username",
"status": "inactive",
"gameData": {
... game specific data ...
}
}
Moves Collection [/turngame/v1/auth/:token/games/:id/moves]
+ Parameters
+ token (string) ... Authentication token
+ id (string) ... ID of the game
Add a move to a game [POST]
Add a move, optionally trigger a chat system event (if "chatEvent" is provided).
body (application/json)
{
"moveData": { ... },
"chatEvent": "pass"
}
response [200] OK
{
"id": "string",
"type": "triominos/v1",
"players": [ "some_username", "other_username" ],
"turn": "other_username",
"status": "active",
"gameData": {
... game specific data ...
},
"moveResult" {
... game specific data ...
}
}
response [400] Bad Request
{
"code": "InvalidPosition"
}
List of codes will be application dependent, as returned by the rules-api
List moves made on the given game [GET]
response [200] OK
[
{
"player": "some_username",
"move": { ... }
},
{
"player": "other_username",
"move": { ... }
},
{
"player": "some_username",
"move": { ... }
}
]