feat(game): add blackjack game component and routing
Some checks failed
Some checks failed
This commit is contained in:
parent
32aa753452
commit
eb153f4459
12 changed files with 273 additions and 2 deletions
|
@ -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
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue