-
Notifications
You must be signed in to change notification settings - Fork 0
Server API Documentation
Josh Grift edited this page Aug 23, 2019
·
1 revision
All requests are sent by json and have a command value.
| Command | Code | Description |
|---|---|---|
| Register | register |
User Register Request |
| Login | login |
User Login Request |
| List | list |
Lists games for user |
| Get Game | get |
Get's the start game data |
| Action | action |
Send the server a user's game action |
| Test | test |
Send a request to the server to test an action |
| Changes | changes |
Get a list of the changes since the last query |
| Next Turn | next |
Signify to the server the player is ready, or is no longer read |
Client sends password and username.
{
"command":"register",
"user":"jgrift",
"pass":"normal-looking-password"
}Server turns password into hash and stores
{user:”jgrift”,pass:”HAJSDGHJASDGLASDKJ”}
Sends server username and password to login
Client:
{"command":"login", user:"jgrift","pass":"EDFGBNJHGF"}check_auth("EDFGBNJHGF", "normal-looking-password")
{"auth":"456yh"} Lists games for user
{
"command":"list", // command
"user":"jgrift", // user
"auth":"45678in" // authentication token
}{
"games":[
{
"id":"XXXX", // Game/map ID
"name":"Josh's Game" // Game/map Description
}
]
}{
command:”get”, // Commmand
user:”jgrift”, // User
auth:”45678in”, // Authentication Token
game:”XXXX” // Game/map ID
}{
tiles:[
{
"ground":"water", // ground layer (id)
"terrain":"mountain", // terrain layer (id) or null
"building":{ // or null
id:"house", // building id
health:"100",
team:"red",
...
},
"unit":{ // or null
"id":"archer",
"health":"100",
"team":"red",
},
"visable":true, // true or false
"coords":[0,1] // x,y
},
...
],
...
}Complete an action
{
command:”action”,
list:[
{subject:”5,6”,verb:”move”,noun:”5,7”},
...
],
auth:”45678in”,
game:”XXXX”,
user:”jgrift”
}{
results:[
{valid:true,status:null},
...
],
changes:[
{layer:”unit”,x:1,y:1,id:{type:”unit”,health:”80”}
]
}OR
{
results:[
{valid:false,status:”OBSTACLE”}
]
}Same as action, but replace action with test
{command:”changes”,auth:”45678in”,game:”XXXX”,user:”jgrift”}{turn:”play”,changes:[]}OR
{turn:”waiting”,changes:[]}{command:”next”,value:"ready",auth:”45678in”,game:”XXXX”,user:”jgrift”}OR
{command:”next”,value:"cancel",auth:”45678in”,game:”XXXX”,user:”jgrift”}
For your sanity and mine, use tableconvert.com