Refactoring score calculation logic

This commit is contained in:
2022-09-14 21:58:31 +02:00
parent 051657ef65
commit 753e490c29
5 changed files with 139 additions and 41 deletions
@@ -28,19 +28,19 @@
<table class="point-entry">
<tr *ngIf="this.actualPlayers[0]">
<td><p>{{this.actualPlayers[0].firstName}}</p></td>
<td><input type="number" [(ngModel)]="this.actualPlayers[0].finalCardScore"/></td>
<td><input type="number" [(ngModel)]="this.actualPlayers[0].finalCardScore" (change)="this.calculateCurrentScores()"/></td>
</tr>
<tr *ngIf="this.actualPlayers[1]">
<td><p>{{this.actualPlayers[1].firstName}}</p></td>
<td><input type="number" [(ngModel)]="this.actualPlayers[1].finalCardScore"/></td>
<td><input type="number" [(ngModel)]="this.actualPlayers[1].finalCardScore" (change)="this.calculateCurrentScores()"/></td>
</tr>
<tr *ngIf="this.actualPlayers[2]">
<td><p>{{this.actualPlayers[2].firstName}}</p></td>
<td><input type="number" [(ngModel)]="this.actualPlayers[2].finalCardScore"/></td>
<td><input type="number" [(ngModel)]="this.actualPlayers[2].finalCardScore" (change)="this.calculateCurrentScores()"/></td>
</tr>
<tr *ngIf="this.actualPlayers[3]">
<td><p>{{this.actualPlayers[3].firstName}}</p></td>
<td><input type="number" [(ngModel)]="this.actualPlayers[3].finalCardScore"/></td>
<td><input type="number" [(ngModel)]="this.actualPlayers[3].finalCardScore" (change)="this.calculateCurrentScores()"/></td>
</tr>
</table>
<p id="score-warn" *ngIf="calculatePointSum() !== 240">Total score doesn't add up ({{getScoreDifferenceText()}})</p>
@@ -55,7 +55,7 @@
</div>
<div id="scores">
<p class="team-{{player.team}}" *ngFor="let player of actualPlayers">
{{player.firstName}}: {{calculateCurrentScore(player)}}
{{player.firstName}}: {{player.gamePoints}}
</p>
</div>
</div>