snapshot_poker_uiux_cleanup
This commit is contained in:
+79
-5
@@ -40,17 +40,91 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const cards =
|
const service =
|
||||||
await getPokerService()
|
getPokerService();
|
||||||
.viewCards({
|
|
||||||
|
const [
|
||||||
|
cards,
|
||||||
|
game
|
||||||
|
] =
|
||||||
|
await Promise.all([
|
||||||
|
service.viewCards({
|
||||||
gameId,
|
gameId,
|
||||||
userId:
|
userId:
|
||||||
interaction.user.id
|
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({
|
await interaction.editReply({
|
||||||
content:
|
content:
|
||||||
`🃏 Your cards: **${cards.map(cardToString).join(" ")}**`,
|
lines.join("\n"),
|
||||||
embeds: [],
|
embeds: [],
|
||||||
components: []
|
components: []
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ module.exports = {
|
|||||||
|
|
||||||
return interaction.editReply({
|
return interaction.editReply({
|
||||||
content:
|
content:
|
||||||
`✅ Hand **#${game.data.handNumber}** started.`,
|
`✅ Hand **#${game.data.handNumber}** started. Cards have been dealt — use **🃏 Cards** to view your hand.`,
|
||||||
embeds: [],
|
embeds: [],
|
||||||
components: []
|
components: []
|
||||||
});
|
});
|
||||||
|
|||||||
+22
-3
@@ -30,16 +30,16 @@ const POKER_MAX_PLAYERS =
|
|||||||
6;
|
6;
|
||||||
|
|
||||||
const POKER_DEFAULT_SMALL_BLIND =
|
const POKER_DEFAULT_SMALL_BLIND =
|
||||||
100;
|
10;
|
||||||
|
|
||||||
const POKER_DEFAULT_BIG_BLIND =
|
const POKER_DEFAULT_BIG_BLIND =
|
||||||
200;
|
20;
|
||||||
|
|
||||||
const POKER_DEFAULT_BUY_IN =
|
const POKER_DEFAULT_BUY_IN =
|
||||||
1000;
|
1000;
|
||||||
|
|
||||||
const POKER_TURN_TIMEOUT =
|
const POKER_TURN_TIMEOUT =
|
||||||
30;
|
90;
|
||||||
|
|
||||||
const POKER_LOBBY_TIMEOUT =
|
const POKER_LOBBY_TIMEOUT =
|
||||||
15 * 60;
|
15 * 60;
|
||||||
@@ -492,6 +492,17 @@ function syncCompletedHand(
|
|||||||
game.data.turnExpiresAt =
|
game.data.turnExpiresAt =
|
||||||
null;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1707,6 +1718,14 @@ function createPokerService({
|
|||||||
nextGame.data.handCompletedAt =
|
nextGame.data.handCompletedAt =
|
||||||
null;
|
null;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Lobby expiry only applies while waiting between
|
||||||
|
* hands. Active hands are governed by turn timers.
|
||||||
|
*/
|
||||||
|
|
||||||
|
nextGame.data.lobbyExpiresAt =
|
||||||
|
null;
|
||||||
|
|
||||||
applyTurnDeadline(
|
applyTurnDeadline(
|
||||||
nextGame,
|
nextGame,
|
||||||
now(),
|
now(),
|
||||||
|
|||||||
+19
-17
@@ -115,12 +115,12 @@ function buildMainMenuEmbed(
|
|||||||
"### 🎡 Roulette",
|
"### 🎡 Roulette",
|
||||||
"Bet on Red, Black, Odd, Even, or Zero.",
|
"Bet on Red, Black, Odd, Even, or Zero.",
|
||||||
"",
|
"",
|
||||||
"### 🏦 Vault Heist",
|
|
||||||
"Attempt to breach ShaiBot's Cookie Vault.",
|
|
||||||
"",
|
|
||||||
"### ♠️ Poker",
|
"### ♠️ Poker",
|
||||||
"Create or join a 2–6 player Cookie Poker table.",
|
"Create or join a 2–6 player Cookie Poker table.",
|
||||||
"",
|
"",
|
||||||
|
"### 🏦 Vault Heist",
|
||||||
|
"Attempt to breach ShaiBot's Cookie Vault.",
|
||||||
|
"",
|
||||||
"### 🛟 Bankruptcy",
|
"### 🛟 Bankruptcy",
|
||||||
"At exactly 0 Cookies, claim a 1,000 Cookie starter kit."
|
"At exactly 0 Cookies, claim a 1,000 Cookie starter kit."
|
||||||
].join("\n")
|
].join("\n")
|
||||||
@@ -184,19 +184,6 @@ function buildMainMenuButtons() {
|
|||||||
ButtonStyle.Primary
|
ButtonStyle.Primary
|
||||||
),
|
),
|
||||||
|
|
||||||
new ButtonBuilder()
|
|
||||||
.setCustomId(
|
|
||||||
"crumbSaucerHeist"
|
|
||||||
)
|
|
||||||
.setLabel(
|
|
||||||
"Vault Heist"
|
|
||||||
)
|
|
||||||
.setEmoji(
|
|
||||||
"🏦"
|
|
||||||
)
|
|
||||||
.setStyle(
|
|
||||||
ButtonStyle.Danger
|
|
||||||
),
|
|
||||||
|
|
||||||
new ButtonBuilder()
|
new ButtonBuilder()
|
||||||
.setCustomId(
|
.setCustomId(
|
||||||
@@ -209,7 +196,22 @@ function buildMainMenuButtons() {
|
|||||||
"♠️"
|
"♠️"
|
||||||
)
|
)
|
||||||
.setStyle(
|
.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 =
|
const POKER_CARD_RESPONSE_LIFETIME =
|
||||||
5000;
|
5000;
|
||||||
|
|
||||||
|
const POKER_ACTIVE_STATES_FOR_DISPLAY =
|
||||||
|
new Set([
|
||||||
|
"PREFLOP",
|
||||||
|
"FLOP",
|
||||||
|
"TURN",
|
||||||
|
"RIVER"
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
function getPokerGameIdFromInteraction(
|
function getPokerGameIdFromInteraction(
|
||||||
interaction
|
interaction
|
||||||
@@ -509,7 +517,14 @@ function buildPokerTableEmbed(
|
|||||||
);
|
);
|
||||||
|
|
||||||
const stateLabel =
|
const stateLabel =
|
||||||
|
publicGame.state ===
|
||||||
|
"NEXT_HAND"
|
||||||
|
? "🏆 HAND COMPLETE"
|
||||||
|
: POKER_ACTIVE_STATES_FOR_DISPLAY.has(
|
||||||
publicGame.state
|
publicGame.state
|
||||||
|
)
|
||||||
|
? `🃏 ${publicGame.state.replaceAll("_", " ")}`
|
||||||
|
: publicGame.state
|
||||||
.replaceAll("_", " ");
|
.replaceAll("_", " ");
|
||||||
|
|
||||||
const pot =
|
const pot =
|
||||||
@@ -517,6 +532,11 @@ function buildPokerTableEmbed(
|
|||||||
|
|
||||||
const description = [
|
const description = [
|
||||||
`**State:** ${stateLabel}`,
|
`**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()} 🍪`,
|
`**Blinds:** ${publicGame.data.smallBlind.toLocaleString()} / ${publicGame.data.bigBlind.toLocaleString()} 🍪`,
|
||||||
`**Buy-In:** ${publicGame.data.buyIn.toLocaleString()} 🍪`,
|
`**Buy-In:** ${publicGame.data.buyIn.toLocaleString()} 🍪`,
|
||||||
`**Pot:** ${pot.toLocaleString()} 🍪`,
|
`**Pot:** ${pot.toLocaleString()} 🍪`,
|
||||||
@@ -547,16 +567,21 @@ function buildPokerTableEmbed(
|
|||||||
if (current) {
|
if (current) {
|
||||||
description.push(
|
description.push(
|
||||||
"",
|
"",
|
||||||
`### <@${current.userId}>'s turn`
|
"━━━━━━━━━━━━━━━━━━",
|
||||||
|
`### 👉 CURRENT TURN: <@${current.userId}>`
|
||||||
);
|
);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
publicGame.data.turnExpiresAt
|
publicGame.data.turnExpiresAt
|
||||||
) {
|
) {
|
||||||
description.push(
|
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 (
|
if (
|
||||||
publicGame.state ===
|
publicGame.state ===
|
||||||
"WAITING"
|
"WAITING"
|
||||||
|
||
|
||||||
|
publicGame.state ===
|
||||||
|
"NEXT_HAND"
|
||||||
) {
|
) {
|
||||||
description.push(
|
description.push(
|
||||||
"",
|
"",
|
||||||
|
|||||||
Reference in New Issue
Block a user