fixed merge conflict
This commit is contained in:
commit
5bd67aa9e9
84
README.md
84
README.md
@ -1,56 +1,70 @@
|
||||
# ultimate_tictactoe_server
|
||||
# Ultimate TicTacToe Server
|
||||
|
||||
a python server backend for ultimate tic-tac-toe.
|
||||
|
||||
communication with the web client is done by a (far from any standard and almost random) json protocol:
|
||||
|
||||
|
||||
## setup server
|
||||
|
||||
## new version:
|
||||
setup the database connection settings in `settings.py`. If files for a certificate are given, the websocket connection will be use the secured `wss://` websocket protocol instead of `ws://` (which is necessary if the client is accessed by `https://`). To create the necessary tables, the script `./create_database.py` can be used
|
||||
|
||||
|
||||
## communication protocol with client
|
||||
|
||||
**json match state:**
|
||||
|
||||
```json
|
||||
{
|
||||
complete_field: '[[...],[...],...]',
|
||||
global_field: '[[...],[...],...]',
|
||||
last_move: {
|
||||
"sub_x": "...",
|
||||
"sub_y": "...",
|
||||
"x": "...",
|
||||
"y": "..."
|
||||
"complete_field": '[[...],[...],...]',
|
||||
"global_field": '[[...],[...],...]',
|
||||
"last_move": {
|
||||
"sub_x": <int: xcoord of subfield of last move>,
|
||||
"sub_y": <int: ycoord of subfield of last move>,
|
||||
"x": <int: local xcoord in subfield of last move>,
|
||||
"y": <int: local ycoord in subfield of last move>
|
||||
}
|
||||
game_over: <true | false>,
|
||||
is_draw: <true | false>,
|
||||
player_won: <null | <player_name>>,
|
||||
current_player: <null | <player_name>>,
|
||||
player_a: "...",
|
||||
player_b: "..."
|
||||
"game_over": <true | false>,
|
||||
"is_draw": <true | false>,
|
||||
"player_won": <null | <player_name>>,
|
||||
"current_player": <null | <player_name>>,
|
||||
"player_a": "...",
|
||||
"player_b": "..."
|
||||
}
|
||||
```
|
||||
|
||||
`complete_field` is of dimension 9x9, `global_field` of 3x3 (indicating the status of each subfield).
|
||||
The possible values for a single field are
|
||||
|
||||
```
|
||||
FIELD_EMPTY = 0
|
||||
FIELD_USER_A = 1
|
||||
FIELD_USER_B = 2
|
||||
FIELD_DRAW = 3
|
||||
```
|
||||
|
||||
**match**:
|
||||
|
||||
server sends this to every user which is participating in a match if it's updated
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "match_update",
|
||||
"data": {
|
||||
"id": "...",
|
||||
"revoke_time": <revoke_time>,
|
||||
"ranked": "<true | false">,
|
||||
"match_state": <null| <match_state>>
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
**new temp session**
|
||||
|
||||
NOT IMPLEMENTED YET (and maybe never will be)
|
||||
|
||||
give the possibility to temporary login without a password
|
||||
|
||||
client
|
||||
|
||||
```json
|
||||
@ -77,6 +91,8 @@ server response:
|
||||
|
||||
**connect by session id**
|
||||
|
||||
reconnect with the session id from the last session
|
||||
|
||||
client
|
||||
|
||||
```json
|
||||
@ -102,43 +118,41 @@ server response:
|
||||
|
||||
**login or register**:
|
||||
|
||||
login with username and password. If the username does not exist yet, a new account
|
||||
is created automatically. After a successful login the server sends an elo update, friends update and match updates for each open match,.
|
||||
|
||||
|
||||
keep pw null for requesting a temporary session (will be deleted after one hour of inactivity and matches are not ranked)
|
||||
|
||||
|
||||
client:
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "login",
|
||||
"data": {
|
||||
"name": "<player_name>",
|
||||
"pw": "<password> | null"
|
||||
"pw": "<password>"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
response:
|
||||
server response:
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "login_response",
|
||||
"data": {
|
||||
"success": <true|false>,
|
||||
"id": "<session-id>",
|
||||
"registered": <true | false>,
|
||||
"id": "<session-id>",
|
||||
"msg": "..."
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
**match_request**:
|
||||
|
||||
client (or server for sending invites)
|
||||
will be send by clients. If `player` is `null` the player will be matched with the next (or previous)
|
||||
player which sent a request without a player name
|
||||
|
||||
client:
|
||||
|
||||
```json
|
||||
{
|
||||
@ -163,6 +177,8 @@ server_response:
|
||||
|
||||
**match_move**:
|
||||
|
||||
sending moves to the server. The server will answer with a match update.
|
||||
|
||||
client
|
||||
|
||||
```json
|
||||
@ -182,7 +198,7 @@ client
|
||||
|
||||
**match update**
|
||||
|
||||
(also send on match start and send for all matches after login)
|
||||
(is also sent on match start and send for all matches after login)
|
||||
|
||||
server:
|
||||
|
||||
@ -261,6 +277,8 @@ response:
|
||||
|
||||
**friend update**:
|
||||
|
||||
is sent by server after a login or reconnect
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "friends_update",
|
||||
@ -275,6 +293,8 @@ response:
|
||||
|
||||
**elo rank update**:
|
||||
|
||||
is sent by server after login, reconnect or a finished match
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "elo_update",
|
||||
|
Loading…
Reference in New Issue
Block a user