| ... | @@ -72,6 +72,16 @@ Uses some decorators as explained in the [User](./user) page, but it also has so |
... | @@ -72,6 +72,16 @@ Uses some decorators as explained in the [User](./user) page, but it also has so |
|
|
|
|
|
|
|
- Uses the Roles-decorator to only pass requests made by a person with admin-role in the game
|
|
- Uses the Roles-decorator to only pass requests made by a person with admin-role in the game
|
|
|
|
|
|
|
|
|
### get flagbox events, GET /game/flag-events/{game's UUID}
|
|
|
|
|
|
|
|
### get initial settings for flagbox, GET /game/flag/{game's UUID}
|
|
|
|
|
|
|
|
- Used by Arduino flagboxes to retrieve some initial settings
|
|
|
|
|
|
|
|
### send flagbox event, POST /game/flag/{game's UUID}
|
|
|
|
|
|
|
|
- Used by Arduino flagboxes to send events
|
|
|
|
|
|
|
### file upload, POST /game/upload
|
|
### file upload, POST /game/upload
|
|
|
|
|
|
|
|
- Uses the FileInterceptor to overwrite some default settings
|
|
- Uses the FileInterceptor to overwrite some default settings
|
| ... | @@ -85,3 +95,77 @@ Uses some decorators as explained in the [User](./user) page, but it also has so |
... | @@ -85,3 +95,77 @@ Uses some decorators as explained in the [User](./user) page, but it also has so |
|
|
### get image, GET /game/images/{filename}
|
|
### get image, GET /game/images/{filename}
|
|
|
|
|
|
|
|
- Sends the file from `/images` folder identified by the filename in the URL
|
|
- Sends the file from `/images` folder identified by the filename in the URL
|
|
|
|
|
|
|
|
## game.service.ts
|
|
|
|
|
|
|
|
Contains 11 functions for game handling.
|
|
|
|
|
|
|
|
### constructor
|
|
|
|
|
|
|
|
GameService uses the NotificationGateway to send socket updates for users. More information about the gateway can be found [here](./notifications)
|
|
|
|
|
|
|
|
### createNewGame(person: PersonEntity, data: newGameDTO)
|
|
|
|
|
|
|
|
- Throws an exception if a game already exists with the same name
|
|
|
|
|
|
|
|
- Creates a new game with the given settings and sets the person creating the game as an admin
|
|
|
|
|
|
|
|
### editGame(data: GameDTO)
|
|
|
|
|
|
|
|
- Throws an exception if a game already exists with the same name
|
|
|
|
|
|
|
|
- Throws an exception if two factions share the same name
|
|
|
|
|
|
|
|
- Throws an exception if an objective point does not have a location assigned to it
|
|
|
|
|
|
|
|
- Modifies the game's settings according to the values in GameDTO
|
|
|
|
|
|
|
|
### updateGameStatus(data: GameStateDTO)
|
|
|
|
|
|
|
|
- Throws an exception if the game was not found
|
|
|
|
|
|
|
|
- Updates the game's state to the given state
|
|
|
|
|
|
|
|
- Triggers a socket update for state-event, which triggers a fetch in frontend
|
|
|
|
|
|
|
|
- Does not have any validation on the order of gamestates, so you can set the game to ENDED and then to CREATED
|
|
|
|
|
|
|
|
### listFactions
|
|
|
|
|
|
|
|
- Lists all the factions from the game, excluding faction's password
|
|
|
|
|
|
|
|
### deleteGame(data: GameId)
|
|
|
|
|
|
|
|
- Deletes the game from the database and everything related to it
|
|
|
|
|
|
|
|
### listGames(state: string)
|
|
|
|
|
|
|
|
- Returns all game names and their id that match the given criteria
|
|
|
|
|
|
|
|
### returnObjectivePointInfo(data: GameId)
|
|
|
|
|
|
|
|
- Returns game's all objective points and their most recent event
|
|
|
|
|
|
|
|
- Uses a helper function `InfoHelper` to check if the point is owned by neutral
|
|
|
|
|
|
|
|
### flagboxQuery(data: GameId)
|
|
|
|
|
|
|
|
- Returns the initial settings for the Arduino flagboxes
|
|
|
|
|
|
|
|
### flagboxEvent(data: FlagboxEventDTO)
|
|
|
|
|
|
|
|
- Saves the events sent by Arduino flagbox to database
|
|
|
|
|
|
|
|
- Triggers a socket update for flagbox-event, which triggers a fetch in frontend
|
|
|
|
|
|
|
|
## gameperson.decorator.ts
|
|
|
|
|
|
|
|
Gameperson decorators works exactly like [UserDecorator](./user#userdecoratorts), but retuns information on user's role in the game. For the decorator to work, the controller **needs** the `RolesGuard` decorator as shown in the example below:
|
|
|
|
|
|
|
|
```typescript
|
|
|
|
@Post('example')
|
|
|
|
@Roles('admin)
|
|
|
|
async exampleroute(@GamePerson() gamePerson: Game_PersonEntity, @Body() data) {
|
|
|
|
return this.exampleservice.examplefunction(gamePerson, body);
|
|
|
|
}
|
|
|
|
``` |