Go to file
2019-03-21 15:42:34 +01:00
.vscode almost working version 2019-03-21 12:06:22 +01:00
.gitignore Initial commit 2019-03-07 10:29:35 +00:00
connection_handler.py handle reconnects correctly 2019-03-21 15:42:34 +01:00
create_database.py work in progress, commit just for sync 2019-03-14 00:07:32 +01:00
database_connection.py work in progress, commit just for sync 2019-03-14 00:07:32 +01:00
game_manager.py fixing registering process 2019-03-10 13:58:33 +01:00
LICENSE Initial commit 2019-03-07 10:29:35 +00:00
main.py almost working version 2019-03-21 12:06:22 +01:00
match_manager.py almost working version 2019-03-21 12:06:22 +01:00
match.py almost working version 2019-03-21 12:06:22 +01:00
message_handler.py work in progress, commit just for sync 2019-03-14 00:07:32 +01:00
README.md almost working version 2019-03-21 12:06:22 +01:00
session_manager.py almost working version 2019-03-21 12:06:22 +01:00
settings.py filled settings file 2019-03-11 19:03:03 +01:00
user_manager.py almost working version 2019-03-21 12:06:22 +01:00
user.py work in progress, commit just for sync 2019-03-14 00:07:32 +01:00

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:

register as player:

{
    "type": "register",
    "data": {
        "id": "<player_id>",
   		"name": "<player_name>"
    }
}

response:

{
    "type": "register_response",
    "data": {
        "success": true,
        "msg": "<additional info e.g. in case of error>"
    }
}

message from server that game started

{
    "type": "game_starts",
    "data": {
        "msg": "...",
        "opponent_name": "...",
        "is_first_move": true
    }
}

note: is_first_move indicates whether the player or it's opponent begins

move

{
    "type": "move",
    "data": {
        "sub_x": "...",
        "sub_y": "...",
        "x": "...",
        "y": "..."
    }
}

response:

{
    "type": "move_response",
    "data": {
        "success": true,
        "msg": "..."
    }
}

end game

{
    "type": "end_game",
    "data": {
        "msg": "..."
    }
}

(response?)

new version:

json match state:

{
    complete_field: '[[...],[...],...]',
    global_field: '[[...],[...],...]',
    last_move: {
        "sub_x": "...",
        "sub_y": "...",
        "x": "...",
        "y": "..."
    }
    game_over: <true | false>,
    player_won: <null | <player_name>>
    current_player: <null | <player_name>>
    player_a: "..."
    player_b: "..."
}

match:

{
    "type": "match_update",
    "data": {
        "id": "...",
        "match_state": <null| <match_state>>
    }
}

new temp session

client

{
    "type": "temp_session",
    "data": {
   		"name": "<player_name>"
    }
}

server response:

{
    "type": "login_response",
    "data": {
        "success": <true|false>,
        "id": "<session-id>", 
        "msg": "..."
    }
}

connect by session id

client

{
    "type": "reconnect",
    "data": {
        "id": "<session-id>",
    }
}

server response:

{
    "type": "reconnect_response",
    "data": {
        "success": <true|false>,
        "msg": "..."
    }
}

login or register:

{
    "type": "login",
    "data": {
   		"name": "<player_name>",
   		"pw": "<password>"
    }
}

response:

{
    "type": "login_response",
    "data": {
        "success": <true|false>,
        "id": "<session-id>", 
        "msg": "..."
    }
}

match_request:

client (or server for sending invites)

{
    "type": "match_request",
    "data": {
        "player": <null | <opponent_name>>
    }
}

server_response:

{
    "type": "match_request_response",
    "data": {
        "success": <true|false>
        "msg": "..."
    }
}

match_move:

client

{
    "type": "move",
    "data": {
        "id": "match_id",
        "sub_x": "...",
        "sub_y": "...",
        "x": "...",
        "y": "..."
    }
}

match update

(also send on match start and send for all matches after login)

server:

{
    "type": "match_update",
    "data": {
        "id": "<match_id>",
        "match_state": "<json match state>"
    }
}

match close

client:

{
    "type": "end_match",
    "data": {
        "id": "<match_id>"
    }
}