Skip to content
Snippets Groups Projects

Development to testing

Merged Ghost User requested to merge Development into testing
10 files
+ 89
56
Compare changes
  • Side-by-side
  • Inline
Files
10
@@ -7,8 +7,6 @@ import {
Body,
Get,
Put,
UseInterceptors,
ClassSerializerInterceptor,
Delete,
} from '@nestjs/common';
@@ -24,7 +22,24 @@ import {
} from './faction.dto';
import { FactionService } from './faction.service';
import { Roles, GameStates } from '../shared/guard.decorator';
import { GamePerson } from 'src/game/gameperson.decorator';
import { GamePerson } from '../game/gameperson.decorator';
/////////////////////////////////////////////////////////////////////////////////
/// FactionController is being used for routing: ///
/// ///
/// Group ///
/// - create group when game status is CREATED ///
/// - getting groups with faction id(this is used mainly for listing players) ///
/// - joining group when game status is CREATED ///
/// ///
/// Faction ///
/// - checking users faction ///
/// - joining faction ///
/// - leaving faction ///
/// - changing faction multiplier (not implemented) ///
/// ///
/// See shared folder files for more information on decorators. ///
/////////////////////////////////////////////////////////////////////////////////
@Controller('faction')
export class FactionController {
@@ -40,9 +55,7 @@ export class FactionController {
@Param('id') id: string,
@Body() data: GameGroupDTO,
) {
try {
return this.factionservice.createGroup(person, id, data);
} catch (error) {}
return this.factionservice.createGroup(person, id, data);
}
// id is faction ID
@@ -63,12 +76,6 @@ export class FactionController {
return this.factionservice.joinGroup(gameperson, data);
}
@UseInterceptors(ClassSerializerInterceptor)
@Get('get-faction-members/:id')
async getFactionMembers(@Param('id') factionId) {
return this.factionservice.listFactionMembers(factionId);
}
// param game ID is passed to @Roles
@Put('promote/:id')
@Roles('admin')
@@ -82,7 +89,7 @@ export class FactionController {
// :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())
@GameStates('CREATED', 'STARTED')
@GameStates('CREATED', 'STARTED', 'PAUSED')
@UsePipes(new ValidationPipe())
joinFaction(
@User('id') person,
@@ -100,13 +107,15 @@ export class FactionController {
leaveFaction(@GamePerson('gamepersonId') gamepersonId) {
return this.factionservice.leaveFaction(gamepersonId);
}
// used to change factions multiplier
@Put('faction-multiplier/:id')
@Roles('admin')
@GameStates('STARTED')
factionMultiplier(@Param('id') game, @Body() body: FactionDTO) {
return this.factionservice.changeFactionMultiplier(body);
}
// not implemented in frontend uncomment this and services equivalent when needed
// @Put('faction-multiplier/:id')
// @Roles('admin')
// @GameStates('STARTED')
// factionMultiplier(@Param('id') game, @Body() body: FactionDTO) {
// return this.factionservice.changeFactionMultiplier(body);
// }
// check if person belongs to a faction in a game
@Get('check-faction/:id')
Loading