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: []
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user