fix(games): skip upfront bet deduction for per-round betting games
Some checks failed
Deploy to Production / test (push) Failing after 35s

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) <noreply@anthropic.com>
This commit is contained in:
syntaxbullet
2026-04-06 12:54:21 +02:00
parent a36c05994c
commit 96eba8270c

View File

@@ -395,6 +395,18 @@ export class GameServer {
): Promise<void> {
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)];