fix: Correct PnL calculation to show net profit instead of gross payout
Some checks failed
Deploy to Production / test (push) Failing after 36s

- GameServer.ts: Calculate netProfit = grossPayout - betAmount and send as 'net'
  instead of sending gross payout labeled as net
- BlackjackGame.tsx: Fix PnL calculations to use net profit correctly
  - Hand win/blackjack now shows net profit (payout minus bet)
  - Lose correctly shows negative bet amount
  - Round result banner displays roundNet (net profit) with appropriate colors
- Remove dead code (myPnl variable that was calculated but never used)
- Update color coding: green for profit, red for loss, blue for zero balance
This commit is contained in:
syntaxbullet
2026-04-06 14:42:18 +02:00
parent 966bad98d3
commit cd9e1e7242
2 changed files with 11 additions and 20 deletions

View File

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