Skip to content
Snippets Groups Projects
Commit a4f6721f authored by L4072's avatar L4072
Browse files

Faction multipliers have a meaning now

parent c47128bd
No related branches found
No related tags found
3 merge requests!59Development to master,!48Development,!47scoreMultiplier to Development
...@@ -19,6 +19,7 @@ import { ...@@ -19,6 +19,7 @@ import {
PromotePlayerDTO, PromotePlayerDTO,
JoinFactionDTO, JoinFactionDTO,
JoinGameGroupDTO, JoinGameGroupDTO,
FactionDTO,
} from './faction.dto'; } from './faction.dto';
import { FactionService } from './faction.service'; import { FactionService } from './faction.service';
import { Roles, GameStates } from '../shared/guard.decorator'; import { Roles, GameStates } from '../shared/guard.decorator';
...@@ -90,6 +91,14 @@ export class FactionController { ...@@ -90,6 +91,14 @@ export class FactionController {
return this.factionservice.joinFaction(person, data); return this.factionservice.joinFaction(person, data);
} }
// 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);
}
// check if person belongs to a faction in a game // check if person belongs to a faction in a game
@Get('check-faction/:id') @Get('check-faction/:id')
@UseGuards(new AuthGuard()) @UseGuards(new AuthGuard())
......
...@@ -3,8 +3,9 @@ import { InjectRepository } from '@nestjs/typeorm'; ...@@ -3,8 +3,9 @@ import { InjectRepository } from '@nestjs/typeorm';
import { Repository, Not } from 'typeorm'; import { Repository, Not } from 'typeorm';
import { FactionEntity, GameGroupEntity } from './faction.entity'; import { FactionEntity, GameGroupEntity } from './faction.entity';
import { JoinFactionDTO, GameGroupDTO, JoinGameGroupDTO } from './faction.dto'; import { JoinFactionDTO, GameGroupDTO, JoinGameGroupDTO, FactionDTO } from './faction.dto';
import { Game_PersonEntity } from '../game/game.entity'; import { Game_PersonEntity } from '../game/game.entity';
import { async } from 'rxjs/internal/scheduler/async';
@Injectable() @Injectable()
export class FactionService { export class FactionService {
...@@ -53,6 +54,14 @@ export class FactionService { ...@@ -53,6 +54,14 @@ export class FactionService {
} }
} }
async changeFactionMultiplier(body: FactionDTO){
const faction = await this.factionRepository.findOne({
where: {factionId: body.factionId}
});
faction.multiplier = body.multiplier;
return await this.factionRepository.save(faction);
}
async promotePlayer(body) { async promotePlayer(body) {
const gamepersonId = body.player; const gamepersonId = body.player;
// get playerdata // get playerdata
......
...@@ -40,7 +40,7 @@ export class ScoreService { ...@@ -40,7 +40,7 @@ export class ScoreService {
order: { scoreTimeStamp: 'DESC' }, order: { scoreTimeStamp: 'DESC' },
}); });
if (lastScore) { if (lastScore) {
scoreData.score += lastScore.score; scoreData.score += lastScore.score * faction.multiplier;
} }
// add the score for Faction // add the score for Faction
const newScore = await this.scoreRepository.create(scoreData); const newScore = await this.scoreRepository.create(scoreData);
...@@ -69,7 +69,7 @@ export class ScoreService { ...@@ -69,7 +69,7 @@ export class ScoreService {
i => i.faction === current.owner.factionId, i => i.faction === current.owner.factionId,
); );
index !== -1 index !== -1
? await (scoreData[index]['score'] += box.objectivePointMultiplier) ? await (scoreData[index]['score'] += box.objectivePointMultiplier * current.owner.multiplier)
: await scoreData.push({ : await scoreData.push({
score: box.objectivePointMultiplier, score: box.objectivePointMultiplier,
faction: current.owner.factionId, faction: current.owner.factionId,
......
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