diff --git a/src/app/components/add-game/add-game.component.ts b/src/app/components/add-game/add-game.component.ts index 5d647a5..00895c3 100644 --- a/src/app/components/add-game/add-game.component.ts +++ b/src/app/components/add-game/add-game.component.ts @@ -387,7 +387,7 @@ export class AddGameComponent implements OnInit { let winningTeam = this.getWinningTeamAndScore().team; let winningTeamScore = this.getWinningTeamAndScore().score; 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 @@ -412,8 +412,7 @@ export class AddGameComponent implements OnInit { gameScore += this.getCharliePoints(winningTeam); } - // TODO: Game score in case of a solo - this.setGameScores(gameScore, winningTeam); + this.setGameScores(gameScore, winningTeam, isSoloPlay); } /** @@ -509,10 +508,14 @@ export class AddGameComponent implements OnInit { * @param score The score to set * @param winningTeam The team that won */ - setGameScores(score: number, winningTeam: Team) { + setGameScores(score: number, winningTeam: Team, isSolo: boolean) { for (let player of this.actualPlayers) { if (player.team === winningTeam) { - player.gamePoints = score; + if(isSolo) { + player.gamePoints = score * 3; + } else { + player.gamePoints = score; + } } else { player.gamePoints = -score; } @@ -606,4 +609,27 @@ export class AddGameComponent implements OnInit { 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; + } }