From 82cef1b34a092700d580d233359c980a8daaef66 Mon Sep 17 00:00:00 2001 From: DeSqBlocki Date: Tue, 8 Sep 2026 20:51:58 +0200 Subject: [PATCH] snapshot_poker_uiux_cleanup --- buttons/poker/cards.js | 84 +++++++++++++++++++++++++++++++++++++++--- buttons/poker/start.js | 2 +- utils/crumbPoker.js | 25 +++++++++++-- utils/crumbSaucer.js | 36 +++++++++--------- utils/pokerDiscord.js | 38 ++++++++++++++++--- 5 files changed, 154 insertions(+), 31 deletions(-) diff --git a/buttons/poker/cards.js b/buttons/poker/cards.js index b66ed69..cada53b 100644 --- a/buttons/poker/cards.js +++ b/buttons/poker/cards.js @@ -40,17 +40,91 @@ module.exports = { } try { - const cards = - await getPokerService() - .viewCards({ + const service = + getPokerService(); + + const [ + cards, + game + ] = + await Promise.all([ + service.viewCards({ gameId, userId: interaction.user.id - }); + }), + service.getTable({ + gameId + }) + ]); + + const hand = + game.data.hand; + + const player = + game.data.players.find( + candidate => + String(candidate.userId) === + String(interaction.user.id) + ); + + const currentPlayer = + hand?.players?.find( + candidate => + candidate.seat === + hand.currentSeat + ); + + const isYourTurn = + Boolean( + player + && + hand + && + hand.currentSeat === + player.seat + ); + + const communityCards = + hand?.communityCards ?? []; + + const lines = [ + "### 🃏 Your Cards", + `**${cards.map(cardToString).join(" ")}**`, + "", + "**Community:** " + + (communityCards.length + ? communityCards + .map(cardToString) + .join(" ") + : "No community cards yet."), + "" + ]; + + if (isYourTurn) { + lines.push( + "👉 **It's YOUR TURN.**", + game.data.turnExpiresAt + ? `⏱️ Auto-folds .` + : "⏱️ Your turn timer is active." + ); + } + + else if (currentPlayer) { + lines.push( + `Waiting for <@${currentPlayer.userId}> to act.` + ); + } + + else { + lines.push( + "The hand is not currently waiting on a player action." + ); + } await interaction.editReply({ content: - `🃏 Your cards: **${cards.map(cardToString).join(" ")}**`, + lines.join("\n"), embeds: [], components: [] }); diff --git a/buttons/poker/start.js b/buttons/poker/start.js index bf3b714..4da475f 100644 --- a/buttons/poker/start.js +++ b/buttons/poker/start.js @@ -51,7 +51,7 @@ module.exports = { return interaction.editReply({ content: - `✅ Hand **#${game.data.handNumber}** started.`, + `✅ Hand **#${game.data.handNumber}** started. Cards have been dealt — use **🃏 Cards** to view your hand.`, embeds: [], components: [] }); diff --git a/utils/crumbPoker.js b/utils/crumbPoker.js index 5b7b727..e368fe9 100644 --- a/utils/crumbPoker.js +++ b/utils/crumbPoker.js @@ -30,16 +30,16 @@ const POKER_MAX_PLAYERS = 6; const POKER_DEFAULT_SMALL_BLIND = - 100; + 10; const POKER_DEFAULT_BIG_BLIND = - 200; + 20; const POKER_DEFAULT_BUY_IN = 1000; const POKER_TURN_TIMEOUT = - 30; + 90; const POKER_LOBBY_TIMEOUT = 15 * 60; @@ -492,6 +492,17 @@ function syncCompletedHand( game.data.turnExpiresAt = null; + /* + * A completed hand starts a fresh between-hand lobby + * window. Do not inherit the original table-creation + * expiry, otherwise a healthy table can close shortly + * after a long hand finishes. + */ + + game.data.lobbyExpiresAt = + now + + POKER_LOBBY_TIMEOUT; + return true; } @@ -1707,6 +1718,14 @@ function createPokerService({ nextGame.data.handCompletedAt = null; + /* + * Lobby expiry only applies while waiting between + * hands. Active hands are governed by turn timers. + */ + + nextGame.data.lobbyExpiresAt = + null; + applyTurnDeadline( nextGame, now(), diff --git a/utils/crumbSaucer.js b/utils/crumbSaucer.js index 6b665d6..eea57a0 100644 --- a/utils/crumbSaucer.js +++ b/utils/crumbSaucer.js @@ -115,12 +115,12 @@ function buildMainMenuEmbed( "### 🎡 Roulette", "Bet on Red, Black, Odd, Even, or Zero.", "", - "### 🏦 Vault Heist", - "Attempt to breach ShaiBot's Cookie Vault.", - "", "### ♠️ Poker", "Create or join a 2–6 player Cookie Poker table.", "", + "### 🏦 Vault Heist", + "Attempt to breach ShaiBot's Cookie Vault.", + "", "### 🛟 Bankruptcy", "At exactly 0 Cookies, claim a 1,000 Cookie starter kit." ].join("\n") @@ -184,19 +184,6 @@ function buildMainMenuButtons() { ButtonStyle.Primary ), - new ButtonBuilder() - .setCustomId( - "crumbSaucerHeist" - ) - .setLabel( - "Vault Heist" - ) - .setEmoji( - "🏦" - ) - .setStyle( - ButtonStyle.Danger - ), new ButtonBuilder() .setCustomId( @@ -209,7 +196,22 @@ function buildMainMenuButtons() { "♠️" ) .setStyle( - ButtonStyle.Success + ButtonStyle.Primary + ), + + + new ButtonBuilder() + .setCustomId( + "crumbSaucerHeist" + ) + .setLabel( + "Vault Heist" + ) + .setEmoji( + "🏦" + ) + .setStyle( + ButtonStyle.Danger ) ), diff --git a/utils/pokerDiscord.js b/utils/pokerDiscord.js index fa7be41..a93fce7 100644 --- a/utils/pokerDiscord.js +++ b/utils/pokerDiscord.js @@ -27,6 +27,14 @@ const POKER_TABLE_FOOTER_PREFIX = const POKER_CARD_RESPONSE_LIFETIME = 5000; +const POKER_ACTIVE_STATES_FOR_DISPLAY = + new Set([ + "PREFLOP", + "FLOP", + "TURN", + "RIVER" + ]); + function getPokerGameIdFromInteraction( interaction @@ -509,14 +517,26 @@ function buildPokerTableEmbed( ); const stateLabel = - publicGame.state - .replaceAll("_", " "); + publicGame.state === + "NEXT_HAND" + ? "🏆 HAND COMPLETE" + : POKER_ACTIVE_STATES_FOR_DISPLAY.has( + publicGame.state + ) + ? `🃏 ${publicGame.state.replaceAll("_", " ")}` + : publicGame.state + .replaceAll("_", " "); const pot = hand?.pot ?? 0; const description = [ `**State:** ${stateLabel}`, + hand && POKER_ACTIVE_STATES_FOR_DISPLAY.has( + publicGame.state + ) + ? `**Hand #${publicGame.data.handNumber}** • 🃏 Cards have been dealt. Use **Cards** to view your hand.` + : null, `**Blinds:** ${publicGame.data.smallBlind.toLocaleString()} / ${publicGame.data.bigBlind.toLocaleString()} 🍪`, `**Buy-In:** ${publicGame.data.buyIn.toLocaleString()} 🍪`, `**Pot:** ${pot.toLocaleString()} 🍪`, @@ -547,16 +567,21 @@ function buildPokerTableEmbed( if (current) { description.push( "", - `### <@${current.userId}>'s turn` + "━━━━━━━━━━━━━━━━━━", + `### 👉 CURRENT TURN: <@${current.userId}>` ); if ( publicGame.data.turnExpiresAt ) { description.push( - `⏱️ Auto-folds ` + `⏱️ **90-second turn** • Auto-folds ` ); } + + description.push( + "━━━━━━━━━━━━━━━━━━" + ); } } @@ -575,7 +600,10 @@ function buildPokerTableEmbed( if ( publicGame.state === - "WAITING" + "WAITING" + || + publicGame.state === + "NEXT_HAND" ) { description.push( "",