docs: minor adjustements and comments on techDesign #2

Open
micosil wants to merge 1 commits from micosil-techDesign-comments into main
1 changed files with 59 additions and 53 deletions

View File

@ -108,16 +108,20 @@ Upon completing the seven rounds, players will be notified of the points they ea
## 4. Out of scope (for V1) ## 4. Out of scope (for V1)
- Private lobbies, where an admin can invite players by user id - Private lobbies, where an admin can invite players by user id
<!--Games are private by default as you need the code to join, and there will be no listing of all lobbies,simply being able to kick players out should suffice.-->
- Kick player out from a lobby - Kick player out from a lobby
- Games history, saving to database - Games history, saving to database
- Playing against bots, with either algorithmic behaviour or AI - Playing against bots, with either algorithmic behaviour or AI
- Drawing pieces, instead of placing them - Drawing pieces, instead of placing them
- Timed rounds
## 5. High-level proposal ## 5. High-level proposal
### 5.1. Server-client communications ### 5.1. Server-client communications
Server and client need to communicate asynchronously, as many actions (such as submitting piece placements) need to wait for other players to finish their respective actions. For this reason, they will communicate through web-sockets. The following requests will be needed: Server and client need to communicate asynchronously, as many actions (such as submitting piece placements) need to wait for other players to finish their respective actions. For this reason, they will communicate through web-sockets. The following requests <!-- best to talk about events as there will be no requests in the traditional REST sense --> will be needed:
<!-- *I think a request "originator" or direction would also be useful in this table, for exaple the game start event originates from the server, after all the players in the lobby have indicated that they are ready* -->
| Request type | Inputs | Outputs | Notes | | Request type | Inputs | Outputs | Notes |
| ----------------------- | ------------------------------------- | ----------------------- | ----------------------------------------------------------------------- | | ----------------------- | ------------------------------------- | ----------------------- | ----------------------------------------------------------------------- |
@ -155,7 +159,7 @@ The systems will contain the following modules, with submodules for specific ite
- Manages the room state transitions, from lobby to in-game to ended - Manages the room state transitions, from lobby to in-game to ended
- Manages the rounds transitions - Manages the rounds transitions
- Administrates quests - Administrates quests
- Piece placement module - Piece placement module <!--we have to be careful with what we inject with in this module, ideally nothing, as we wont have DI in react-->
- Verification logic on piece placement (shared between front and back-end) - Verification logic on piece placement (shared between front and back-end)
- Special cells and pieces consumption (shared also) - Special cells and pieces consumption (shared also)
- Manages piece placement action stackings to enable undo actions (front only) - Manages piece placement action stackings to enable undo actions (front only)
@ -169,7 +173,7 @@ The systems will contain the following modules, with submodules for specific ite
### 6.1. Modellisation of the users and games ### 6.1. Modellisation of the users and games
``` ```ts
var usersMap = Map<socketId: string, userId: string> var usersMap = Map<socketId: string, userId: string>
var users = Map<userId: string, User> var users = Map<userId: string, User>
User = { User = {
@ -199,8 +203,8 @@ Game = {
| 1. Cell<br/> 2. Piece <br/> 3. External node <br/> 4. Border <br/> 5. Track <br/> 6. Internal node <br/> 7. Exit <br/> 8. Internal node | <img src="./samples/modellisation-schema.jpg" width=300px height=320px/> | | 1. Cell<br/> 2. Piece <br/> 3. External node <br/> 4. Border <br/> 5. Track <br/> 6. Internal node <br/> 7. Exit <br/> 8. Internal node | <img src="./samples/modellisation-schema.jpg" width=300px height=320px/> |
**Enum types** **Enum types**
<!-- string enums are much more human readable if we later on decide to store games on a database-->
``` ```ts
TrackType = "RAIL" | "ROAD" TrackType = "RAIL" | "ROAD"
Direction = "NORTH" | "SOUTH" | "EAST" | "WEST" Direction = "NORTH" | "SOUTH" | "EAST" | "WEST"
ExitType = "RAIL" | "ROAD" | "AMBIVALENT" ExitType = "RAIL" | "ROAD" | "AMBIVALENT"
@ -210,7 +214,7 @@ CellType = "NORMAL" | "STATION" | "FACTORY" | "UNIVERSITY"
**Internal types** **Internal types**
``` ```ts
Exit = { type: ExitType } Exit = { type: ExitType }
absctract Node = { cell: Cell } absctract Node = { cell: Cell }
ExternalNode extends Node = { ExternalNode extends Node = {
@ -228,7 +232,7 @@ Border = Pair<ExternalNode, ExternalNode | Exit> // Joins two nodes from adjacen
**Main types** **Main types**
``` ```ts
Cell = { Cell = {
externalNodes: Set<ExternalNode>, externalNodes: Set<ExternalNode>,
type: CellType, type: CellType,
@ -258,10 +262,10 @@ Given a Board object:
- If there are some tracks, for each of them find the external nodes that they can connect to. Traverse through the internal nodes when necessary. Note: internal nodes might be dead ends in some cases. - If there are some tracks, for each of them find the external nodes that they can connect to. Traverse through the internal nodes when necessary. Note: internal nodes might be dead ends in some cases.
- For each accessible external node (not the original), get the cell's border and traverse it: - For each accessible external node (not the original), get the cell's border and traverse it:
- If it's an exit: - If it's an exit:
- If it's not AMBIVALENT, pop it from the original set and add it to this sub-grid's set. - If it's not `AMBIVALENT`, pop it from the original set and add it to this sub-grid's set.
- Then stop (regardless of the type of exit) - Then stop (regardless of the type of exit)
- If it's another cell, execute this process recursively starting from the new cell's starting external node. - If it's another cell, execute this process recursively starting from the new cell's starting external node.
- In order to avoid the algorithm to stack overflow on looped grids, every time an external node is accessed, consume it by adding it to a global ban-list. - In order to avoid the algorithm to stack overflow on looped grids, every time an external node is accessed, consume it by adding it to a global visited-node-list.
#### 6.2.3. Calculating longest road #### 6.2.3. Calculating longest road
@ -278,47 +282,49 @@ For each border in a board, we will verify:
### 6.3. Game transitions ### 6.3. Game transitions
## 7. Implementation plan ## 7. Implementation plan
- [ ] Design phase
- Home page - [x] First design document Draft
- Manage user connection - [ ] Migrate tasks to kanban
- Create join page - [ ] Home page
- Page frame - [ ] Manage user connection
- User name input box - [ ] Create join page
- Create lobby button and request - [ ] Page frame
- Join lobby button, input box, and request - [ ] User name input box
- Create lobby page - [ ] Create lobby button and request
- Create players view - [ ] Join lobby button, input box, and request
- Create start game button - [ ] Create lobby page
- Create request handlers - [ ] Create players view
- Create lobby handler - [ ] Create start game button
- Join lobby handler - [ ] Create request handlers
- Broadcasting in lobby - [ ] Create lobby handler
- Game start handler - [ ] Join lobby handler
- Game play - [ ] Broadcasting in lobby
- Game page - [ ] Game start handler
- Create board view - [ ] Game play
- Create piece set view - [ ] Game page
- Create piece focus (and rotation) view - [ ] Create board view
- Create quests view - [ ] Create piece set view
- Create piece placement animations - [ ] Create piece focus (and rotation) view
- Create piece placement validator - [ ] Create quests view
- Create special cells logic - [ ] Create piece placement animations
- Create undo action button - [ ] Create piece placement validator
- Create submit button - [ ] Create special cells logic
- Create submit handler - [ ] Create undo action button
- Create quests checker and broadcasting - [ ] Create submit button
- One quest checker will be needed per quest type - [ ] Create submit handler
- Create quests info display in web - [ ] Create quests checker and broadcasting
- Create round info broadcasted - [ ] One quest checker will be needed per quest type
- Game end - [ ] Create quests info display in web
- Game end page - [ ] Create round info broadcasted
- Create boards view - [ ] Game end
- Create points view - [ ] Game end page
- Create winner view - [ ] Create boards view
- Create focus board animations - [ ] Create points view
- Create points calculation logic - [ ] Create winner view
- Create quests counter - [ ] Create focus board animations
- Create longest track pathfinder - [ ] Create points calculation logic
- Create connected exits pathfinder - [ ] Create quests counter
- Create dead-end tracks counter - [ ] Create longest track pathfinder
- Create house and center cells counter - [ ] Create connected exits pathfinder
- [ ] Create dead-end tracks counter
- [ ] Create house and center cells counter