mirror of
https://github.com/cassoule/flopobot_v2.git
synced 2026-03-18 21:40:27 +01:00
mouais
This commit is contained in:
@@ -124,7 +124,7 @@ export function blackjackRoutes(io) {
|
||||
bank,
|
||||
currentBet: 0,
|
||||
inRound: false,
|
||||
hands: [{ cards: [], stood: false, busted: false, doubled: false, surrendered: false, hasActed: false }],
|
||||
hands: [{ cards: [], stood: false, busted: false, doubled: false, surrendered: false, hasActed: false, bet: 0 }],
|
||||
activeHand: 0,
|
||||
joined_at: Date.now(),
|
||||
msgId: null,
|
||||
@@ -231,6 +231,7 @@ export function blackjackRoutes(io) {
|
||||
}
|
||||
|
||||
p.currentBet = bet;
|
||||
p.hands[p.activeHand].bet = bet;
|
||||
emitToast({ type: "player-bet", userId, amount: bet });
|
||||
emitUpdate("bet-placed", snapshot(room));
|
||||
return res.status(200).json({ message: "bet-accepted" });
|
||||
@@ -247,15 +248,32 @@ export function blackjackRoutes(io) {
|
||||
if (action === "double" && !room.settings.fakeMoney) {
|
||||
const userDB = getUser.get(userId);
|
||||
const coins = userDB?.coins ?? 0;
|
||||
if (coins < p.currentBet) return res.status(403).json({ message: "insufficient-funds-for-double" });
|
||||
updateUserCoins.run({ id: userId, coins: coins - p.currentBet });
|
||||
const hand = p.hands[p.activeHand];
|
||||
if (coins < hand.bet) return res.status(403).json({ message: "insufficient-funds-for-double" });
|
||||
updateUserCoins.run({ id: userId, coins: coins - hand.bet });
|
||||
insertLog.run({
|
||||
id: `${userId}-blackjack-${Date.now()}`,
|
||||
user_id: userId, target_user_id: null,
|
||||
action: 'BLACKJACK_DOUBLE',
|
||||
coins_amount: -p.currentBet, user_new_amount: coins - p.currentBet,
|
||||
coins_amount: -hand.bet, user_new_amount: coins - hand.bet,
|
||||
});
|
||||
p.bank = coins - p.currentBet;
|
||||
p.bank = coins - hand.bet;
|
||||
// effective bet size is handled in settlement via hand.doubled flag
|
||||
}
|
||||
|
||||
if (action === "split" && !room.settings.fakeMoney) {
|
||||
const userDB = getUser.get(userId);
|
||||
const coins = userDB?.coins ?? 0;
|
||||
const hand = p.hands[p.activeHand];
|
||||
if (coins < hand.bet) return res.status(403).json({ message: "insufficient-funds-for-split" });
|
||||
updateUserCoins.run({ id: userId, coins: coins - hand.bet });
|
||||
insertLog.run({
|
||||
id: `${userId}-blackjack-${Date.now()}`,
|
||||
user_id: userId, target_user_id: null,
|
||||
action: 'BLACKJACK_SPLIT',
|
||||
coins_amount: -hand.bet, user_new_amount: coins - hand.bet,
|
||||
});
|
||||
p.bank = coins - hand.bet;
|
||||
// effective bet size is handled in settlement via hand.doubled flag
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user