snapshot_poker_phase5
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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"
|
||||
|
||||
+36
-12
@@ -474,20 +474,41 @@ 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"
|
||||
);
|
||||
}
|
||||
|
||||
await cookies.updateOne(
|
||||
{
|
||||
userId
|
||||
},
|
||||
{
|
||||
$pull: {
|
||||
appliedCookieOperations:
|
||||
operationId
|
||||
const {
|
||||
cookies
|
||||
} =
|
||||
getCollections();
|
||||
|
||||
const result =
|
||||
await cookies.updateOne(
|
||||
{
|
||||
userId
|
||||
},
|
||||
{
|
||||
$pull: {
|
||||
appliedCookieOperations:
|
||||
operationId
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
);
|
||||
|
||||
/*
|
||||
* Keep the Cookie document tidy once the final temporary
|
||||
* idempotency marker has been cleared.
|
||||
*/
|
||||
|
||||
await cookies.updateOne(
|
||||
{
|
||||
@@ -503,6 +524,9 @@ async function clearCookieOperation(
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
return result.modifiedCount ===
|
||||
1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -127,6 +127,8 @@ function formatPokerError(
|
||||
return (
|
||||
known[error?.code]
|
||||
??
|
||||
known[error?.message]
|
||||
??
|
||||
error?.message
|
||||
??
|
||||
"The Poker action could not be completed."
|
||||
|
||||
@@ -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
@@ -754,7 +754,8 @@ async function auditProfileData(
|
||||
"slots",
|
||||
"blackjack",
|
||||
"roulette",
|
||||
"heist"
|
||||
"heist",
|
||||
"poker"
|
||||
]
|
||||
) {
|
||||
const value =
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user