import { Controller, Post, Param, UsePipes, Body, Get, UseInterceptors, ClassSerializerInterceptor, } from '@nestjs/common'; import { TrackingService } from './tracking.service'; import { User } from '../user/user.decorator'; import { Roles, GameStates } from '../shared/guard.decorator'; import { ValidationPipe } from '../shared/validation.pipe'; import { GeoDTO } from './geo.dto'; import { GamePerson } from '../game/gameperson.decorator'; @Controller('tracking') export class TrackingController { constructor(private trackingservice: TrackingService) {} // inserts tracking data to the database // :id is the id of the game @Post('location/:id') @Roles('soldier') @GameStates('STARTED') @UsePipes(new ValidationPipe()) async trackLocation( @GamePerson() gameperson, @Param('id') id, @Body() trackdata: GeoDTO, ) { return this.trackingservice.trackLocation(gameperson, id, trackdata); } // finds certain player's location // :id is the id of the game @Get('players/:id') @Roles('admin', 'factionleader') @GameStates('STARTED', 'PAUSED') async getPlayerLocations(@GamePerson() gameperson, @Param('id') gameId) { return this.trackingservice.getPlayers(gameperson, gameId); } }