diff --git a/src/app/components/add-game/add-game.component.ts b/src/app/components/add-game/add-game.component.ts index 6f7d7cb..7b01147 100644 --- a/src/app/components/add-game/add-game.component.ts +++ b/src/app/components/add-game/add-game.component.ts @@ -432,6 +432,7 @@ export class AddGameComponent implements OnInit { // TODO: Bonus points gameScore += this.getFinalFoxPoints(winningTeam); + gameScore += this.getCharliePoints(winningTeam); // TODO: Check for announcements that have not been fulfilled! @@ -503,8 +504,8 @@ export class AddGameComponent implements OnInit { let reFoxesCaught: number = 0; let contraFoxesCaught: number = 0; - for(let player of this.actualPlayers) { - if(player.team === Team.RE) { + for (let player of this.actualPlayers) { + if (player.team === Team.RE) { reFoxesCaught += player.foxesCaught ?? 0; } else { contraFoxesCaught += player.foxesCaught ?? 0; @@ -524,7 +525,7 @@ export class AddGameComponent implements OnInit { getFinalFoxPoints(winningTeam: Team): number { let finalPoints = 0; - if(winningTeam === Team.RE) { + if (winningTeam === Team.RE) { finalPoints += this.calculateFoxPoints().re; finalPoints -= this.calculateFoxPoints().contra; } else { @@ -534,4 +535,18 @@ export class AddGameComponent implements OnInit { return finalPoints; } + + /** + * Returns the extra points for a when a charlie made the final trick. + * If the winning team played the charlie, they get one point. If the losing team played the charlie, the winning team loses one point. + * @param winningTeam The winning team + */ + getCharliePoints(winningTeam: Team): number { + for(let player of this.actualPlayers) { + if(player.wonLastTrickWithCharlie) { + return player.team === winningTeam ? 1 : -1; + } + } + return 0; + } } diff --git a/src/app/models/doppelkopf/player.ts b/src/app/models/doppelkopf/player.ts index bb02f49..6c50a23 100644 --- a/src/app/models/doppelkopf/player.ts +++ b/src/app/models/doppelkopf/player.ts @@ -10,4 +10,5 @@ export interface Player { hadTrumpHandoff?: boolean; team?: Team; foxesCaught?: number; + wonLastTrickWithCharlie?: boolean; }