This section describes the responses of server. In general each response have a status, which resides in "status" field. Only response with status "ok" means that last query have been processed clearly, any status, that differs from this, stands for error and his "message" field describes exactly what bad thing have happened.
Every successful query will be followed by this response, it have a status field with value "ok" and all necessary data after it. { "status": "ok", ... }
This is an error response, and have a meaning of syntax error in JSON query parsing. { "status": "badRequest", "message": "", }
This error appears when command is incorrect, unknown, don't have enough fields for command or have extra fields, that don't required by command. Also may be used for error reporting when other error statuses can't be used. { "status": "badCommand", "message": "", }
This error returned if something unhandled happened inside your engine. { "status": "internalError", "message": "", }
Used when a bad password supplied to a register command, when username already exists. { "status": "badPassword", "message": "", }
Thats it, invalid sid supplied to any command, that requires a sid. { "status": "badSid", "message": "", }
Stands for an error, when a name of game already reserved. { "status": "alreadyExists", "message": "" }
This is an error, when some command supplied, that couldn't be executed, when user have status "in game". { "status": "alreadyInGame", "message": "", }
Same as above, but with user status "not in game" { "status": "notInGame", "message": "", }
This section contains a list of commands, with short descriptions ( I hope it'll happen soon).
Note: The commands with a star(*) in a beginning of name should work only in test mode, and return Bad Command in a normal mode.
{
"cmd": "register",
"username": "<username>",
"password": "<password>"
}
Good: { "status": "ok", "sid": "" } Errors: Bad Password, Bad Username
{
"cmd": "unregister",
"sid": "<sid>"
}
Good: OK
Errors: Bad Sid
{
"cmd": "sendMessage",
"sid": "<sid>",
"gameName": "<name of the game>"
"message": "<message>"
}
Good: OK
Errors: Bad Game, Bad Message, Bad Sid
{
"cmd": "getChatHistory",
"sid": "<sid>",
"gameName": "<name of the game>"
}
Good: { "status": "ok", "chat": [ { "username": "", "message": "", "time": "" }, ... ] }
Errors: Bad Sid, Bad Game
{
"cmd": "clear"
}
Good: OK
Errors: None
{
"cmd": "getGamesList",
"sid": "<sid>"
}
Good: { "status": "ok", "games": [ { "gameName": "", "mapName": "", "factionName": "", "gameStatus": "", "playersCount": , "connectedPlayersCount": , "totalCost": }, ... ] }
Errors: Bad Sid
{
"cmd": "getPlayersList",
"sid": "<sid>"
}
Good: { "status": "ok", "players": [ { "username": "" }, ... ] }
Errors: Bad Sid
{
"cmd": "getPlayersListForGame",
"sid": "<sid>",
"gameName": "<name of the game>"
}
Good: { "status": "ok", "players": [ { "username": "" }, ... ] }
Errors: Bad Sid, Bad Game
{
"cmd": "setPlayerStatus",
"sid": "<sid>",
"status": "<status>"
}
Good: OK
{
"cmd": "createGame",
"sid": "<sid>",
"gameName": "<name of the game>",
"maxPlayers": <number>,
"mapName": "<name of map>",
"factionName": "<name of faction>",
"totalCost": <number>
}
Good: OK
{
"cmd": "joinGame",
"sid": "<sid>",
"gameName": "<name of the game>"
}
Good: OK
{
"cmd": "leaveGame",
"sid": "<sid>",
"gameName": "<name of the game>"
}
Good: OK
Each test is a file with .tst extension. The name of a test must contain only Latin letters, symbol "_", and digits. In other words, it must match following regexp /[a-zA-Z0-9_]+\.tst/
The format of test is a set of JSON requests, separated by newlines and/or white spaces. Only double quotes are allowed. An answer to a test must have exactly the same name, but with .ans extension. The format of an answer is absolutely the same as the format of a test.
Consider the following example:
goodUsername_1.tst { "cmd": "register", "username": "Vasya_Pupkin", "password": "123456" } goodUsername_1.ans { "sid": "Vasya_Pupkin123456", "status": "ok" }
The previous example also shows another important aspect - the sid-generator. While running in testing mode, it must return sid, that is generated by simple rule: sid = username + password
Also there are some tricks to make tests fully determined. First of all server must use random number generator, based on Mersenne Twister algorithm. Tester must provide 0 as a seed to a random number generator before each test. Any time specific test must use "2000-01-01 00:00:00" value.
Its a turn-based strategy game, the action takes place on a rectangular field, which is represented by a sequence of strings, consist only of a 3 types of characters: "x" - obstacle, "." - free cell, "[1-9]"(digits from 1 to 9) - players deployment spots. For instance the map in JSON query can be drawn like this { ... "map": ["......222", "....x.222", "...xxx...", "111.x....", "111......"] ... } Before the game starts players must put their Units on a deployment spots. Each Unit have a cost, and sum of all Units costs must be equal of lower then totalCost declared for map. Each Unit have a list of characteristics:
- HP - health
- MP - count of squares, unit can cross in one turn
- Defense
- Attack
- Range
- Damage
- Cost
{
"cmd": "uploadMap",
"sid": "<sid>",
"name": "<name>",
"terrain": "[<map strings>,...]",
}
Good: OK
Error: Bad Map, Bad Sid, Already Exists
{
"cmd": "deleteMap",
"sid": "<sid>",
"name": "<name>"
}
Good: OK
{
"cmd": "uploadFaction",
"sid": "<sid>",
"name": "<name of faction",
"units": [
{
"name": "<name of unit>",
"hp": <number>,
"mp": <number>,
"defense": <number>,
"attack": <number>,
"range": <number>,
"damage": <number>,
"cost": <number>
}, ... ]
}
Good: OK
{
"cmd": "deleteFaction",
"sid": "<sid>",
"name": "<name of faction>"
}
Good: OK
{
"cmd": "uploadArmy",
"sid": "<sid>",
"name": "<name of army>",
"factionName": "<name of faction>",
"units": [
{
"name": "<unit name>",
"count": <number>
},...]
}
Good: OK
{
"cmd": "deleteArmy",
"sid": "<sid>",
"name": "<name of army>"
}
Good: OK
{
"cmd": "chooseArmy",
"sid": "<sid>",
"name": "<name of Army>"
}
Good: OK
{
"cmd": "getMap",
"sid": "<sid>,
"name": "<name of map>"
}
Good: { "status": "ok", "map": ["",...], }
{
"cmd": "getMapList",
"sid": "<sid>"
}
Good: { "status": "ok", "maps": [ { "name": "", "players": "", "width": "", "height": "" } ] }
{
"cmd": "getFaction",
"sid": "<sid>",
"name": "<name of faction>"
}
Good: { "status": "ok", "units": [ { "name": "", "hp": , "mp": , "defense": , "attack": , "range": , "damage": , "cost": }, ... ] }
{
"cmd": "getArmy",
"sid": "<sid>",
"name": "<name of army>"
}
Good: { "status": "ok", "units": [ { "name": "", "count": },... ] }
{
"cmd": "getGameState",
"sid": "<sid>",
"name": "<name of game>"
}
Good:
{
"status": "ok",
"players": [
{
"username": ""
"units": [
{
"name": "",
"hp": ,
"mp": ,
"defense": ,
"attack": ,
"range": ,
"damage": ,
"cost":
}, ...
]
"isReady":
}, ...
]
"turn":
}
{
"cmd": "move",
"sid": "<sid>",
"turn": <number>
"units": [
{
"name": "<name of unit>",
"posX": <number>,
"posY": <number>,
"destX": <number>,
"destY": <number>,
"attackX": <number>,
"attackY": <number>
}, ...
]
}
Good: OK