snapshot_poker_phase5

This commit is contained in:
DeSqBlocki
2026-09-08 21:49:43 +02:00
parent 6342c4569b
commit 1ef2295c07
9 changed files with 1462 additions and 18 deletions
+61
View File
@@ -6,6 +6,12 @@ const {
refreshPokerTableMessage
} = require("../utils/pokerDiscord");
const {
announcePokerHandProgress,
createPokerProfileContext,
recordPokerHandProfiles
} = require("../utils/pokerProfile");
const TURN_CHECK_INTERVAL =
5 * 1000;
@@ -91,6 +97,39 @@ async function processPokerTurns(
client,
result
);
if (
result.game
?.data
?.hand
?.state ===
"PAYOUT"
) {
try {
await recordPokerHandProfiles(
result.game
);
const context =
await createPokerProfileContext(
client,
result.game
);
if (context) {
await announcePokerHandProgress(
context,
result.game
);
}
}
catch (error) {
console.error(
`[PokerProfile] Timeout profile processing failed for ${result.game.gameId}:`,
error
);
}
}
}
}
}
@@ -169,6 +208,28 @@ async function recoverPoker(
client,
game
);
if (
game.data?.hand?.state ===
"PAYOUT"
) {
await recordPokerHandProfiles(
game
);
const context =
await createPokerProfileContext(
client,
game
);
if (context) {
await announcePokerHandProgress(
context,
game
);
}
}
}
catch (error) {
console.error(
-4
View File
@@ -3,10 +3,6 @@
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "node --test",
"test:poker": "node --test tests/pokerEngine.test.js tests/crumbPoker.test.js"
},
"repository": {
"type": "git",
"url": "https://git.desq-gaming.de/admin_rb/ShaiBot.git"
+26 -2
View File
@@ -474,9 +474,25 @@ async function clearCookieOperation(
userId,
operationId
) {
const cookies =
getCookieCollection();
if (
typeof operationId !==
"string"
||
!/^[A-Za-z0-9:_-]{1,160}$/.test(
operationId
)
) {
throw new Error(
"INVALID_COOKIE_OPERATION_ID"
);
}
const {
cookies
} =
getCollections();
const result =
await cookies.updateOne(
{
userId
@@ -489,6 +505,11 @@ async function clearCookieOperation(
}
);
/*
* Keep the Cookie document tidy once the final temporary
* idempotency marker has been cleared.
*/
await cookies.updateOne(
{
userId,
@@ -503,6 +524,9 @@ async function clearCookieOperation(
}
}
);
return result.modifiedCount ===
1;
}
+36
View File
@@ -8,6 +8,11 @@ const {
PokerEngineError
} = require("./pokerEngine");
const {
recordPokerActionProfile,
recordPokerHandProfiles
} = require("./pokerProfile");
/*
* ============================================================
* CONFIG
@@ -1965,6 +1970,37 @@ function createPokerService({
);
}
/*
* Profile/stat history is secondary to the authoritative
* Poker state. A profile failure must never invalidate a
* successfully committed table action or payout.
*/
try {
await recordPokerActionProfile(
nextGame,
userId,
action
);
if (
nextGame.data.hand
?.state ===
"PAYOUT"
) {
await recordPokerHandProfiles(
nextGame
);
}
}
catch (error) {
console.error(
`[PokerProfile] Failed to persist profile history for ${nextGame.gameId}:`,
error
);
}
return clone(nextGame);
}
+2
View File
@@ -127,6 +127,8 @@ function formatPokerError(
return (
known[error?.code]
??
known[error?.message]
??
error?.message
??
"The Poker action could not be completed."
+30
View File
@@ -9,6 +9,10 @@ const {
refreshPokerTableMessage
} = require("./pokerDiscord");
const {
announcePokerHandProgress
} = require("./pokerProfile");
async function executePokerAction(
interaction,
@@ -50,6 +54,19 @@ async function executePokerAction(
game
);
try {
await announcePokerHandProgress(
interaction,
game
);
}
catch (error) {
console.error(
`[PokerProfile] Failed to announce completed hand ${game.gameId}:`,
error
);
}
return interaction.editReply({
content:
typeof successText ===
@@ -145,6 +162,19 @@ async function executeMinimumRaise(
game
);
try {
await announcePokerHandProgress(
interaction,
game
);
}
catch (error) {
console.error(
`[PokerProfile] Failed to announce completed hand ${game.gameId}:`,
error
);
}
return interaction.editReply({
content:
`✅ ${type === "bet" ? "Bet" : "Raised to"} ${legal.minRaiseTo.toLocaleString()} 🍪`,
File diff suppressed because it is too large Load Diff
+2 -1
View File
@@ -754,7 +754,8 @@ async function auditProfileData(
"slots",
"blackjack",
"roulette",
"heist"
"heist",
"poker"
]
) {
const value =
+7 -1
View File
@@ -935,6 +935,9 @@ async function trackProfileEvent(
);
break;
case "profile_refresh":
break;
default:
return;
}
@@ -2041,7 +2044,8 @@ async function buildStatsEmbed(
["🎰 Slots", stats.games?.slots],
["🃏 Blackjack", stats.games?.blackjack],
["🎡 Roulette", stats.games?.roulette],
["🏦 Heist", stats.games?.heist]
["🏦 Heist", stats.games?.heist],
["♠️ Poker", stats.games?.poker]
].map(([name, game = {}]) => {
const played =
Number(game.played ?? 0);
@@ -2923,6 +2927,8 @@ function formatCategoryName(
"🎡 Roulette",
heist:
"🏦 Heist",
poker:
"♠️ Poker",
collector:
"🏆 Collector",
other: