|
|
|
## REPLAY
|
|
|
|
|
|
|
|
Replay-folder contains the module, controller and a service. It uses a lot of imports, due to the `MockData` function using so many services.
|
|
|
|
|
|
|
|
## replay.controller.ts
|
|
|
|
|
|
|
|
Contains two routes, which are all prefixed with url `replay`.
|
|
|
|
|
|
|
|
### get replay data, GET /replay/{game's UUID}
|
|
|
|
|
|
|
|
- Any user can fetch the replay data
|
|
|
|
|
|
|
|
### generate mockdata, POST /replay/mockdata/{game's UUID}
|
|
|
|
|
|
|
|
- Must be sent with authorization header containing a Bearer token
|
|
|
|
|
|
|
|
- Uses the Roles-decorator to only pass requests made by a person with admin-role in the game
|
|
|
|
|
|
|
|
## replay.service.ts
|
|
|
|
|
|
|
|
Contains two functions and four helper functions
|
|
|
|
|
|
|
|
### replayData(gameId)
|
|
|
|
|
|
|
|
- Creates a response object with all gamedata with timestamps
|
|
|
|
|
|
|
|
- Players array
|
|
|
|
|
|
|
|
```
|
|
|
|
{
|
|
|
|
"lng": 25.79088,
|
|
|
|
"lat": 62.20147,
|
|
|
|
"time": 1564474732563,
|
|
|
|
"info": [
|
|
|
|
{
|
|
|
|
"key": "icon",
|
|
|
|
"value": "mechanized.svg"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"key": "colour",
|
|
|
|
"value": "#4287f5"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"key": "name",
|
|
|
|
"value": "mech-leader"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"key": "role",
|
|
|
|
"value": "soldier"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
```
|
|
|
|
|
|
|
|
- Factions array
|
|
|
|
|
|
|
|
```
|
|
|
|
{
|
|
|
|
"name": "Verkkotekniikka",
|
|
|
|
"colour": "#f2f23f",
|
|
|
|
"active": true
|
|
|
|
},
|
|
|
|
```
|
|
|
|
|
|
|
|
- Scores
|
|
|
|
|
|
|
|
- Drawings
|
|
|
|
|
|
|
|
- Objective Points
|
|
|
|
|
|
|
|
- Uses two helper functions `returnObjectivePointInfo` and `parseHistory`
|
|
|
|
|
|
|
|
### getScores(gameId: GameEntity)
|
|
|
|
|
|
|
|
- Returns all factions' scores and their colour
|
|
|
|
|
|
|
|
### scoreTick(gameId)
|
|
|
|
|
|
|
|
- Triggered by backend's internal clock
|
|
|
|
|
|
|
|
- Logic explained in greater detail in [`tick`](./tick)
|
|
|
|
|
|
|
|
- Calculates points for factions based on their controlled objective points
|
|
|
|
|
|
|
|
- Uses a helper function `pushScore` to add new scores to the repository
|
|
|
|
|
|
|
|
- At the end of the tick, sends a socket update to trigger score fetch in frontend
|
|
|
|
|
|
|
|
#### pushscore(data: [`ScoreDTO`](./dtos#scoredto))
|
|
|
|
|
|
|
|
- throws an exception if faction was not found
|
|
|
|
|
|
|
|
- takes the latest score and sums the new score to the latest score
|
|
|
|
|
|
|
|
## score.entity.ts
|
|
|
|
|
|
|
|
Reflects the datababse table for score. |