added new logic to the new rewards

This commit is contained in:
DeSqBlocki
2026-08-23 00:43:43 +02:00
parent 4d858554be
commit 425686ec40
15 changed files with 1644 additions and 2662 deletions
+6 -6
View File
@@ -27,30 +27,30 @@ const HEIST_METHODS = {
baseChance: 0.65,
minStealPercent: 0.01,
maxStealPercent: 0.03,
maxStealAmount: 5000,
maxStealAmount: 1500,
minPenaltyPercent: 0.01,
maxPenaltyPercent: 0.04,
maxPenaltyAmount: 1500
maxPenaltyAmount: 750
},
Hack: {
baseChance: 0.45,
minStealPercent: 0.03,
maxStealPercent: 0.06,
maxStealAmount: 12500,
maxStealAmount: 3500,
minPenaltyPercent: 0.03,
maxPenaltyPercent: 0.07,
maxPenaltyAmount: 4000
maxPenaltyAmount: 2000
},
Smash: {
baseChance: 0.25,
minStealPercent: 0.06,
maxStealPercent: 0.12,
maxStealAmount: 25000,
maxStealAmount: 7500,
minPenaltyPercent: 0.06,
maxPenaltyPercent: 0.12,
maxPenaltyAmount: 10000
maxPenaltyAmount: 5000
}
};
+80 -10
View File
@@ -18,7 +18,8 @@ const {
} = require("./cookieEconomy");
const {
recordGameOutcome
recordGameOutcome,
trackProfileEvent
} = require("./profileSystem");
const GAME_COLLECTION =
@@ -112,7 +113,9 @@ async function startBlackjack(
interaction,
bet,
allowCustomBet = false,
allIn = false
source = "normal",
previousAllIn = false,
previousBet = 0
) {
if (
!allowCustomBet &&
@@ -196,6 +199,9 @@ async function startBlackjack(
getCookieBalance(houseId)
]);
const allIn =
bet === playerBalance;
if (playerBalance < bet) {
return temporaryEphemeralReply(
interaction,
@@ -276,6 +282,11 @@ async function startBlackjack(
doubled:
false,
allIn,
vaultAtBet:
playerBalance,
source,
previousAllIn,
previousBet,
deck,
playerCards,
dealerCards,
@@ -285,6 +296,20 @@ async function startBlackjack(
await games.insertOne(game);
await trackProfileEvent(
interaction,
playerId,
{
type: "game_start",
game: "blackjack",
source,
bet,
allIn,
previousAllIn,
previousBet
}
);
const playerBlackjack =
isBlackjack(playerCards);
@@ -370,7 +395,7 @@ async function startBlackjackAllIn(
interaction,
balance,
true,
true
"all_in"
);
}
@@ -405,6 +430,9 @@ async function runBlackjackBack(
const bet =
Number(parts[2]);
const previousAllIn =
parts[3] === "1";
if (
ownerId !==
interaction.user.id
@@ -435,7 +463,9 @@ async function runBlackjackBack(
interaction,
bet,
true,
false
"run_it_back",
previousAllIn,
bet
);
}
@@ -803,6 +833,32 @@ async function finishBlackjack(
game,
result
) {
const { db } = getCollections();
const claim = await db
.collection(GAME_COLLECTION)
.updateOne(
{
gameId: game.gameId,
state: "Playing"
},
{
$set: {
state: "Resolving"
}
}
);
if (claim.modifiedCount !== 1) {
return temporaryEphemeralReply(
interaction,
{
content:
"This Blackjack hand is already being resolved."
}
);
}
const houseId =
interaction.client.user.id;
@@ -845,6 +901,23 @@ async function finishBlackjack(
`[Blackjack] House cannot cover payout ${payout} for ${game.userId}`
);
await db
.collection(GAME_COLLECTION)
.updateOne(
{
gameId: game.gameId,
state: "Resolving"
},
{
$set: {
state: "Finished",
result: "PayoutError",
payout: 0,
finishedAt: getUnixTime()
}
}
);
return interaction.update({
embeds: [
new EmbedBuilder()
@@ -856,7 +929,7 @@ async function finishBlackjack(
)
.setFooter({
text:
`crumbBlackjackResult:${game.userId}:${game.originalBet}`
`crumbBlackjackResult:${game.userId}:${game.originalBet}:${game.allIn ? 1 : 0}`
})
],
components:
@@ -871,9 +944,6 @@ async function finishBlackjack(
);
}
const { db } =
getCollections();
await db
.collection(
GAME_COLLECTION
@@ -883,7 +953,7 @@ async function finishBlackjack(
gameId:
game.gameId,
state:
"Playing"
"Resolving"
},
{
$set: {
@@ -1010,7 +1080,7 @@ async function finishBlackjack(
)
.setFooter({
text:
`crumbBlackjackResult:${game.userId}:${game.originalBet}`
`crumbBlackjackResult:${game.userId}:${game.originalBet}:${game.allIn ? 1 : 0}`
});
return interaction.update({
+37 -9
View File
@@ -12,7 +12,8 @@ const {
} = require("./cookieEconomy");
const {
recordGameOutcome
recordGameOutcome,
trackProfileEvent
} = require("./profileSystem");
const ROULETTE_BETS = [
@@ -206,7 +207,10 @@ async function startRouletteAllIn(
async function showRouletteChoices(
interaction,
bet,
allIn = false
requestedAllIn = false,
source = "normal",
previousAllIn = false,
previousBet = 0
) {
if (
!Number.isSafeInteger(bet) ||
@@ -262,7 +266,7 @@ async function showRouletteChoices(
})
.setFooter({
text:
`crumbRouletteBet:${interaction.user.id}:${bet}:${allIn ? 1 : 0}`
`crumbRouletteBet:${interaction.user.id}:${bet}:${requestedAllIn ? 1 : 0}:${source}:${previousAllIn ? 1 : 0}:${previousBet}`
});
return interaction.update({
@@ -303,6 +307,9 @@ async function runRouletteBack(
const bet =
Number(parts[2]);
const previousAllIn =
parts[3] === "1";
if (
ownerId !==
interaction.user.id
@@ -383,8 +390,14 @@ async function playRoulette(
const bet =
Number(parts[2]);
const allIn =
parts[3] === "1";
const source =
parts[4] || "normal";
const previousAllIn =
parts[5] === "1";
const previousBet =
Number(parts[6] ?? 0);
if (
ownerId !==
@@ -476,6 +489,23 @@ async function playRoulette(
throw error;
}
const allIn =
bet === playerBalance;
await trackProfileEvent(
interaction,
playerId,
{
type: "game_start",
game: "roulette",
source,
bet,
allIn,
previousAllIn,
previousBet
}
);
await interaction.update({
embeds: [
buildSpinEmbed(
@@ -594,9 +624,7 @@ async function playRoulette(
won &&
choiceKey ===
"Zero",
allIn:
won &&
allIn
allIn
}
);
@@ -664,7 +692,7 @@ async function playRoulette(
)
.setFooter({
text:
`crumbRouletteResult:${playerId}:${bet}`
`crumbRouletteResult:${playerId}:${bet}:${allIn ? 1 : 0}`
});
return interaction.editReply({
+21 -3
View File
@@ -13,7 +13,8 @@ const {
} = require("./cookieEconomy");
const {
recordGameOutcome
recordGameOutcome,
trackProfileEvent
} = require("./profileSystem");
const SLOT_BETS = [
@@ -104,7 +105,8 @@ async function showSlots(interaction) {
async function playSlots(
interaction,
bet
bet,
source = "normal"
) {
const ownerId =
getSlotsSessionOwner(
@@ -197,6 +199,17 @@ async function playSlots(
throw error;
}
await trackProfileEvent(
interaction,
playerId,
{
type: "game_start",
game: "slots",
source,
bet
}
);
await interaction.update({
embeds: [
buildSpinningEmbed(
@@ -321,6 +334,10 @@ async function playSlots(
? "loss"
: "push",
profit,
triplet:
outcome.type === "triple"
? outcome.symbol
: null,
jackpot:
outcome.type ===
"triple" &&
@@ -460,7 +477,8 @@ async function runSlotsBack(
return playSlots(
interaction,
bet
bet,
"run_it_back"
);
}
+992 -2014
View File
File diff suppressed because it is too large Load Diff