Skip to content
Snippets Groups Projects
Commit 425eaa78 authored by Samuli Virtapohja's avatar Samuli Virtapohja
Browse files

changes to formatting

parent e1d08665
No related branches found
No related tags found
3 merge requests!59Development to master,!48Development,!45Specificplayer to Development
......@@ -6,6 +6,8 @@ import {
UsePipes,
Body,
Get,
UseInterceptors,
ClassSerializerInterceptor,
} from '@nestjs/common';
import { TrackingService } from './tracking.service';
......@@ -38,4 +40,12 @@ export class TrackingController {
async getPlayerLocations(@User('id') userId, @Param('id') gameId) {
return this.trackingservice.getPlayers(userId, gameId);
}
@Get('player/:id')
@Roles('admin', 'factionleader')
@GameStates('STARTED', 'PAUSED')
@UseInterceptors(ClassSerializerInterceptor)
async getPlayerData(@User('id') userId, @Param('id') gameid, @Body() person) {
return this.trackingservice.getPlayerData(person);
}
}
......@@ -5,9 +5,12 @@ import { TrackingController } from './tracking.controller';
import { TrackingService } from './tracking.service';
import { TrackingEntity } from './tracking.entity';
import { Game_PersonEntity } from '../game/game.entity';
import { PersonEntity } from '../user/user.entity';
@Module({
imports: [TypeOrmModule.forFeature([TrackingEntity, Game_PersonEntity])],
imports: [
TypeOrmModule.forFeature([TrackingEntity, Game_PersonEntity, PersonEntity]),
],
controllers: [TrackingController],
providers: [TrackingService],
})
......
......@@ -6,6 +6,7 @@ import { Game_PersonEntity } from '../game/game.entity';
import { TrackingEntity } from './tracking.entity';
import { TrackingDTO } from './tracking.dto';
import { FactionEntity } from '../faction/faction.entity';
import { PersonEntity } from '../user/user.entity';
@Injectable()
export class TrackingService {
......@@ -14,6 +15,8 @@ export class TrackingService {
private trackingrepository: Repository<TrackingEntity>,
@InjectRepository(Game_PersonEntity)
private gamepersonrepository: Repository<Game_PersonEntity>,
@InjectRepository(PersonEntity)
private personrepository: Repository<PersonEntity>,
) {}
async trackLocation(personId, gameId, trackdata: TrackingDTO) {
......@@ -95,6 +98,25 @@ export class TrackingService {
return currentdata;
}
// get selected player data
async getPlayerData(person) {
const gameperson = await this.gamepersonrepository.findOne({
where: { gamepersonId: person.gamepersonId },
relations: ['person', 'leaderGroup', 'group', 'faction'],
});
if (!gameperson) {
throw new HttpException('No player found!', HttpStatus.BAD_REQUEST);
}
return {
gamepersonId: gameperson.gamepersonId,
name: gameperson.person.name,
role: gameperson.role,
group: gameperson.group,
faction: gameperson.faction.factionName,
};
}
private async mapFunction(data): Promise<Number> {
return await data.map(type => {
return type;
......
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