Update readme

This commit is contained in:
Eden Kirin
2023-04-02 20:20:45 +02:00
parent aa0e276cbc
commit f9ed25760f
3 changed files with 240 additions and 157 deletions

393
README.md
View File

@ -8,10 +8,10 @@
- Destination: center of a board (W / 2, H / 2) - Destination: center of a board (W / 2, H / 2)
- Initial player position: Random on board border - Initial player position: Random on board border
- Available moves: - Available moves:
- left - left
- right - right
- up - up
- down - down
- Optional on-board obstacles - Optional on-board obstacles
### Rules ### Rules
@ -202,33 +202,33 @@ Check REST API interface on [FastAPI docs](http://localhost:8010/docs).
Request body: Request body:
```json ```json
{ {
"player_name": "Pero" "player_name": "Pero"
} }
``` ```
Response body: Response body:
```json ```json
{ {
"board": { "board": {
"width": 101, "width": 101,
"height": 101 "height": 101
}, },
"destination": { "destination": {
"position": { "position": {
"x": 50, "x": 50,
"y": 50 "y": 50
} }
}, },
"player": { "player": {
"id": "75bba7cd-a4c1-4b50-b0b5-6382c2822a25", "id": "75bba7cd-a4c1-4b50-b0b5-6382c2822a25",
"name": "Pero", "name": "Pero",
"position": { "position": {
"x": 0, "x": 0,
"y": 10 "y": 10
}, },
"move_count": 0, "move_count": 0,
"move_attempt_count": 0 "move_attempt_count": 0
} }
} }
``` ```
@ -251,16 +251,16 @@ Response code:
Response body: Response body:
```json ```json
{ {
"player": { "player": {
"id": "string", "id": "string",
"name": "Pero", "name": "Pero",
"position": { "position": {
"x": 50, "x": 50,
"y": 50 "y": 50
}, },
"move_count": 10, "move_count": 10,
"move_attempt_count": 12 "move_attempt_count": 12
} }
} }
``` ```
@ -273,16 +273,16 @@ Request body: None
Response body: Response body:
```json ```json
{ {
"player": { "player": {
"id": "string", "id": "string",
"name": "Pero", "name": "Pero",
"position": { "position": {
"x": 50, "x": 50,
"y": 50 "y": 50
}, },
"move_count": 10, "move_count": 10,
"move_attempt_count": 12 "move_attempt_count": 12
} }
} }
``` ```
@ -293,19 +293,19 @@ GET `/game`
Response body: Response body:
```json ```json
{ {
"playerId": "75bba7cd-a4c1-4b50-b0b5-6382c2822a25", "playerId": "75bba7cd-a4c1-4b50-b0b5-6382c2822a25",
"board": { "board": {
"width": 101, "width": 101,
"height": 101 "height": 101
}, },
"destinationPosition": { "destinationPosition": {
"x": 50, "x": 50,
"y": 50 "y": 50
}, },
"playerPosition": { "playerPosition": {
"x": 0, "x": 0,
"y": 10 "y": 10
} }
} }
``` ```
@ -316,8 +316,8 @@ Response body:
```json ```json
{ {
"message": message_type, "message": message_type,
"data": ... "data": ...
} }
``` ```
@ -329,101 +329,101 @@ Message: `game_dump`
Data: Data:
```json ```json
{ {
"board": { "board": {
"width": 10, "width": 10,
"height": 10 "height": 10
}, },
"destination": { "destination": {
"position": { "position": {
"x": 5, "x": 5,
"y": 5 "y": 5
} }
}, },
"players": [ "players": [
{ {
"id": "test-player-pero", "id": "test-player-pero",
"name": "Pero", "name": "Pero",
"active": true, "active": true,
"position": { "position": {
"x": 3, "x": 3,
"y": 3 "y": 3
}, },
"move_count": 0, "move_count": 0,
"move_attempt_count": 0, "move_attempt_count": 0,
"state": "CREATED" "state": "CREATED"
}, },
{ {
"id": "test-player-mirko", "id": "test-player-mirko",
"name": "Mirko", "name": "Mirko",
"active": true, "active": true,
"position": { "position": {
"x": 4, "x": 4,
"y": 4 "y": 4
}, },
"move_count": 0, "move_count": 0,
"move_attempt_count": 0, "move_attempt_count": 0,
"state": "CREATED" "state": "CREATED"
} }
], ],
"layers": [ "layers": [
{ {
"name": "obstacles", "name": "obstacles",
"objects": [ "objects": [
{ {
"type": "OBSTACLE", "type": "OBSTACLE",
"position": { "position": {
"x": 0, "x": 0,
"y": 6 "y": 6
} }
}, },
{ {
"type": "OBSTACLE", "type": "OBSTACLE",
"position": { "position": {
"x": 5, "x": 5,
"y": 1 "y": 1
} }
}, },
{ {
"type": "OBSTACLE", "type": "OBSTACLE",
"position": { "position": {
"x": 1, "x": 1,
"y": 6 "y": 6
} }
} }
] ]
}, },
{ {
"name": "destination", "name": "destination",
"objects": [ "objects": [
{ {
"type": "DESTINATION", "type": "DESTINATION",
"position": { "position": {
"x": 5, "x": 5,
"y": 5 "y": 5
} }
} }
] ]
}, },
{ {
"name": "players", "name": "players",
"objects": [ "objects": [
{ {
"type": "PLAYER", "type": "PLAYER",
"position": { "position": {
"x": 3, "x": 3,
"y": 3 "y": 3
} }
}, },
{ {
"type": "PLAYER", "type": "PLAYER",
"position": { "position": {
"x": 4, "x": 4,
"y": 4 "y": 4
} }
} }
] ]
} }
] ]
} }
``` ```
@ -433,6 +433,53 @@ Message: `product_purchase_start`
Data: Data:
```json ```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 ### Product purchase timer tick
@ -441,6 +488,21 @@ Message: `product_purchase_timer_tick`
Data: Data:
```json ```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 ### Product purchase timer done
@ -449,4 +511,25 @@ Message: `product_purchase_done`
Data: Data:
```json ```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