This commit is contained in:
parent
7f436ae0b8
commit
6d2c750a58
|
@ -33,7 +33,8 @@ export class AddGameComponent implements OnInit {
|
||||||
firstName: 'Patrick',
|
firstName: 'Patrick',
|
||||||
team: Team.CONTRA,
|
team: Team.CONTRA,
|
||||||
gamePoints: 0,
|
gamePoints: 0,
|
||||||
finalCardScore: 0
|
finalCardScore: 0,
|
||||||
|
foxesCaught: 1
|
||||||
});
|
});
|
||||||
this.potentialPlayers.push({
|
this.potentialPlayers.push({
|
||||||
firebonkId: 2,
|
firebonkId: 2,
|
||||||
|
@ -430,6 +431,7 @@ export class AddGameComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Bonus points
|
// TODO: Bonus points
|
||||||
|
gameScore += this.getFinalFoxPoints(winningTeam);
|
||||||
|
|
||||||
// TODO: Check for announcements that have not been fulfilled!
|
// TODO: Check for announcements that have not been fulfilled!
|
||||||
|
|
||||||
|
@ -493,4 +495,43 @@ export class AddGameComponent implements OnInit {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates the points that each team got by catching foxes
|
||||||
|
*/
|
||||||
|
calculateFoxPoints(): { re: number, contra: number } {
|
||||||
|
let reFoxesCaught: number = 0;
|
||||||
|
let contraFoxesCaught: number = 0;
|
||||||
|
|
||||||
|
for(let player of this.actualPlayers) {
|
||||||
|
if(player.team === Team.RE) {
|
||||||
|
reFoxesCaught += player.foxesCaught ?? 0;
|
||||||
|
} else {
|
||||||
|
contraFoxesCaught += player.foxesCaught ?? 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
re: reFoxesCaught,
|
||||||
|
contra: contraFoxesCaught
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates the final fox points for the winning team
|
||||||
|
* @param winningTeam The winning team
|
||||||
|
*/
|
||||||
|
getFinalFoxPoints(winningTeam: Team): number {
|
||||||
|
let finalPoints = 0;
|
||||||
|
|
||||||
|
if(winningTeam === Team.RE) {
|
||||||
|
finalPoints += this.calculateFoxPoints().re;
|
||||||
|
finalPoints -= this.calculateFoxPoints().contra;
|
||||||
|
} else {
|
||||||
|
finalPoints += this.calculateFoxPoints().contra;
|
||||||
|
finalPoints -= this.calculateFoxPoints().re;
|
||||||
|
}
|
||||||
|
|
||||||
|
return finalPoints;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user