feat(blackjack): refresh user balance on game state change
This commit is contained in:
parent
08b12d238e
commit
e983b21e07
7 changed files with 48 additions and 19 deletions
|
@ -82,8 +82,7 @@ export default class BlackjackComponent {
|
|||
|
||||
if (isGameOver) {
|
||||
console.log('Game is over, state:', game.state);
|
||||
this.refreshUserBalance();
|
||||
|
||||
this.userService.refreshCurrentUser();
|
||||
this.showGameResult.set(true);
|
||||
console.log('Game result dialog should be shown now');
|
||||
}
|
||||
|
@ -96,7 +95,7 @@ export default class BlackjackComponent {
|
|||
this.blackjackService.startGame(bet).subscribe({
|
||||
next: (game) => {
|
||||
this.updateGameState(game);
|
||||
this.refreshUserBalance();
|
||||
this.userService.refreshCurrentUser();
|
||||
this.isActionInProgress.set(false);
|
||||
},
|
||||
error: (error) => {
|
||||
|
@ -115,6 +114,9 @@ export default class BlackjackComponent {
|
|||
this.blackjackService.hit(this.currentGameId()!).subscribe({
|
||||
next: (game) => {
|
||||
this.updateGameState(game);
|
||||
if (game.state !== 'IN_PROGRESS') {
|
||||
this.userService.refreshCurrentUser();
|
||||
}
|
||||
this.isActionInProgress.set(false);
|
||||
},
|
||||
error: (error) => {
|
||||
|
@ -139,6 +141,7 @@ export default class BlackjackComponent {
|
|||
this.blackjackService.stand(this.currentGameId()!).subscribe({
|
||||
next: (game) => {
|
||||
this.updateGameState(game);
|
||||
this.userService.refreshCurrentUser();
|
||||
this.isActionInProgress.set(false);
|
||||
},
|
||||
error: (error) => {
|
||||
|
@ -163,6 +166,7 @@ export default class BlackjackComponent {
|
|||
this.blackjackService.doubleDown(this.currentGameId()!).subscribe({
|
||||
next: (game) => {
|
||||
this.updateGameState(game);
|
||||
this.userService.refreshCurrentUser();
|
||||
this.isActionInProgress.set(false);
|
||||
},
|
||||
error: (error) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue