Read instructions provided in CONTRIBUTING.md.
Send a request at ws://{deployment_address}/ws/connect/. This will open up a websocket connection with the server.
The server uses json formatting for communcation. Thus, all further communication would be through an exchange of json objects. All the message have one mandatory field: type. Often, it is accompanied with another field value. Additional fields might also be used if needed.
Now, to enter the waiting queue and get paired against an opponent of similar strength, send a queuing message:
{
"type": "queue",
// OPTIONAL: Given values are default
"playerDetails": {
"name": "Player",
"rating": 1000
}
}All the response messages have type set as reply. Also, they have a mandatory field success indicating failure / success of the request. In case success field is false, additional field value is supplied telling the reason of teh failure.
{
"type": "reply",
"success": "true"
}In case of failure:
{
"type": "reply",
"success": "false",
"value": "Already in queue!"
}Once you have been added the queue, another response will be sent when the game has been started.
Response after successful pairing:
{
"type": "start",
"color": "white",
"opponentDetails": {
"name": "Player",
"rating": 1000
}
}If it's your turn, you can play a move by sending a move request:
{
"type": "move",
"value": "e2"
}A reponse will generated for your move.
Successful move:
{
"type": "reply",
"success": "true"
}In case the request is rejected, value can have different values like Game has not started yet!, Not your turn!, Invalid move!, etc.
{
"type": "reply",
"success": "false",
"value": "Not your turn!"
}If your move has resulted in termination of the game (checkmate or draw), the response will have additional field outcome. In case of a win, additional field winner telling the winning color will be given.
Refer this doc for termination values.
Reponse in case of win:
{
"type": "reply",
"success": "true",
"outcome": {
"termination": "1",
"result": "1-0",
"winner": "white"
}
}In case of a draw:
{
"type": "reply",
"success": "true",
"outcome": {
"termination": "3",
"result": "1/2-1/2",
}
}Whenever opponent plays a move, player gets a message in this format:
{
"type": "opponent",
"value": "e4"
}If opponent's move has led to termination of the game, a similar outcome field is added.
In case of win (opponent has won):
{
"type": "opponent",
"value": "Qxf7",
"outcome": {
"termination": "1",
"result": "1-0",
"winner": "white"
}
}To be added.
To be added
Once the game is terminated, the players can start a new game by sending a queue request again to the server.
Send HTTP GET request at /health to receive health checks in this format:
{
"available_capacity": 1000,
"ready_to_close": true
}Place .env file in root directory.
# Optional
DEBUG=True
SECRET_KEY=h^z13$qr_s_wd65@gnj7a=xs7t05$w7q8!x_8zsld#
# Optional
LIMIT=1000