snapshot_poker_uiux_cleanup
This commit is contained in:
+79
-5
@@ -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 <t:${game.data.turnExpiresAt}:R>.`
|
||||
: "⏱️ 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: []
|
||||
});
|
||||
|
||||
@@ -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: []
|
||||
});
|
||||
|
||||
+22
-3
@@ -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(),
|
||||
|
||||
+19
-17
@@ -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
|
||||
)
|
||||
),
|
||||
|
||||
|
||||
+30
-2
@@ -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,7 +517,14 @@ function buildPokerTableEmbed(
|
||||
);
|
||||
|
||||
const stateLabel =
|
||||
publicGame.state ===
|
||||
"NEXT_HAND"
|
||||
? "🏆 HAND COMPLETE"
|
||||
: POKER_ACTIVE_STATES_FOR_DISPLAY.has(
|
||||
publicGame.state
|
||||
)
|
||||
? `🃏 ${publicGame.state.replaceAll("_", " ")}`
|
||||
: publicGame.state
|
||||
.replaceAll("_", " ");
|
||||
|
||||
const pot =
|
||||
@@ -517,6 +532,11 @@ function buildPokerTableEmbed(
|
||||
|
||||
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 <t:${publicGame.data.turnExpiresAt}:R>`
|
||||
`⏱️ **90-second turn** • Auto-folds <t:${publicGame.data.turnExpiresAt}:R>`
|
||||
);
|
||||
}
|
||||
|
||||
description.push(
|
||||
"━━━━━━━━━━━━━━━━━━"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -576,6 +601,9 @@ function buildPokerTableEmbed(
|
||||
if (
|
||||
publicGame.state ===
|
||||
"WAITING"
|
||||
||
|
||||
publicGame.state ===
|
||||
"NEXT_HAND"
|
||||
) {
|
||||
description.push(
|
||||
"",
|
||||
|
||||
Reference in New Issue
Block a user