Total score doesn't add up ({{getScoreDifferenceText()}})
+
diff --git a/src/app/components/add-game/add-game.component.ts b/src/app/components/add-game/add-game.component.ts
index 079d0e3..fe528e0 100644
--- a/src/app/components/add-game/add-game.component.ts
+++ b/src/app/components/add-game/add-game.component.ts
@@ -218,13 +218,27 @@ export class AddGameComponent implements OnInit {
/**
* Checks if the sum of all points is exactly 240
*/
- totalScoreValid(): boolean {
+ calculatePointSum(): number {
let totalScore: number = 0;
for (let player of this.actualPlayers) {
totalScore += player.finalCardScore ?? 0;
}
- return totalScore === 240;
+ return totalScore;
+ }
+
+ /**
+ * Generates a string that explains if the total point sum is too low / too high
+ */
+ getScoreDifferenceText(): string {
+ let difference = this.calculatePointSum() - 240;
+
+ if(difference > 0) {
+ return difference + ' more than expected';
+ } else {
+ difference *= -1;
+ return difference + ' less than expected';
+ }
}
/**