feat: add game state enum and refactor game components

This commit is contained in:
Jan-Marlon Leibl 2025-04-02 09:06:44 +02:00
parent 349e4ce1ec
commit 4b569157aa
Signed by: jleibl
GPG key ID: 300B2F906DC6F1D5
10 changed files with 105 additions and 115 deletions

View file

@ -1,6 +1,7 @@
import { ChangeDetectionStrategy, Component, Input, Output, EventEmitter } from '@angular/core';
import { CommonModule, CurrencyPipe } from '@angular/common';
import { animate, style, transition, trigger } from '@angular/animations';
import { GameState } from '../../../../../enum/gameState';
@Component({
selector: 'app-game-result',
@ -55,7 +56,6 @@ import { animate, style, transition, trigger } from '@angular/animations';
</div>
</div>
`,
styleUrls: ['./game-result.component.css'],
changeDetection: ChangeDetectionStrategy.OnPush,
animations: [
trigger('fadeInOut', [
@ -74,7 +74,7 @@ import { animate, style, transition, trigger } from '@angular/animations';
],
})
export class GameResultComponent {
@Input() gameState = '';
@Input() gameState: GameState = GameState.IN_PROGRESS;
@Input() amount = 0;
@Input() set show(value: boolean) {
console.log('GameResultComponent show input changed:', value, 'gameState:', this.gameState);
@ -86,15 +86,15 @@ export class GameResultComponent {
visible = false;
get isWin(): boolean {
return this.gameState === 'PLAYER_WON';
return this.gameState === GameState.PLAYER_WON;
}
get isLoss(): boolean {
return this.gameState === 'PLAYER_LOST';
return this.gameState === GameState.PLAYER_LOST;
}
get isDraw(): boolean {
return this.gameState === 'DRAW';
return this.gameState === GameState.DRAW;
}
getResultTitle(): string {