feat(slots): update balance handling on spin results

This commit is contained in:
Jan-Marlon Leibl 2025-05-07 17:47:34 +02:00
commit a3f34e960b
Signed by: jleibl
GPG key ID: 300B2F906DC6F1D5
2 changed files with 7 additions and 3 deletions

View file

@ -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);
}

View file

@ -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;
},
});