Update readme

This commit is contained in:
Eden Kirin
2023-04-02 19:52:47 +02:00
parent c30529c087
commit d4d03b78f9
3 changed files with 271 additions and 168 deletions

183
README.md
View File

@ -24,6 +24,7 @@
## Game States ## Game States
```plantuml ```plantuml
scale 1024 width
hide empty description hide empty description
state "Start Game" as StartGame state "Start Game" as StartGame
@ -314,46 +315,55 @@ Response body:
### WS Data format ### WS Data format
- json - json
```json
{
"message": message_type,
"data": ...
}
```
### Game state structure ### Game state structure
URI: `/game-state` Message: `game_dump`
Data: Data:
```json ```json
{ {
"board": { "board": {
"width": 21, "width": 10,
"height": 21 "height": 10
}, },
"destination": { "destination": {
"position": { "position": {
"x": 10, "x": 5,
"y": 10 "y": 5
} }
}, },
"players": [ "players": [
{ {
"id": "test-player-id", "id": "test-player-pero",
"name": "Pero", "name": "Pero",
"active": true, "active": true,
"position": { "position": {
"x": 2, "x": 3,
"y": 2 "y": 3
}, },
"move_count": 3, "move_count": 0,
"move_attempt_count": 3 "move_attempt_count": 0,
"state": "CREATED"
}, },
{ {
"id": "95962b49-0003-4bf2-b205-71f2590f2318", "id": "test-player-mirko",
"name": "Mirko", "name": "Mirko",
"active": true, "active": true,
"position": { "position": {
"x": 0, "x": 4,
"y": 0 "y": 4
}, },
"move_count": 15, "move_count": 0,
"move_attempt_count": 20 "move_attempt_count": 0,
"state": "CREATED"
} }
], ],
"layers": [ "layers": [
@ -363,36 +373,22 @@ Data:
{ {
"type": "OBSTACLE", "type": "OBSTACLE",
"position": { "position": {
"x": 4, "x": 0,
"y": 2 "y": 6
}
},
{
"type": "OBSTACLE",
"position": {
"x": 4,
"y": 13
}
},
{
"type": "OBSTACLE",
"position": {
"x": 18,
"y": 18
} }
}, },
{ {
"type": "OBSTACLE", "type": "OBSTACLE",
"position": { "position": {
"x": 5, "x": 5,
"y": 4 "y": 1
} }
}, },
{ {
"type": "OBSTACLE", "type": "OBSTACLE",
"position": { "position": {
"x": 7, "x": 1,
"y": 10 "y": 6
} }
} }
] ]
@ -403,8 +399,8 @@ Data:
{ {
"type": "DESTINATION", "type": "DESTINATION",
"position": { "position": {
"x": 10, "x": 5,
"y": 10 "y": 5
} }
} }
] ]
@ -415,15 +411,15 @@ Data:
{ {
"type": "PLAYER", "type": "PLAYER",
"position": { "position": {
"x": 2, "x": 3,
"y": 2 "y": 3
} }
}, },
{ {
"type": "PLAYER", "type": "PLAYER",
"position": { "position": {
"x": 0, "x": 4,
"y": 0 "y": 4
} }
} }
] ]
@ -431,3 +427,110 @@ Data:
] ]
} }
``` ```
### Product purchase start
Message: `product_purchase_start`
Data:
```json
{
"player": {
"id": "test-player-pero",
"name": "Pero",
"active": true,
"position": {
"x": 10,
"y": 10
},
"move_count": 1,
"move_attempt_count": 1,
"state": "ON_DESTINATION"
},
"products": [
{
"name": "CocaCola",
"id": "cocacola-id",
"description": null
},
{
"name": "Pepsi",
"id": "pepsi-id",
"description": null
},
{
"name": "Fanta",
"id": "fanta-id",
"description": null
},
{
"name": "Snickers",
"id": "snickers-id",
"description": null
},
{
"name": "Mars",
"id": "mars-id",
"description": null
},
{
"name": "Burek",
"id": "burek-id",
"description": null
}
],
"timeout": 5
}
```
### Product purchase timer tick
Message: `product_purchase_timer_tick`
Data:
```json
{
"time_left": 4,
"player": {
"id": "test-player-pero",
"name": "Pero",
"active": true,
"position": {
"x": 10,
"y": 10
},
"move_count": 1,
"move_attempt_count": 1,
"state": "ON_DESTINATION"
}
}
```
### Product purchase timer done
Message: `product_purchase_done`
Data:
```json
{
"player": {
"id": "test-player-pero",
"name": "Pero",
"active": true,
"position": {
"x": 10,
"y": 10
},
"move_count": 1,
"move_attempt_count": 1,
"state": "ON_DESTINATION"
},
"product": {
"name": "CocaCola",
"id": "cocacola-id",
"description": null
}
}
```
If product selection timeout occured, product will be null.

View File

@ -45,5 +45,5 @@ class Settings:
ws_server: WSServerSettings ws_server: WSServerSettings
purchase_timeout: int = 10 # seconds purchase_timeout: int = 10 # seconds
log_level: int = logging.INFO log_level: int = logging.INFO
products: Optional[List[Product]] = None products: List[Product] = None
debug: Optional[DebugSettings] = None debug: Optional[DebugSettings] = None