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

promoting to admin nulls relation to faction and group

parent 0ef626e0
No related branches found
No related tags found
2 merge requests!59Development to master,!48Development
......@@ -10,7 +10,6 @@ import {
FactionDTO,
} from './faction.dto';
import { Game_PersonEntity } from '../game/game.entity';
import { async } from 'rxjs/internal/scheduler/async';
@Injectable()
export class FactionService {
......@@ -82,9 +81,15 @@ export class FactionService {
where: { gamepersonId },
});
if (gameperson) {
const factionleader = await this.game_PersonRepository.create(gameperson);
factionleader.role = body.role;
return await this.game_PersonRepository.save(factionleader);
const promotedPlayer = await this.game_PersonRepository.create(
gameperson,
);
promotedPlayer.role = body.role;
if (body.role === 'admin') {
promotedPlayer.faction = null;
promotedPlayer.group = null;
}
return await this.game_PersonRepository.save(promotedPlayer);
}
throw new HttpException('player does not exist', HttpStatus.BAD_REQUEST);
}
......
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