feat: add double down feature to blackjack game
This commit is contained in:
parent
d90fcdcf1e
commit
d2b22b561d
7 changed files with 190 additions and 61 deletions
|
@ -31,6 +31,13 @@ import { Card } from '../../models/blackjack.model';
|
|||
>
|
||||
Halten
|
||||
</button>
|
||||
<button
|
||||
(click)="doubleDown.emit()"
|
||||
class="button-primary px-8 py-4 text-lg font-medium min-w-[120px]"
|
||||
[disabled]="gameState !== 'IN_PROGRESS' || playerCards.length !== 2"
|
||||
>
|
||||
Verdoppeln
|
||||
</button>
|
||||
<button
|
||||
(click)="leave.emit()"
|
||||
class="bg-accent-red hover:bg-accent-red/80 px-8 py-4 rounded text-lg font-medium min-w-[120px] transition-all duration-300"
|
||||
|
@ -48,6 +55,7 @@ export class GameControlsComponent {
|
|||
|
||||
@Output() hit = new EventEmitter<void>();
|
||||
@Output() stand = new EventEmitter<void>();
|
||||
@Output() doubleDown = new EventEmitter<void>();
|
||||
@Output() leave = new EventEmitter<void>();
|
||||
|
||||
calculateHandValue(cards: Card[]): number {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
|
||||
import { ChangeDetectionStrategy, Component, Input, Output, EventEmitter } from '@angular/core';
|
||||
import { CommonModule, CurrencyPipe } from '@angular/common';
|
||||
import { animate, style, transition, trigger } from '@angular/animations';
|
||||
|
||||
|
@ -11,6 +11,7 @@ import { animate, style, transition, trigger } from '@angular/animations';
|
|||
*ngIf="visible"
|
||||
[@fadeInOut]
|
||||
class="modal-bg"
|
||||
style="z-index: 1000; position: fixed;"
|
||||
>
|
||||
<div
|
||||
class="modal-card"
|
||||
|
@ -52,7 +53,7 @@ import { animate, style, transition, trigger } from '@angular/animations';
|
|||
|
||||
<button
|
||||
type="button"
|
||||
(click)="visible = false"
|
||||
(click)="closeDialog()"
|
||||
class="button-primary w-full py-2"
|
||||
>
|
||||
Verstanden
|
||||
|
@ -66,16 +67,16 @@ import { animate, style, transition, trigger } from '@angular/animations';
|
|||
trigger('fadeInOut', [
|
||||
transition(':enter', [
|
||||
style({ opacity: 0 }),
|
||||
animate('300ms ease-out', style({ opacity: 1 }))
|
||||
animate('150ms ease-out', style({ opacity: 1 }))
|
||||
]),
|
||||
transition(':leave', [
|
||||
animate('200ms ease-in', style({ opacity: 0 }))
|
||||
animate('150ms ease-in', style({ opacity: 0 }))
|
||||
])
|
||||
]),
|
||||
trigger('cardAnimation', [
|
||||
transition(':enter', [
|
||||
style({ opacity: 0, transform: 'scale(0.8)' }),
|
||||
animate('350ms ease-out', style({ opacity: 1, transform: 'scale(1)' }))
|
||||
style({ opacity: 0, transform: 'scale(0.95)' }),
|
||||
animate('200ms ease-out', style({ opacity: 1, transform: 'scale(1)' }))
|
||||
])
|
||||
])
|
||||
]
|
||||
|
@ -84,9 +85,12 @@ export class GameResultComponent {
|
|||
@Input() gameState: string = '';
|
||||
@Input() amount: number = 0;
|
||||
@Input() set show(value: boolean) {
|
||||
console.log('GameResultComponent show input changed:', value, 'gameState:', this.gameState);
|
||||
this.visible = value;
|
||||
}
|
||||
|
||||
@Output() close = new EventEmitter<void>();
|
||||
|
||||
visible = false;
|
||||
|
||||
get isWin(): boolean {
|
||||
|
@ -121,4 +125,10 @@ export class GameResultComponent {
|
|||
if (this.isDraw) return 'text-yellow-400';
|
||||
return '';
|
||||
}
|
||||
|
||||
closeDialog(): void {
|
||||
this.visible = false;
|
||||
this.close.emit();
|
||||
console.log('Dialog closed by user');
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue