fix: correct blackjack PnL calculation and enhance UI
Some checks failed
Deploy to Production / test (push) Failing after 35s
Some checks failed
Deploy to Production / test (push) Failing after 35s
- Fix incorrect PnL calculations where multipliers were treated as amounts - Add proper net profit calculation: (multiplier × bet) - bet - Update UI with gradient backgrounds, icons, and improved animations - Add slide-in and pulse-slow keyframe animations - Enhance dealer area with status-based styling - Improve action buttons with colored gradients and hover effects - Revise round result banner with better visual hierarchy
This commit is contained in:
@@ -194,12 +194,14 @@ function finishPlayerTurns(state: BlackjackState): BlackjackState {
|
||||
// First resolve the hands
|
||||
const resolvedHands = seat.hands.map(h => resolveHand(h, dealerHand));
|
||||
|
||||
// Then calculate PnL based on resolved hands
|
||||
// Calculate round payouts as multipliers
|
||||
const roundPayout = calculateRoundPayouts({ [id]: { ...seat, hands: resolvedHands } });
|
||||
const roundPayoutMoney = roundPayout[id] ?? 0;
|
||||
// Subtract the total bet amount to get net profit/loss
|
||||
const multiplier = roundPayout[id] ?? 0;
|
||||
// Calculate total bet amount for this player
|
||||
const roundBetTotal = seat.hands.reduce((sum, h) => sum + (h.bet * state.betAmount), 0);
|
||||
const roundNetPnl = roundPayoutMoney ? roundPayoutMoney - roundBetTotal : -roundBetTotal;
|
||||
// Calculate actual payout amount and net profit
|
||||
const roundPayoutAmount = Math.round(multiplier * state.betAmount);
|
||||
const roundNetPnl = roundBetTotal > 0 ? roundPayoutAmount - roundBetTotal : 0;
|
||||
|
||||
resolvedSeats[id] = {
|
||||
...seat,
|
||||
|
||||
Reference in New Issue
Block a user