diff --git a/api/src/games/GameServer.ts b/api/src/games/GameServer.ts index 1689b09..b6ff568 100644 --- a/api/src/games/GameServer.ts +++ b/api/src/games/GameServer.ts @@ -97,15 +97,16 @@ export class GameServer { for (const [playerId, multiplier] of Object.entries(roundPayouts)) { if (multiplier <= 0) continue; - const amount = Math.floor(betAmount * multiplier); + const grossPayout = Math.floor(betAmount * multiplier); + const netProfit = grossPayout - betAmount; // Calculate net profit (gross payout minus original bet) try { await economyService.modifyUserBalance( playerId, - BigInt(amount), + BigInt(grossPayout), TransactionType.GAME_WIN, `${gameName} round payout (room ${roomId.slice(0, 8)})`, ); - payoutDetails[playerId] = { net: amount }; + payoutDetails[playerId] = { net: netProfit }; } catch (err) { logger.error("web", `Round payout failed for ${playerId} in room ${roomId}: ${err}`); } diff --git a/panel/src/games/blackjack/BlackjackGame.tsx b/panel/src/games/blackjack/BlackjackGame.tsx index 6f88f8a..a71d3a7 100644 --- a/panel/src/games/blackjack/BlackjackGame.tsx +++ b/panel/src/games/blackjack/BlackjackGame.tsx @@ -211,13 +211,13 @@ function Seat({ seat, playerName, isMe, isActivePlayer, activeHandIdx, betAmount const hasHands = seat.hands.length > 0; const compact = seat.hands.length > 2; - // Calculate current round PnL for the display + // Calculate current round PnL for the display (only needed before results are shown) const currentRoundPnl = seat.hands.reduce((sum, h) => { if (!h.result) return sum; // Not yet resolved const handWin = h.bet * betAmount; - if (h.result === "win" || h.result === "blackjack") return sum + handWin; - if (h.result === "push") return sum; // Push returns bet - return sum - handWin; // Lose + if (h.result === "win" || h.result === "blackjack") return sum + (handWin - betAmount); // Net profit + if (h.result === "push") return sum; // Push returns bet, so net is 0 + return sum - betAmount; // Lose loses the bet amount }, 0); const totalPnl = seat.cumulativePnl + currentRoundPnl; @@ -364,11 +364,11 @@ function RoundResultBanner({ roundNumber, roundResult, myPlayerId, betAmount, my