feat(slots): update balance handling on spin results
This commit is contained in:
parent
93c5dc7fe3
commit
a3f34e960b
2 changed files with 7 additions and 3 deletions
|
@ -54,12 +54,13 @@ public class SlotService {
|
|||
SpinResult spinResult = new SpinResult();
|
||||
spinResult.setStatus(status.name().toLowerCase());
|
||||
|
||||
this.balanceService.subtractFunds(user, betAmount);
|
||||
|
||||
if (status == Status.WIN) {
|
||||
BigDecimal winAmount = betAmount.multiply(winSymbol.getPayoutMultiplier());
|
||||
this.balanceService.addFunds(user, winAmount);
|
||||
spinResult.setAmount(winAmount);
|
||||
} else {
|
||||
this.balanceService.subtractFunds(user, betAmount);
|
||||
spinResult.setAmount(betAmount);
|
||||
}
|
||||
|
||||
|
|
|
@ -114,12 +114,15 @@ export default class SlotsComponent implements OnInit, OnDestroy {
|
|||
this.userService.updateLocalBalance(result.amount);
|
||||
}
|
||||
|
||||
this.userService.refreshCurrentUser();
|
||||
|
||||
this.isSpinning = false;
|
||||
}, 1500);
|
||||
},
|
||||
error: (err) => {
|
||||
console.error('Error spinning slot machine:', err);
|
||||
this.userService.updateLocalBalance(betAmount);
|
||||
this.userService.refreshCurrentUser();
|
||||
this.isSpinning = false;
|
||||
},
|
||||
});
|
||||
|
|
Reference in a new issue