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

View file

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

View file

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