.vscode | ||
.gitignore | ||
connection_handler.py | ||
create_database.py | ||
database_connection.py | ||
LICENSE | ||
main.py | ||
match_manager.py | ||
match.py | ||
message_handler.py | ||
README.md | ||
session_manager.py | ||
settings.py | ||
tools.py | ||
user_manager.py | ||
user.py |
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:
new version:
json match state:
{
complete_field: '[[...],[...],...]',
global_field: '[[...],[...],...]',
last_move: {
"sub_x": "...",
"sub_y": "...",
"x": "...",
"y": "..."
}
game_over: <true | false>,
is_draw: <true | false>,
player_won: <null | <player_name>>,
current_player: <null | <player_name>>,
player_a: "...",
player_b: "..."
}
match:
{
"type": "match_update",
"data": {
"id": "...",
"revoke_time": <revoke_time>,
"ranked": "<true | false">,
"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:
keep pw null for requesting a temporary session (will be deleted after one hour of inactivity and matches are not ranked)
{
"type": "login",
"data": {
"name": "<player_name>",
"pw": "<password> | null"
}
}
response:
{
"type": "login_response",
"data": {
"success": <true|false>,
"id": "<session-id>",
"registered": <true | false>,
"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>"
}
}
friend request:
{
"type": "friend_request",
"data" : {
"user": "<friend>"
}
}
response:
{
"type": "friend_request_response",
"data": {
"success": <true|false>
"msg": "..."
}
}
unfriend:
{
"type": "unfriend_request",
"data" : {
"user": "<friend>"
}
}
response:
{
"type": "unfriend_request_response",
"data": {
"success": <true|false>
"msg": "..."
}
}
friend update:
{
"type": "friends_update",
"data": {
"friends": "<list of friends>",
"elos": "<list of elo values>"
}
}
elo rank update:
{
"type": "elo_update",
"data": {
"elo": <elo_value>,
"rank": <rank>,
"top_names": <list of top 100 names>,
"top_elos": <list of top 100 elos>
}
}