Skip to content
Snippets Groups Projects
Commit 0cb15cee authored by L4168's avatar L4168
Browse files

added GameStates Guard

parent 903574f1
No related branches found
No related tags found
3 merge requests!59Development to master,!36Development,!32Game state
...@@ -21,7 +21,7 @@ import { ...@@ -21,7 +21,7 @@ import {
JoinGameGroupDTO, JoinGameGroupDTO,
} from './faction.dto'; } from './faction.dto';
import { FactionService } from './faction.service'; import { FactionService } from './faction.service';
import { Roles } from '../shared/guard.decorator'; import { Roles, GameStates } from '../shared/guard.decorator';
@Controller('faction') @Controller('faction')
export class FactionController { export class FactionController {
...@@ -30,6 +30,7 @@ export class FactionController { ...@@ -30,6 +30,7 @@ export class FactionController {
// takes gameId from the url to verify user role // takes gameId from the url to verify user role
@Post('create-group/:id') @Post('create-group/:id')
@Roles('soldier') @Roles('soldier')
@GameStates('CREATED')
@UsePipes(new ValidationPipe()) @UsePipes(new ValidationPipe())
async createGroup( async createGroup(
@User('id') person, @User('id') person,
...@@ -50,6 +51,7 @@ export class FactionController { ...@@ -50,6 +51,7 @@ export class FactionController {
// takes gameId from the url to verify user role // takes gameId from the url to verify user role
@Put('join-group/:id') @Put('join-group/:id')
@Roles('soldier') @Roles('soldier')
@GameStates('CREATED')
async joinGroup( async joinGroup(
@User('id') person, @User('id') person,
@Param('id') id, @Param('id') id,
...@@ -66,17 +68,24 @@ export class FactionController { ...@@ -66,17 +68,24 @@ export class FactionController {
// param game ID is passed to @Roles // param game ID is passed to @Roles
@Put('promote/:id') @Put('promote/:id')
@UseGuards(new AuthGuard())
@UsePipes(new ValidationPipe())
@Roles('admin') @Roles('admin')
@GameStates('CREATED')
@UsePipes(new ValidationPipe())
promotePlayer(@Param('id') game, @Body() body: PromotePlayerDTO) { promotePlayer(@Param('id') game, @Body() body: PromotePlayerDTO) {
return this.factionservice.promotePlayer(body); return this.factionservice.promotePlayer(body);
} }
@Put('join-faction') // used to join a faction
// :id is the id of the game, and is needed for GameStates to check the state of the game
@Put('join-faction/:id')
@UseGuards(new AuthGuard()) @UseGuards(new AuthGuard())
@GameStates('CREATED')
@UsePipes(new ValidationPipe()) @UsePipes(new ValidationPipe())
joinFaction(@User('id') person, @Body() data: JoinFactionDTO) { joinFaction(
@User('id') person,
@Param('id') game,
@Body() data: JoinFactionDTO,
) {
return this.factionservice.joinFaction(person, data); return this.factionservice.joinFaction(person, data);
} }
} }
...@@ -70,6 +70,7 @@ export class GameController { ...@@ -70,6 +70,7 @@ export class GameController {
} }
@Post('flag/:id') @Post('flag/:id')
@GameStates('STARTED')
async flagboxEvent(@Param('id') id: string, @Body() data: FlagboxEventDTO) { async flagboxEvent(@Param('id') id: string, @Body() data: FlagboxEventDTO) {
return this.gameservice.flagboxEvent(id, data); return this.gameservice.flagboxEvent(id, data);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment