added more achievments
This commit is contained in:
+8
-224
@@ -16,12 +16,6 @@ const {
|
||||
} = require("./profileSystem");
|
||||
|
||||
|
||||
/*
|
||||
* ============================================================
|
||||
* CONFIG
|
||||
* ============================================================
|
||||
*/
|
||||
|
||||
const ROULETTE_BETS = [
|
||||
10,
|
||||
50,
|
||||
@@ -64,10 +58,6 @@ const ROULETTE_CHOICES = {
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* European Roulette red numbers.
|
||||
*/
|
||||
|
||||
const RED_NUMBERS =
|
||||
new Set([
|
||||
1,
|
||||
@@ -91,12 +81,6 @@ const RED_NUMBERS =
|
||||
]);
|
||||
|
||||
|
||||
/*
|
||||
* ============================================================
|
||||
* SHOW ROULETTE
|
||||
* ============================================================
|
||||
*/
|
||||
|
||||
async function showRoulette(
|
||||
interaction
|
||||
) {
|
||||
@@ -171,12 +155,6 @@ async function showRoulette(
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ============================================================
|
||||
* CHOOSE NORMAL WAGER
|
||||
* ============================================================
|
||||
*/
|
||||
|
||||
async function chooseRouletteBet(
|
||||
interaction,
|
||||
bet
|
||||
@@ -223,12 +201,6 @@ async function chooseRouletteBet(
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ============================================================
|
||||
* ALL IN
|
||||
* ============================================================
|
||||
*/
|
||||
|
||||
async function startRouletteAllIn(
|
||||
interaction
|
||||
) {
|
||||
@@ -252,10 +224,6 @@ async function startRouletteAllIn(
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Resolve the balance at click time.
|
||||
*/
|
||||
|
||||
const balance =
|
||||
await getCookieBalance(
|
||||
interaction.user.id
|
||||
@@ -276,13 +244,6 @@ async function startRouletteAllIn(
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* All In only selects the wager.
|
||||
*
|
||||
* Nothing is transferred until the player
|
||||
* chooses Red / Black / Odd / Even / Zero.
|
||||
*/
|
||||
|
||||
return showRouletteChoices(
|
||||
interaction,
|
||||
balance
|
||||
@@ -290,18 +251,6 @@ async function startRouletteAllIn(
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ============================================================
|
||||
* SHOW CHOICE MENU
|
||||
* ============================================================
|
||||
*
|
||||
* Shared by:
|
||||
*
|
||||
* - normal wager buttons
|
||||
* - All In
|
||||
* - Run It Back
|
||||
*/
|
||||
|
||||
async function showRouletteChoices(
|
||||
interaction,
|
||||
bet
|
||||
@@ -389,16 +338,6 @@ async function showRouletteChoices(
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ============================================================
|
||||
* RUN IT BACK
|
||||
* ============================================================
|
||||
*
|
||||
* Remembers ONLY the previous wager.
|
||||
*
|
||||
* It does NOT remember Red / Black / Odd / Even / Zero.
|
||||
*/
|
||||
|
||||
async function runRouletteBack(
|
||||
interaction
|
||||
) {
|
||||
@@ -415,12 +354,6 @@ async function runRouletteBack(
|
||||
[];
|
||||
|
||||
|
||||
/*
|
||||
* Expected:
|
||||
*
|
||||
* crumbRouletteResult:<userId>:<bet>
|
||||
*/
|
||||
|
||||
if (
|
||||
parts[0] !==
|
||||
"crumbRouletteResult"
|
||||
@@ -477,10 +410,6 @@ async function runRouletteBack(
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Same wager, fresh choice.
|
||||
*/
|
||||
|
||||
return showRouletteChoices(
|
||||
interaction,
|
||||
bet
|
||||
@@ -488,12 +417,6 @@ async function runRouletteBack(
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ============================================================
|
||||
* PLAY ROULETTE
|
||||
* ============================================================
|
||||
*/
|
||||
|
||||
async function playRoulette(
|
||||
interaction,
|
||||
choiceKey
|
||||
@@ -566,15 +489,6 @@ async function playRoulette(
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* IMPORTANT:
|
||||
*
|
||||
* Do NOT require ROULETTE_BETS.includes(bet) here.
|
||||
*
|
||||
* All In and Run It Back may legitimately use
|
||||
* amounts outside the predefined wager buttons.
|
||||
*/
|
||||
|
||||
if (
|
||||
!Number.isSafeInteger(
|
||||
bet
|
||||
@@ -616,11 +530,6 @@ async function playRoulette(
|
||||
]);
|
||||
|
||||
|
||||
/*
|
||||
* Balance may have changed while the player
|
||||
* was choosing their bet type.
|
||||
*/
|
||||
|
||||
if (
|
||||
playerBalance <
|
||||
bet
|
||||
@@ -635,20 +544,6 @@ async function playRoulette(
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Worst payout depends on the selected wager.
|
||||
*
|
||||
* Red / Black / Odd / Even:
|
||||
* x2
|
||||
*
|
||||
* Zero:
|
||||
* x36
|
||||
*
|
||||
* The player's wager is transferred to the house
|
||||
* before payout, so houseBalance + bet is available
|
||||
* after accepting the wager.
|
||||
*/
|
||||
|
||||
const maximumPayout =
|
||||
bet *
|
||||
choice.multiplier;
|
||||
@@ -669,12 +564,6 @@ async function playRoulette(
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ========================================================
|
||||
* TAKE WAGER
|
||||
* ========================================================
|
||||
*/
|
||||
|
||||
try {
|
||||
await transferCookies(
|
||||
playerId,
|
||||
@@ -701,12 +590,6 @@ async function playRoulette(
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ========================================================
|
||||
* PSEUDO ANIMATION
|
||||
* ========================================================
|
||||
*/
|
||||
|
||||
await interaction.update({
|
||||
embeds: [
|
||||
buildSpinEmbed(
|
||||
@@ -764,12 +647,6 @@ async function playRoulette(
|
||||
);
|
||||
|
||||
|
||||
/*
|
||||
* ========================================================
|
||||
* ACTUAL RESULT
|
||||
* ========================================================
|
||||
*/
|
||||
|
||||
const result =
|
||||
randomRouletteNumber();
|
||||
|
||||
@@ -788,12 +665,6 @@ async function playRoulette(
|
||||
: 0;
|
||||
|
||||
|
||||
/*
|
||||
* ========================================================
|
||||
* PAYOUT
|
||||
* ========================================================
|
||||
*/
|
||||
|
||||
if (
|
||||
payout >
|
||||
0
|
||||
@@ -871,7 +742,9 @@ async function playRoulette(
|
||||
? "win"
|
||||
: profit < 0
|
||||
? "loss"
|
||||
: "push"
|
||||
: "push",
|
||||
|
||||
profit
|
||||
}
|
||||
);
|
||||
|
||||
@@ -893,6 +766,7 @@ async function playRoulette(
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
else if (
|
||||
profit <
|
||||
0
|
||||
@@ -992,13 +866,6 @@ async function playRoulette(
|
||||
}
|
||||
)
|
||||
|
||||
/*
|
||||
* Remember only:
|
||||
*
|
||||
* owner
|
||||
* wager
|
||||
*/
|
||||
|
||||
.setFooter({
|
||||
text:
|
||||
`crumbRouletteResult:${playerId}:${bet}`
|
||||
@@ -1016,17 +883,13 @@ async function playRoulette(
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ============================================================
|
||||
* RESULT LOGIC
|
||||
* ============================================================
|
||||
*/
|
||||
|
||||
function didRouletteBetWin(
|
||||
choice,
|
||||
number
|
||||
) {
|
||||
switch (choice) {
|
||||
switch (
|
||||
choice
|
||||
) {
|
||||
case "Red":
|
||||
|
||||
return (
|
||||
@@ -1090,12 +953,6 @@ function didRouletteBetWin(
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ============================================================
|
||||
* DISPLAY
|
||||
* ============================================================
|
||||
*/
|
||||
|
||||
function buildSpinEmbed(
|
||||
choice,
|
||||
bet,
|
||||
@@ -1167,12 +1024,6 @@ function formatRouletteNumber(
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ============================================================
|
||||
* WAGER BUTTONS
|
||||
* ============================================================
|
||||
*/
|
||||
|
||||
function buildBetButtons() {
|
||||
return [
|
||||
new ActionRowBuilder()
|
||||
@@ -1183,18 +1034,14 @@ function buildBetButtons() {
|
||||
.setCustomId(
|
||||
`crumbRouletteBet${bet}`
|
||||
)
|
||||
|
||||
.setLabel(
|
||||
bet.toLocaleString()
|
||||
)
|
||||
|
||||
.setEmoji(
|
||||
"🍪"
|
||||
)
|
||||
|
||||
.setStyle(
|
||||
bet >=
|
||||
500
|
||||
bet >= 500
|
||||
? ButtonStyle.Primary
|
||||
: ButtonStyle.Secondary
|
||||
)
|
||||
@@ -1235,12 +1082,6 @@ function buildBetButtons() {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ============================================================
|
||||
* CHOICE BUTTONS
|
||||
* ============================================================
|
||||
*/
|
||||
|
||||
function buildChoiceButtons() {
|
||||
return [
|
||||
new ActionRowBuilder()
|
||||
@@ -1330,22 +1171,10 @@ function buildChoiceButtons() {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ============================================================
|
||||
* RESULT BUTTONS
|
||||
* ============================================================
|
||||
*/
|
||||
|
||||
function buildResultButtons() {
|
||||
return [
|
||||
new ActionRowBuilder()
|
||||
.addComponents(
|
||||
/*
|
||||
* Same wager.
|
||||
*
|
||||
* Player chooses Red/Black/etc again.
|
||||
*/
|
||||
|
||||
new ButtonBuilder()
|
||||
.setCustomId(
|
||||
"crumbRouletteRunItBack"
|
||||
@@ -1360,10 +1189,6 @@ function buildResultButtons() {
|
||||
ButtonStyle.Success
|
||||
),
|
||||
|
||||
/*
|
||||
* Return to wager selection.
|
||||
*/
|
||||
|
||||
new ButtonBuilder()
|
||||
.setCustomId(
|
||||
"crumbSaucerRoulette"
|
||||
@@ -1378,10 +1203,6 @@ function buildResultButtons() {
|
||||
ButtonStyle.Primary
|
||||
),
|
||||
|
||||
/*
|
||||
* Main Crumb Saucer.
|
||||
*/
|
||||
|
||||
new ButtonBuilder()
|
||||
.setCustomId(
|
||||
"crumbSaucerBack"
|
||||
@@ -1400,12 +1221,6 @@ function buildResultButtons() {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ============================================================
|
||||
* SESSION OWNER
|
||||
* ============================================================
|
||||
*/
|
||||
|
||||
function getRouletteSessionOwner(
|
||||
interaction
|
||||
) {
|
||||
@@ -1422,10 +1237,6 @@ function getRouletteSessionOwner(
|
||||
[];
|
||||
|
||||
|
||||
/*
|
||||
* Main Saucer
|
||||
*/
|
||||
|
||||
if (
|
||||
parts[0] ===
|
||||
"crumbSaucer"
|
||||
@@ -1434,10 +1245,6 @@ function getRouletteSessionOwner(
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Roulette wager menu
|
||||
*/
|
||||
|
||||
if (
|
||||
parts[0] ===
|
||||
"crumbRouletteMenu"
|
||||
@@ -1446,10 +1253,6 @@ function getRouletteSessionOwner(
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Roulette choice menu.
|
||||
*/
|
||||
|
||||
if (
|
||||
parts[0] ===
|
||||
"crumbRouletteBet"
|
||||
@@ -1458,10 +1261,6 @@ function getRouletteSessionOwner(
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Roulette result.
|
||||
*/
|
||||
|
||||
if (
|
||||
parts[0] ===
|
||||
"crumbRouletteResult"
|
||||
@@ -1474,12 +1273,6 @@ function getRouletteSessionOwner(
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ============================================================
|
||||
* RANDOM
|
||||
* ============================================================
|
||||
*/
|
||||
|
||||
function randomRouletteNumber() {
|
||||
return Math.floor(
|
||||
Math.random() *
|
||||
@@ -1501,20 +1294,11 @@ function sleep(
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ============================================================
|
||||
* EXPORTS
|
||||
* ============================================================
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
showRoulette,
|
||||
|
||||
chooseRouletteBet,
|
||||
startRouletteAllIn,
|
||||
showRouletteChoices,
|
||||
|
||||
playRoulette,
|
||||
|
||||
runRouletteBack
|
||||
};
|
||||
Reference in New Issue
Block a user