fix: Correct PnL calculation by using betAmount in net profit computation
Some checks failed
Deploy to Production / test (push) Failing after 34s

- Add betAmount field to BlackjackState to track the base bet
- Fix finishPlayerTurns: multiply hand.bet by state.betAmount for actual money bets
- Fix GameServer: roundPayouts are already gross payouts (not multipliers)
- Update cumulative PnL calculation to correctly subtract actual bet amount
- Add betAmount support to riggedState test helper
This commit is contained in:
syntaxbullet
2026-04-06 14:50:40 +02:00
parent f09cbe6939
commit 06c3891045
4 changed files with 13 additions and 8 deletions

View File

@@ -95,10 +95,9 @@ export class GameServer {
const gameName = gameRegistry.get(room.gameSlug)?.name ?? "Game";
const payoutDetails: Record<string, { net: number }> = {};
for (const [playerId, multiplier] of Object.entries(roundPayouts)) {
if (multiplier <= 0) continue;
const grossPayout = Math.floor(betAmount * multiplier);
const netProfit = grossPayout - betAmount; // Calculate net profit (gross payout minus original bet)
for (const [playerId, grossPayout] of Object.entries(roundPayouts)) {
// roundPayout is already the gross payout amount (not a multiplier)
const netProfit = Math.floor(grossPayout) - betAmount; // Calculate net profit (gross payout minus original bet)
try {
await economyService.modifyUserBalance(
playerId,