2019-03-07 11:29:35 +01:00
|
|
|
# ultimate_tictactoe_server
|
|
|
|
|
2019-03-10 00:29:52 +01:00
|
|
|
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:
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-03-14 00:01:02 +01:00
|
|
|
## new version:
|
|
|
|
|
|
|
|
**json match state:**
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
complete_field: '[[...],[...],...]',
|
|
|
|
global_field: '[[...],[...],...]',
|
|
|
|
last_move: {
|
|
|
|
"sub_x": "...",
|
|
|
|
"sub_y": "...",
|
|
|
|
"x": "...",
|
|
|
|
"y": "..."
|
|
|
|
}
|
|
|
|
game_over: <true | false>,
|
2019-03-29 12:52:03 +01:00
|
|
|
is_draw: <true | false>,
|
|
|
|
player_won: <null | <player_name>>,
|
|
|
|
current_player: <null | <player_name>>,
|
|
|
|
player_a: "...",
|
2019-03-21 12:06:22 +01:00
|
|
|
player_b: "..."
|
2019-03-14 00:01:02 +01:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2019-03-21 12:06:22 +01:00
|
|
|
|
|
|
|
|
|
|
|
**match**:
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"type": "match_update",
|
|
|
|
"data": {
|
|
|
|
"id": "...",
|
|
|
|
"match_state": <null| <match_state>>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-03-14 00:01:02 +01:00
|
|
|
**new temp session**
|
|
|
|
|
|
|
|
client
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"type": "temp_session",
|
|
|
|
"data": {
|
|
|
|
"name": "<player_name>"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
server response:
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
2019-03-21 12:06:22 +01:00
|
|
|
"type": "login_response",
|
2019-03-14 00:01:02 +01:00
|
|
|
"data": {
|
|
|
|
"success": <true|false>,
|
|
|
|
"id": "<session-id>",
|
2019-03-21 12:06:22 +01:00
|
|
|
"msg": "..."
|
2019-03-14 00:01:02 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
**connect by session id**
|
|
|
|
|
|
|
|
client
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"type": "reconnect",
|
|
|
|
"data": {
|
|
|
|
"id": "<session-id>",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
server response:
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"type": "reconnect_response",
|
|
|
|
"data": {
|
|
|
|
"success": <true|false>,
|
|
|
|
"msg": "..."
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2019-03-21 12:06:22 +01:00
|
|
|
**login or register**:
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"type": "login",
|
|
|
|
"data": {
|
|
|
|
"name": "<player_name>",
|
|
|
|
"pw": "<password>"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
response:
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"type": "login_response",
|
|
|
|
"data": {
|
|
|
|
"success": <true|false>,
|
|
|
|
"id": "<session-id>",
|
|
|
|
"msg": "..."
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2019-03-14 00:01:02 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
**match_request**:
|
|
|
|
|
2019-03-21 12:06:22 +01:00
|
|
|
client (or server for sending invites)
|
2019-03-14 00:01:02 +01:00
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"type": "match_request",
|
|
|
|
"data": {
|
|
|
|
"player": <null | <opponent_name>>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
server_response:
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"type": "match_request_response",
|
|
|
|
"data": {
|
|
|
|
"success": <true|false>
|
|
|
|
"msg": "..."
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
**match_move**:
|
|
|
|
|
|
|
|
client
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"type": "move",
|
|
|
|
"data": {
|
2019-03-21 12:06:22 +01:00
|
|
|
"id": "match_id",
|
2019-03-14 00:01:02 +01:00
|
|
|
"sub_x": "...",
|
|
|
|
"sub_y": "...",
|
|
|
|
"x": "...",
|
|
|
|
"y": "..."
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
**match update**
|
|
|
|
|
|
|
|
(also send on match start and send for all matches after login)
|
|
|
|
|
|
|
|
server:
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"type": "match_update",
|
|
|
|
"data": {
|
|
|
|
"id": "<match_id>",
|
|
|
|
"match_state": "<json match state>"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
**match close**
|
|
|
|
|
|
|
|
client:
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"type": "end_match",
|
|
|
|
"data": {
|
|
|
|
"id": "<match_id>"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2019-03-21 12:06:22 +01:00
|
|
|
|
|
|
|
|
2019-03-24 16:44:20 +01:00
|
|
|
**friend request**:
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"type": "friend_request",
|
|
|
|
"data" : {
|
|
|
|
"user": "<friend>"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
response:
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"type": "friend_request_response",
|
|
|
|
"data": {
|
|
|
|
"success": <true|false>
|
|
|
|
"msg": "..."
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
**unfriend**:
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"type": "unfriend_request",
|
|
|
|
"data" : {
|
|
|
|
"user": "<friend>"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
response:
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"type": "unfriend_request_response",
|
|
|
|
"data": {
|
|
|
|
"success": <true|false>
|
|
|
|
"msg": "..."
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
**friend update**:
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"type": "friends_update",
|
|
|
|
"data": {
|
2019-03-29 12:52:03 +01:00
|
|
|
"friends": "<list of friends>",
|
|
|
|
"elos": "<list of elo values>"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
**elo rank update**:
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"type": "elo_update",
|
|
|
|
"data": {
|
2019-03-29 14:50:38 +01:00
|
|
|
"elo": <elo_value>,
|
|
|
|
"rank": <rank>,
|
|
|
|
"top_names": <list of top 100 names>,
|
|
|
|
"top_elos": <list of top 100 elos>
|
2019-03-24 16:44:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|