|
|
|
## DRAW
|
|
|
|
|
|
|
|
Draw-folder follows the usual logic containing a controller, a service, a DTO and an entity file.
|
|
|
|
|
|
|
|
## draw.controller.ts
|
|
|
|
|
|
|
|
Contains two routes, which are all prefixed with url `draw`.
|
|
|
|
|
|
|
|
### insert a map drawing, PUT /draw/mapdrawing/{game's UUID}
|
|
|
|
|
|
|
|
- Body must contain a MapDrawing JSON-object as specified in [`coordinate.dto.ts`](./dtos#mapdrawingdto):
|
|
|
|
|
|
|
|
- Must be sent with authorization header containing a Bearer token
|
|
|
|
|
|
|
|
- GameState must be in `CREATED`, `STARTED` or `PAUSED` state for the request to pass
|
|
|
|
|
|
|
|
- User's gameperson role must be `admin` or `factionleader`
|
|
|
|
|
|
|
|
### fetch map drawings, GET /draw/map/{game's UUID}
|
|
|
|
|
|
|
|
- User must have a gameperson entry in the database
|
|
|
|
|
|
|
|
## draw.service.ts
|
|
|
|
|
|
|
|
Contains three functions
|
|
|
|
|
|
|
|
### draw(data: [MapDrawingDTO](./dtos#mapdrawingdto))
|
|
|
|
|
|
|
|
- Throws an exception if updating a drawing that is not part of your faction
|
|
|
|
|
|
|
|
- Creates a new drawing entry in database if the mapdrawingId is not present in the DTO
|
|
|
|
|
|
|
|
- Updates the mapdrawing matching the DTO's mapdrawingId
|
|
|
|
|
|
|
|
#### private createHistory()
|
|
|
|
|
|
|
|
- Helper function for draw-function, that creates and entry in the mapdrawinghistory table
|
|
|
|
|
|
|
|
### drawMap(data: gameperson, gameId)
|
|
|
|
|
|
|
|
- Returns the faction's and admins map drawings and all drawings if the person requesting them has role `admin`
|
|
|
|
|
|
|
|
## coordinate.entity.ts
|
|
|
|
|
|
|
|
Reflects the datababse table for mapdrawing and their history.
|
|
|
|
|
|
|
|
OwnershipCheck function is used to check if the person updating the drawing was is in the same group as it's creator. |