From 96eba8270c41fe3ef5a71b6b26af547684d47ff4 Mon Sep 17 00:00:00 2001 From: syntaxbullet Date: Mon, 6 Apr 2026 12:54:21 +0200 Subject: [PATCH] fix(games): skip upfront bet deduction for per-round betting games Games with getActionCost (like blackjack) handle bet deductions per-round via place_bet actions. The old deductBetsAndStart was also charging at game start, causing double-deduction: wins netted zero and losses doubled. Co-Authored-By: Claude Opus 4.6 (1M context) --- api/src/games/GameServer.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/api/src/games/GameServer.ts b/api/src/games/GameServer.ts index d507cef..1689b09 100644 --- a/api/src/games/GameServer.ts +++ b/api/src/games/GameServer.ts @@ -395,6 +395,18 @@ export class GameServer { ): Promise { const room = this.roomManager.getRoom(roomId); if (!room || room.betsPending) return; + + // Games with getActionCost handle per-round betting themselves (e.g., blackjack). + // Skip the upfront deduction — just start the game. + const plugin = gameRegistry.get(room.gameSlug); + if (plugin?.getActionCost) { + const startResult = this.roomManager.startGame(roomId); + if (!startResult.ok) { + triggeringWs.send(JSON.stringify({ type: "ERROR", message: startResult.error })); + } + return; + } + room.betsPending = true; const uniquePlayers = [...new Set(playerIds)];