added more achievments

This commit is contained in:
DeSqBlocki
2026-08-22 22:10:41 +02:00
parent ae35f61522
commit ca823726e3
12 changed files with 4977 additions and 1998 deletions
+135 -212
View File
@@ -19,83 +19,86 @@ const {
} = require("./profileSystem");
/*
* ============================================================
* CONFIG
* ============================================================
*/
const HEIST_COOLDOWN =
60 * 60; // 1 hour
60 * 60;
/*
* All three approaches use the SAME cooldown:
*
* cooldowns_cookies.heist
*
* Sneak does NOT have its own cooldown.
* Hack does NOT have its own cooldown.
* Smash does NOT have its own cooldown.
*/
const HEIST_METHODS = {
Sneak: {
baseChance: 0.65,
baseChance:
0.65,
minStealPercent: 0.01,
maxStealPercent: 0.03,
maxStealAmount: 1500,
minStealPercent:
0.01,
minPenaltyPercent: 0.01,
maxPenaltyPercent: 0.04,
maxPenaltyAmount: 750
maxStealPercent:
0.03,
maxStealAmount:
1500,
minPenaltyPercent:
0.01,
maxPenaltyPercent:
0.04,
maxPenaltyAmount:
750
},
Hack: {
baseChance: 0.45,
baseChance:
0.45,
minStealPercent: 0.03,
maxStealPercent: 0.06,
maxStealAmount: 3500,
minStealPercent:
0.03,
minPenaltyPercent: 0.03,
maxPenaltyPercent: 0.07,
maxPenaltyAmount: 2000
maxStealPercent:
0.06,
maxStealAmount:
3500,
minPenaltyPercent:
0.03,
maxPenaltyPercent:
0.07,
maxPenaltyAmount:
2000
},
Smash: {
baseChance: 0.25,
baseChance:
0.25,
minStealPercent: 0.06,
maxStealPercent: 0.12,
maxStealAmount: 7500,
minStealPercent:
0.06,
minPenaltyPercent: 0.06,
maxPenaltyPercent: 0.12,
maxPenaltyAmount: 5000
maxStealPercent:
0.12,
maxStealAmount:
7500,
minPenaltyPercent:
0.06,
maxPenaltyPercent:
0.12,
maxPenaltyAmount:
5000
}
};
/*
* ============================================================
* RESOLVE HEIST
* ============================================================
*/
async function resolveCookieHeist(
interaction,
methodName
) {
/*
* Validate ownership of this Heist menu.
*
* Footer:
*
* cookieHeist:<userId>
*/
const footer =
interaction.message
?.embeds?.[0]
@@ -114,10 +117,10 @@ async function resolveCookieHeist(
if (
type !==
"cookieHeist"
"cookieHeist"
||
ownerId !==
interaction.user.id
interaction.user.id
) {
return temporaryEphemeralReply(
interaction,
@@ -129,13 +132,9 @@ async function resolveCookieHeist(
}
/*
* Validate method.
*/
const method =
HEIST_METHODS[
methodName
methodName
];
@@ -150,12 +149,6 @@ async function resolveCookieHeist(
}
/*
* ========================================================
* SHARED HEIST COOLDOWN
* ========================================================
*/
const cooldown =
await claimCooldown(
interaction.user.id,
@@ -179,10 +172,6 @@ async function resolveCookieHeist(
}
/*
* Lock this Heist interaction immediately.
*/
await interaction.update({
embeds: [
new EmbedBuilder()
@@ -212,11 +201,6 @@ async function resolveCookieHeist(
interaction.client.user.id;
/*
* Re-fetch balances because they may have
* changed since the menu was opened.
*/
const [
playerCookies,
vaultCookies
@@ -234,10 +218,10 @@ async function resolveCookieHeist(
if (
playerCookies <
1
1
||
vaultCookies <
1
1
) {
return interaction.editReply({
embeds: [
@@ -267,21 +251,11 @@ async function resolveCookieHeist(
}
/*
* Short theatrical delay.
*/
await sleep(
1200
);
/*
* ========================================================
* DYNAMIC VAULT SECURITY
* ========================================================
*/
const securityPenalty =
getVaultSecurityPenalty(
vaultCookies
@@ -302,12 +276,6 @@ async function resolveCookieHeist(
successChance;
/*
* ========================================================
* SUCCESS
* ========================================================
*/
if (success) {
const rolledPercent =
randomFloat(
@@ -377,30 +345,6 @@ async function resolveCookieHeist(
}
const [
playerAfter,
vaultAfter
] =
await Promise.all([
getCookieBalance(
playerId
),
getCookieBalance(
vaultId
)
]);
const actualPercentage =
(
amount /
vaultCookies
)
*
100;
await trackProfileEvent(
interaction,
playerId,
@@ -412,7 +356,10 @@ async function resolveCookieHeist(
"heist",
result:
"win"
"win",
profit:
amount
}
);
@@ -441,6 +388,30 @@ async function resolveCookieHeist(
);
const [
playerAfter,
vaultAfter
] =
await Promise.all([
getCookieBalance(
playerId
),
getCookieBalance(
vaultId
)
]);
const actualPercentage =
(
amount /
vaultCookies
)
*
100;
const embed =
new EmbedBuilder()
.setTitle(
@@ -551,12 +522,6 @@ async function resolveCookieHeist(
}
/*
* ========================================================
* FAILURE
* ========================================================
*/
const penaltyPercent =
randomFloat(
method.minPenaltyPercent,
@@ -582,11 +547,6 @@ async function resolveCookieHeist(
try {
/*
* Heist fines always go into
* ShaiBot's central vault.
*/
await transferCookies(
playerId,
vaultId,
@@ -630,6 +590,38 @@ async function resolveCookieHeist(
}
await trackProfileEvent(
interaction,
playerId,
{
type:
"game_result",
game:
"heist",
result:
"loss",
profit:
-penalty
}
);
await trackProfileEvent(
interaction,
playerId,
{
type:
"cookie_loss",
amount:
penalty
}
);
const [
playerAfter,
vaultAfter
@@ -654,35 +646,6 @@ async function resolveCookieHeist(
100;
await trackProfileEvent(
interaction,
playerId,
{
type:
"game_result",
game:
"heist",
result:
"loss"
}
);
await trackProfileEvent(
interaction,
playerId,
{
type:
"cookie_loss",
amount:
penalty
}
);
const embed =
new EmbedBuilder()
.setTitle(
@@ -793,12 +756,6 @@ async function resolveCookieHeist(
}
/*
* ============================================================
* RETURN TO CRUMB SAUCER
* ============================================================
*/
function buildReturnButton() {
return [
new ActionRowBuilder()
@@ -821,25 +778,9 @@ function buildReturnButton() {
}
/*
* ============================================================
* SECURITY
* ============================================================
*/
function getVaultSecurityPenalty(
vaultCookies
) {
/*
* Approximately:
*
* 100 -> 5%
* 1,000 -> 7.5%
* 10,000 -> 10%
* 100,000 -> 12.5%
* 1,000,000 -> 15%
*/
return Math.min(
Math.log10(
vaultCookies +
@@ -853,19 +794,14 @@ function getVaultSecurityPenalty(
}
/*
* ============================================================
* PROGRESS TEXT
* ============================================================
*/
function getHeistProgressText(
methodName
) {
switch (
methodName
methodName
) {
case "Sneak":
return [
"🥷 You slip through the service entrance...",
"",
@@ -874,6 +810,7 @@ function getHeistProgressText(
case "Hack":
return [
"💻 You connect to the vault terminal...",
"",
@@ -882,6 +819,7 @@ function getHeistProgressText(
case "Smash":
return [
"💥 You charge directly at the vault...",
"",
@@ -890,17 +828,12 @@ function getHeistProgressText(
default:
return "The heist is underway...";
}
}
/*
* ============================================================
* SUCCESS TEXT
* ============================================================
*/
function getSuccessText(
methodName,
user,
@@ -911,27 +844,31 @@ function getSuccessText(
switch (
methodName
methodName
) {
case "Sneak":
return (
`🥷 ${user} slipped through security and quietly escaped with ${cookies}.`
);
case "Hack":
return (
`💻 ${user} convinced the vault terminal that ${cookies} belonged to them.`
);
case "Smash":
return (
`💥 ${user} smashed through the Cookie Vault and escaped with ${cookies}!`
);
default:
return (
`${user} escaped with ${cookies}.`
);
@@ -939,12 +876,6 @@ function getSuccessText(
}
/*
* ============================================================
* FAILURE TEXT
* ============================================================
*/
function getFailureText(
methodName,
user,
@@ -955,9 +886,10 @@ function getFailureText(
switch (
methodName
methodName
) {
case "Sneak":
return [
`🚨 ${user} stepped directly on the world's loudest Cookie wrapper.`,
"",
@@ -966,6 +898,7 @@ function getFailureText(
case "Hack":
return [
`🚨 ${user} entered the password incorrectly one too many times.`,
"",
@@ -974,6 +907,7 @@ function getFailureText(
case "Smash":
return [
`🚨 ${user} discovered that the vault door is significantly stronger than expected.`,
"",
@@ -982,6 +916,7 @@ function getFailureText(
default:
return (
`The heist failed and cost ${user} ${cookies}.`
);
@@ -989,12 +924,6 @@ function getFailureText(
}
/*
* ============================================================
* UTIL
* ============================================================
*/
function sleep(
ms
) {
@@ -1008,12 +937,6 @@ function sleep(
}
/*
* ============================================================
* EXPORTS
* ============================================================
*/
module.exports = {
resolveCookieHeist,
HEIST_COOLDOWN