feat: add audio features and sounds to the game
Some checks failed
CI / Get Changed Files (pull_request) Successful in 31s
CI / Checkstyle Main (pull_request) Has been skipped
CI / Docker backend validation (pull_request) Has been skipped
CI / oxlint (pull_request) Successful in 23s
CI / prettier (pull_request) Failing after 27s
CI / eslint (pull_request) Successful in 31s
CI / test-build (pull_request) Successful in 49s
CI / Docker frontend validation (pull_request) Successful in 1m34s
Some checks failed
CI / Get Changed Files (pull_request) Successful in 31s
CI / Checkstyle Main (pull_request) Has been skipped
CI / Docker backend validation (pull_request) Has been skipped
CI / oxlint (pull_request) Successful in 23s
CI / prettier (pull_request) Failing after 27s
CI / eslint (pull_request) Successful in 31s
CI / test-build (pull_request) Successful in 49s
CI / Docker frontend validation (pull_request) Successful in 1m34s
This commit is contained in:
parent
4f2e7fe712
commit
5809757bc9
12 changed files with 133 additions and 1 deletions
|
@ -14,6 +14,7 @@ import { UserService } from '@service/user.service';
|
|||
import { timer } from 'rxjs';
|
||||
import { DebtDialogComponent } from '@shared/components/debt-dialog/debt-dialog.component';
|
||||
import { AuthService } from '@service/auth.service';
|
||||
import { AudioService } from '@shared/services/audio.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-blackjack',
|
||||
|
@ -35,6 +36,7 @@ export default class BlackjackComponent implements OnInit {
|
|||
private userService = inject(UserService);
|
||||
private authService = inject(AuthService);
|
||||
private blackjackService = inject(BlackjackService);
|
||||
private audioService = inject(AudioService);
|
||||
|
||||
dealerCards = signal<Card[]>([]);
|
||||
playerCards = signal<Card[]>([]);
|
||||
|
@ -91,6 +93,9 @@ export default class BlackjackComponent implements OnInit {
|
|||
// Show the result dialog after refreshing user data
|
||||
timer(500).subscribe(() => {
|
||||
this.showGameResult.set(true);
|
||||
if (game.state === GameState.PLAYER_WON || game.state === GameState.PLAYER_BLACKJACK) {
|
||||
this.audioService.playWinSound();
|
||||
}
|
||||
console.log('Game result dialog shown after delay');
|
||||
});
|
||||
});
|
||||
|
@ -99,6 +104,7 @@ export default class BlackjackComponent implements OnInit {
|
|||
|
||||
onNewGame(bet: number): void {
|
||||
this.isActionInProgress.set(true);
|
||||
this.audioService.playBetSound();
|
||||
|
||||
this.blackjackService.startGame(bet).subscribe({
|
||||
next: (game) => {
|
||||
|
@ -117,6 +123,7 @@ export default class BlackjackComponent implements OnInit {
|
|||
if (!this.currentGameId() || this.isActionInProgress()) return;
|
||||
|
||||
this.isActionInProgress.set(true);
|
||||
this.audioService.playBetSound();
|
||||
|
||||
this.blackjackService.hit(this.currentGameId()!).subscribe({
|
||||
next: (game) => {
|
||||
|
@ -143,6 +150,7 @@ export default class BlackjackComponent implements OnInit {
|
|||
}
|
||||
|
||||
this.isActionInProgress.set(true);
|
||||
this.audioService.playBetSound();
|
||||
|
||||
this.blackjackService.stand(this.currentGameId()!).subscribe({
|
||||
next: (game) => {
|
||||
|
@ -167,6 +175,7 @@ export default class BlackjackComponent implements OnInit {
|
|||
}
|
||||
|
||||
this.isActionInProgress.set(true);
|
||||
this.audioService.playBetSound();
|
||||
|
||||
this.blackjackService.doubleDown(this.currentGameId()!).subscribe({
|
||||
next: (game) => {
|
||||
|
|
Reference in a new issue