fix: correct blackjack PnL calculation and enhance UI
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:
syntaxbullet
2026-04-06 15:11:47 +02:00
parent 06c3891045
commit 034f2ead1c
4 changed files with 178 additions and 86 deletions

View File

@@ -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,