feat(game): add blackjack game component and routing
Some checks failed
CI / Get Changed Files (pull_request) Successful in 6s
CI / Checkstyle Main (pull_request) Has been skipped
CI / prettier (pull_request) Successful in 16s
CI / eslint (pull_request) Failing after 43s
CI / test-build (pull_request) Successful in 46s

This commit is contained in:
Jan-Marlon Leibl 2025-03-26 13:26:38 +01:00
parent 32aa753452
commit eb153f4459
Signed by: jleibl
GPG key ID: 300B2F906DC6F1D5
12 changed files with 273 additions and 2 deletions

View file

@ -0,0 +1,63 @@
import { ChangeDetectionStrategy, Component, inject, signal } from '@angular/core';
import { CommonModule } from '@angular/common';
import { NavbarComponent } from '../../../shared/components/navbar/navbar.component';
import { Router } from '@angular/router';
import { UserService } from '../../../service/user.service';
import { PlayingCardComponent } from './components/playing-card/playing-card.component';
import { DealerHandComponent } from './components/dealer-hand/dealer-hand.component';
import { PlayerHandComponent } from './components/player-hand/player-hand.component';
import { GameControlsComponent } from './components/game-controls/game-controls.component';
import { GameInfoComponent } from './components/game-info/game-info.component';
import { Card } from './models/card.model';
@Component({
selector: 'app-blackjack',
standalone: true,
imports: [
CommonModule,
NavbarComponent,
PlayingCardComponent,
DealerHandComponent,
PlayerHandComponent,
GameControlsComponent,
GameInfoComponent,
],
templateUrl: './blackjack.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export default class BlackjackComponent {
private router = inject(Router);
private userService = inject(UserService);
dealerCards: Card[] = [
{ value: '2', suit: '♥', hidden: false },
{ value: '3', suit: '♦', hidden: false },
{ value: 'B', suit: '□', hidden: true },
];
playerCards: Card[] = [];
currentBet = 0;
balance = signal(0);
constructor() {
this.userService.getCurrentUser().subscribe((user) => {
this.balance.set(user?.balance ?? 0);
});
}
onHit(): void {
// Implementation for hit action
}
onStand(): void {
// Implementation for stand action
}
leaveGame(): void {
this.router.navigate(['/home']);
}
onNewGame(): void {
// Implementation for new game
}
}