feat(slots): add slot machine component with styling and logic #170

Merged
jleibl merged 9 commits from task/CAS-44/lootbox-selection into main 2025-05-07 16:10:05 +00:00
3 changed files with 9 additions and 9 deletions
Showing only changes of commit 205bf1e52c - Show all commits

View file

@ -57,7 +57,7 @@ export default class BlackjackComponent implements OnInit {
this.balance.set(user.balance);
}
});
// Subscribe to user updates for real-time balance changes
this.userService.currentUser$.subscribe((user) => {
if (user) {
@ -92,7 +92,7 @@ export default class BlackjackComponent implements OnInit {
if (isGameOver) {
console.log('Game is over, state:', game.state);
this.userService.refreshCurrentUser();
// Get the latest balance before showing the result dialog
timer(1000).subscribe(() => {
this.userService.getCurrentUser().subscribe((user) => {
@ -183,7 +183,7 @@ export default class BlackjackComponent implements OnInit {
this.blackjackService.doubleDown(this.currentGameId()!).subscribe({
next: (game) => {
this.updateGameState(game);
// Wait a bit to ensure the backend has finished processing
timer(1000).subscribe(() => {
this.userService.getCurrentUser().subscribe((user) => {
@ -196,7 +196,7 @@ export default class BlackjackComponent implements OnInit {
}
});
});
this.isActionInProgress.set(false);
},
error: (error) => {
@ -210,7 +210,7 @@ export default class BlackjackComponent implements OnInit {
onCloseGameResult(): void {
console.log('Closing game result dialog');
this.showGameResult.set(false);
// Refresh the balance when dialog is closed and update local state
this.userService.getCurrentUser().subscribe((user) => {
if (user) {

View file

@ -109,13 +109,13 @@ export default class SlotsComponent implements OnInit, OnDestroy {
next: (result) => {
setTimeout(() => {
this.slotResult.set(result);
if (result.status === 'win') {
this.userService.updateLocalBalance(result.amount);
}
this.userService.refreshCurrentUser();
this.isSpinning = false;
}, 1500);
},

View file

@ -21,7 +21,7 @@ export class UserService {
}
// Subscribe to auth service user updates
this.authService.userSubject.subscribe(user => {
this.authService.userSubject.subscribe((user) => {
this.currentUserSubject.next(user);
});
}