diff --git a/src/game/game.controller.ts b/src/game/game.controller.ts index 95df1720d7e3d8bb05ecef9333cd71f23f5048e7..3fca76600bb3ca192b3e3e70e290a462dc72d0af 100644 --- a/src/game/game.controller.ts +++ b/src/game/game.controller.ts @@ -41,9 +41,11 @@ export class GameController { private gameservice: GameService, private tickservice: TickService, ) { + // starts timer this.tickservice.startTimer(); } + //new game @Post('new') @UseGuards(new AuthGuard()) @UsePipes(new ValidationPipe()) @@ -51,6 +53,7 @@ export class GameController { return this.gameservice.createNewGame(person, body); } + // edit game @Put('edit/:id') @Roles('admin') @GameStates('CREATED') @@ -60,6 +63,7 @@ export class GameController { return this.gameservice.editGame(id, body); } + // delete game @Delete('delete/:id') @Roles('admin') @GameStates('CREATED') @@ -67,6 +71,7 @@ export class GameController { return this.gameservice.deleteGame(id); } + // change game state @Put('edit-state/:id') @Roles('admin') @UsePipes(new ValidationPipe()) @@ -74,11 +79,13 @@ export class GameController { return this.gameservice.updateGameStatus(body); } + // list all games @Get('listgames') async listGames(state) { return this.gameservice.listGames(state); } + // list games based on parameter @Get('listgames/:state') async listGamesState(@Param('state') state: string) { return this.gameservice.listGames(state); @@ -91,28 +98,33 @@ export class GameController { return this.gameservice.returnGameInfo(id); } + //get all factions @Get('get-factions/:id') @Roles('admin') async returnGameFactions(@Param('id') id: GameEntity) { return this.gameservice.listFactions(id); } + // get flagbox events @Get('flag-events/:id') async returnFlagboxInfo(@Param('id') id: GameEntity) { return this.gameservice.returnObjectivePointInfo(id); } + // initial settings for flagbox @Get('flag/:id') async flagboxQuery(@Param('id') id: string) { return this.gameservice.flagboxQuery(id); } + // flagbox event @Post('flag/:id') @GameStates('STARTED') async flagboxEvent(@Param('id') id: string, @Body() data: FlagboxEventDTO) { return this.gameservice.flagboxEvent(id, data); } + // image upload @Post('upload') @UseInterceptors( FileInterceptor('image', { @@ -134,6 +146,7 @@ export class GameController { return image; } + // get images @Get('images/:img') returnImage(@Param('img') image, @Res() res) { return res.sendFile(image, { root: 'images' }); diff --git a/src/game/game.dto.ts b/src/game/game.dto.ts index e6d99869c101eedc77d7050275c2de4d09b9540f..a5bb525ddc6c34a17da91787a4bf5027405099f2 100644 --- a/src/game/game.dto.ts +++ b/src/game/game.dto.ts @@ -4,7 +4,6 @@ import { Length, IsDateString, IsNumber, - Validate, Min, Max, ValidateNested, @@ -15,7 +14,6 @@ import { } from 'class-validator'; import { ObjectivePointEntity } from './game.entity'; -import { CenterJSON } from '../shared/custom-validation'; import { FactionDTO } from '../faction/faction.dto'; import { CenterDTO, NodeSettingsDTO } from './game.json.dto'; import { Type } from 'class-transformer'; diff --git a/src/game/game.service.ts b/src/game/game.service.ts index 9d0244a4c523d1759818439d5f915f206af4aebe..e4bf8fac3275e3360b9a3eb658dcacd9f4db84ae 100644 --- a/src/game/game.service.ts +++ b/src/game/game.service.ts @@ -1,4 +1,4 @@ -import { Injectable, HttpException, HttpStatus, Inject } from '@nestjs/common'; +import { Injectable, HttpException, HttpStatus } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; import { Repository, Not } from 'typeorm'; @@ -162,7 +162,6 @@ export class GameService { const updatedGame = await this.gameRepository.findOne({ id: game.id }); if (updatedGame) { updatedGame.state = game.state; - console.log(game.state); await this.gameRepository.save(updatedGame); //add or remove from scoretick based on gamestate @@ -188,7 +187,7 @@ export class GameService { } async deleteGame(id) { - // TODO: Delete factions from Faction table associated with the deleted game + // Delete factions from Faction table associated with the deleted game await this.gameRepository.delete({ id }); return { message: 'Game deleted', @@ -270,6 +269,7 @@ export class GameService { return response; } + //returns flagbox colour and faction private async infoHelper(obj) { return (await obj) ? { diff --git a/src/game/gameperson.decorator.ts b/src/game/gameperson.decorator.ts index 26c119ae5edf7771e79fad206b39baaa018ab284..c23eb3800e3a65c596138f0db8d693467c0bd735 100644 --- a/src/game/gameperson.decorator.ts +++ b/src/game/gameperson.decorator.ts @@ -7,6 +7,8 @@ import { createParamDecorator } from '@nestjs/common'; role faction } + + See more information from decorators in shared folder files. */ export const GamePerson = createParamDecorator((data, req) => { return data ? req.gameperson[data] : req.gameperson;