feat: add hand value display to dealer and player hands
Some checks failed
CI / Get Changed Files (pull_request) Successful in 6s
CI / prettier (pull_request) Failing after 20s
CI / test-build (pull_request) Successful in 35s
CI / eslint (pull_request) Failing after 44s
CI / Checkstyle Main (pull_request) Successful in 51s

This commit is contained in:
Jan-Marlon Leibl 2025-04-02 13:03:04 +02:00
parent 801edfe89e
commit 40c402ae36
Signed by: jleibl
GPG key ID: 300B2F906DC6F1D5
2 changed files with 24 additions and 2 deletions

View file

@ -2,6 +2,7 @@ import { ChangeDetectionStrategy, Component, Input, OnChanges, SimpleChanges } f
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { Card } from '@blackjack/models/blackjack.model'; import { Card } from '@blackjack/models/blackjack.model';
import { PlayingCardComponent } from '../playing-card/playing-card.component'; import { PlayingCardComponent } from '../playing-card/playing-card.component';
import { GameControlsService } from '@blackjack/services/game-controls.service';
@Component({ @Component({
selector: 'app-dealer-hand', selector: 'app-dealer-hand',
@ -9,7 +10,15 @@ import { PlayingCardComponent } from '../playing-card/playing-card.component';
imports: [CommonModule, PlayingCardComponent], imports: [CommonModule, PlayingCardComponent],
template: ` template: `
<div class="space-y-4"> <div class="space-y-4">
<h3 class="section-heading text-2xl mb-4">Dealer's Karten</h3> <div class="flex justify-between items-center">
<h3 class="section-heading text-2xl">Dealer's Karten</h3>
<div class="flex items-center gap-2">
<div class="text-text-secondary">Punkte:</div>
<div class="text-xl font-bold text-accent-red">
{{ gameControlsService.calculateHandValue(cards) }}
</div>
</div>
</div>
<div class="card p-6 !bg-accent-red"> <div class="card p-6 !bg-accent-red">
<div class="flex justify-center gap-4 min-h-[160px] p-4 border-2 border-red-400 rounded-lg"> <div class="flex justify-center gap-4 min-h-[160px] p-4 border-2 border-red-400 rounded-lg">
@if (cards.length > 0) { @if (cards.length > 0) {
@ -38,6 +47,8 @@ export class DealerHandComponent implements OnChanges {
private lastCardCount = 0; private lastCardCount = 0;
constructor(protected gameControlsService: GameControlsService) {}
ngOnChanges(changes: SimpleChanges): void { ngOnChanges(changes: SimpleChanges): void {
if (changes['cards']) { if (changes['cards']) {
this.updateCardsWithState(); this.updateCardsWithState();

View file

@ -2,6 +2,7 @@ import { ChangeDetectionStrategy, Component, Input, OnChanges, SimpleChanges } f
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { PlayingCardComponent } from '../playing-card/playing-card.component'; import { PlayingCardComponent } from '../playing-card/playing-card.component';
import { Card } from '@blackjack/models/blackjack.model'; import { Card } from '@blackjack/models/blackjack.model';
import { GameControlsService } from '@blackjack/services/game-controls.service';
@Component({ @Component({
selector: 'app-player-hand', selector: 'app-player-hand',
@ -9,7 +10,15 @@ import { Card } from '@blackjack/models/blackjack.model';
imports: [CommonModule, PlayingCardComponent], imports: [CommonModule, PlayingCardComponent],
template: ` template: `
<div class="space-y-4"> <div class="space-y-4">
<h3 class="section-heading text-2xl mb-4">Deine Karten</h3> <div class="flex justify-between items-center">
<h3 class="section-heading text-2xl">Deine Karten</h3>
<div class="flex items-center gap-2">
<div class="text-text-secondary">Punkte:</div>
<div class="text-xl font-bold text-emerald">
{{ gameControlsService.calculateHandValue(cards) }}
</div>
</div>
</div>
<div class="card p-6 !bg-emerald"> <div class="card p-6 !bg-emerald">
<div <div
class="flex justify-center gap-4 min-h-[160px] p-4 border-2 border-emerald-400 rounded-lg" class="flex justify-center gap-4 min-h-[160px] p-4 border-2 border-emerald-400 rounded-lg"
@ -40,6 +49,8 @@ export class PlayerHandComponent implements OnChanges {
private lastCardCount = 0; private lastCardCount = 0;
constructor(protected gameControlsService: GameControlsService) {}
ngOnChanges(changes: SimpleChanges): void { ngOnChanges(changes: SimpleChanges): void {
if (changes['cards']) { if (changes['cards']) {
this.updateCardsWithState(); this.updateCardsWithState();