fix: Correct PnL calculation to show net profit instead of gross payout
Some checks failed
Deploy to Production / test (push) Failing after 36s
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:
@@ -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}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user