diff --git a/README.md b/README.md index 9483aac..3cf1cd2 100644 --- a/README.md +++ b/README.md @@ -170,11 +170,11 @@ package Masterpiece #seashell { usecase Game as "Game Engine" usecase WS as "WS Server" } - usecase Vis as "Visualisation\nService" + usecase Vis as "Flutter\nVisualisation\nService" } -usecase ExtVis1 as "Visualisation\nService" -usecase ExtVis2 as "Visualisation\nService" +usecase ExtVis1 as "Visualisation\nClient" +usecase ExtVis2 as "Visualisation\nClient" P1 -left-> API: REST API P2 -left-> API: REST API @@ -204,41 +204,58 @@ Game ->o WS: Send initial state Client1 ->o WS: Client connect activate WS #coral WS -> Client1: Game state -deactivate +deactivate WS Client2 ->o WS: Client connect activate WS #coral WS -> Client2: Game state -deactivate +deactivate WS loop #lightyellow On game state change Game ->o WS: Game state activate WS #coral WS o-> Client1: Game state WS o-> Client2: Game state - deactivate + deactivate WS end -== Product purchase mode == +== Player reached destination == -Game -> WS: Purchase start -activate WS #coral - WS o-> Client1: Purchase start - WS o-> Client2: Purchase start -deactivate +Game -> Game: Lock game for other players +activate Game + Game -> WS: Player reached destination + activate WS #coral + WS o-> Client1: Select product + WS o-> Client2: Select product + deactivate WS +deactivate Game -loop #lightyellow Purchase countdown timer - Game ->o WS: Timer count down +loop #lightyellow Product select countdown timer (60s) + Game ->o WS: Timer timeout + activate Game activate WS #coral - WS o-> Client1: Purchase time left - WS o-> Client2: Purchase time left - deactivate + WS o-> Client1: Selection timeout + WS o-> Client2: Selection timeout + deactivate WS + Game -> Game: Unlock game + deactivate Game end -Game -> WS: Purchase done + +Client1 -> WS: Product selected activate WS #coral - WS o-> Client1: Purchase done - WS o-> Client2: Purchase done -deactivate + WS o-> Game: Product selected + activate Game + WS o-> Client2: Product selected +deactivate WS + + +Game -> Game: Unlock game + Game -> WS: Game state + activate WS #coral + WS o-> Client1: Game state + WS o-> Client2: Game state + deactivate WS +deactivate Game ``` @@ -383,6 +400,8 @@ Response body: ### Game state structure +Direction: Game server -> Clients + Message: `game_dump` Data: @@ -486,109 +505,42 @@ Data: } ``` -### Product purchase start +### Player reached destination -Message: `product_purchase_start` +Direction: Game server -> Clients + +Message: `player_reached_destination` Data: ```json { "player": { - "id": "test-player-pero", - "name": "Pero", + "id": "2e0f1a50-eaa6-4efd-b0c3-adbf7000eec2", + "name": "Joso", "active": true, "position": { - "x": 10, - "y": 10 + "x": 5, + "y": 5 }, - "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, + "move_count": 6, + "move_attempt_count": 6, "state": "ON_DESTINATION" } } ``` -### Product purchase timer done +### Product selection timeout -Message: `product_purchase_done` +Direction: Game server -> Clients -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 - } -} -``` +Message: `product_selection_timeout` -If product selection timeout occured, product will be null. +Data: `null` + +### Product selection done + +Message: `product_selection_done` + +Direction: Client -> Game server, Game server -> Clients + +Data: `null` diff --git a/fairhopper-sdk b/fairhopper-sdk index fd71fa2..ed8f93d 160000 --- a/fairhopper-sdk +++ b/fairhopper-sdk @@ -1 +1 @@ -Subproject commit fd71fa276c2f2030b60a6d41470641d80043618d +Subproject commit ed8f93d7d08112d4e8b625a6b22f9b3cdf4daea0 diff --git a/frontend/index.html b/frontend/index.html index 1f06bca..c836545 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -8,6 +8,9 @@ + @@ -42,6 +45,26 @@ + +