Adding correct point calculation for Solo games
All checks were successful
Jenkins Production Deployment

This commit is contained in:
Patrick Müller 2022-09-16 11:49:39 +02:00
parent 7082abcdf7
commit aec84dca5d
Signed by: Paddy
GPG Key ID: 37ABC11275CAABCE

View File

@ -387,7 +387,7 @@ export class AddGameComponent implements OnInit {
let winningTeam = this.getWinningTeamAndScore().team; let winningTeam = this.getWinningTeamAndScore().team;
let winningTeamScore = this.getWinningTeamAndScore().score; let winningTeamScore = this.getWinningTeamAndScore().score;
let unfulfilledAnnouncementPoints = this.checkUnfulfilledAnnouncements(winningTeam, winningTeamScore); let unfulfilledAnnouncementPoints = this.checkUnfulfilledAnnouncements(winningTeam, winningTeamScore);
let isSoloPlay = false; let isSoloPlay = this.checkIfSolo();
// We are going to calculate the points for the winning team and then set all players points accordingly // We are going to calculate the points for the winning team and then set all players points accordingly
@ -412,8 +412,7 @@ export class AddGameComponent implements OnInit {
gameScore += this.getCharliePoints(winningTeam); gameScore += this.getCharliePoints(winningTeam);
} }
// TODO: Game score in case of a solo this.setGameScores(gameScore, winningTeam, isSoloPlay);
this.setGameScores(gameScore, winningTeam);
} }
/** /**
@ -509,10 +508,14 @@ export class AddGameComponent implements OnInit {
* @param score The score to set * @param score The score to set
* @param winningTeam The team that won * @param winningTeam The team that won
*/ */
setGameScores(score: number, winningTeam: Team) { setGameScores(score: number, winningTeam: Team, isSolo: boolean) {
for (let player of this.actualPlayers) { for (let player of this.actualPlayers) {
if (player.team === winningTeam) { if (player.team === winningTeam) {
if(isSolo) {
player.gamePoints = score * 3;
} else {
player.gamePoints = score; player.gamePoints = score;
}
} else { } else {
player.gamePoints = -score; player.gamePoints = -score;
} }
@ -606,4 +609,27 @@ export class AddGameComponent implements OnInit {
return gamePoints; return gamePoints;
} }
/**
* _____ __
* / ___/____ / /___
* \__ \/ __ \/ / __ \
* ___/ / /_/ / / /_/ /
* /____/\____/_/\____/
*/
/**
* Checks, according to the assigned Teams, if this is a solo play
*/
checkIfSolo(): boolean {
let numberOfElders: number = 0;
for(let player of this.actualPlayers) {
if(player.team === Team.RE) {
numberOfElders++;
}
}
return numberOfElders === 1;
}
} }