Skip to content

Commit

Permalink
roulette streaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Mewtwo2387 committed Nov 4, 2024
1 parent 54c6abf commit 00a256d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
7 changes: 4 additions & 3 deletions classes/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ class Database {
{ name: 'roulette_amount_gambled', type: 'FLOAT', defaultValue: 0 },
{ name: 'roulette_times_won', type: 'INTEGER', defaultValue: 0 },
{ name: 'roulette_amount_won', type: 'FLOAT', defaultValue: 0 },
{ name: 'roulette_relative_won', type: 'FLOAT', defaultValue: 0 }
{ name: 'roulette_relative_won', type: 'FLOAT', defaultValue: 0 },
{ name: 'roulette_streak', type: 'INTEGER', defaultValue: 0 }
];

columnsToAdd.forEach(async (column) => {
Expand Down Expand Up @@ -261,8 +262,8 @@ class Database {
async createUser(userId) {
//theregottabeabetterwaytodothis.png
const query = `
INSERT INTO User (id, credits, bitcoin, last_bought_price, last_bought_amount, total_bought_price, total_bought_amount, total_sold_price, total_sold_amount, dinonuggies, dinonuggies_last_claimed, dinonuggies_claim_streak, multiplier_amount_level, multiplier_rarity_level, beki_level, birthdays, ascension_level, heavenly_nuggies, nuggie_flat_multiplier_level, nuggie_streak_multiplier_level, nuggie_credits_multiplier_level, pity, slots_times_played, slots_amount_gambled, slots_times_won, slots_amount_won, slots_relative_won, blackjack_times_played, blackjack_amount_gambled, blackjack_times_won, blackjack_times_drawn, blackjack_times_lost, blackjack_amount_won, blackjack_relative_won, roulette_times_played, roulette_amount_gambled, roulette_times_won, roulette_amount_won, roulette_relative_won)
VALUES (?, 10000, 0, 0, 0, 0, 0, 0, 0, 0, NULL, 0, 1, 1, 1, ?, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)`
INSERT INTO User (id, credits, bitcoin, last_bought_price, last_bought_amount, total_bought_price, total_bought_amount, total_sold_price, total_sold_amount, dinonuggies, dinonuggies_last_claimed, dinonuggies_claim_streak, multiplier_amount_level, multiplier_rarity_level, beki_level, birthdays, ascension_level, heavenly_nuggies, nuggie_flat_multiplier_level, nuggie_streak_multiplier_level, nuggie_credits_multiplier_level, pity, slots_times_played, slots_amount_gambled, slots_times_won, slots_amount_won, slots_relative_won, blackjack_times_played, blackjack_amount_gambled, blackjack_times_won, blackjack_times_drawn, blackjack_times_lost, blackjack_amount_won, blackjack_relative_won, roulette_times_played, roulette_amount_gambled, roulette_times_won, roulette_amount_won, roulette_relative_won, roulette_streak)
VALUES (?, 10000, 0, 0, 0, 0, 0, 0, 0, 0, NULL, 0, 1, 1, 1, ?, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)`

try {
await this.executeQuery(query, [userId]);
Expand Down
33 changes: 21 additions & 12 deletions commands/roulette.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class Roulette extends Command {
const betType = interaction.options.getString('bet_type');
const betValue = interaction.options.getInteger('bet_value');
const credits = await this.client.db.getUserAttr(interaction.user.id, 'credits');
let streak = await this.client.db.getUserAttr(interaction.user.id, 'roulette_streak');

if (amount < 0) {
await interaction.editReply({ embeds: [new Discord.EmbedBuilder()
Expand Down Expand Up @@ -74,24 +75,31 @@ class Roulette extends Command {

// Determine if the bet was successful
if (betType === 'number' && parseInt(betValue) === wheelResult) {
multi = 38;
resultMessage += `You correctly guessed the number!`;
multi = 38 * Math.pow(1.06, streak);
streak++;
resultMessage += `You correctly guessed the number! You are now on a streak of ${streak}`;
} else if (betType === 'red' && colorResult === 'red') {
multi = 2.1;
resultMessage += `You correctly guessed red!`;
multi = 2 * Math.pow(1.06, streak);
streak++;
resultMessage += `You correctly guessed red! You are now on a streak of ${streak}`;
} else if (betType === 'black' && colorResult === 'black') {
multi = 2.1;
resultMessage += `You correctly guessed black!`;
multi = 2 * Math.pow(1.06, streak);
streak++;
resultMessage += `You correctly guessed black! You are now on a streak of ${streak}`;
} else if (betType === 'green' && colorResult === 'green') {
multi = 38;
resultMessage += `You correctly guessed green!`;
multi = 38 * Math.pow(1.06, streak);
streak++;
resultMessage += `You correctly guessed green! You are now on a streak of ${streak}`;
} else if (betType === 'even' && wheelResult % 2 === 0) {
multi = 2.1;
resultMessage += `You correctly guessed even!`;
multi = 2 * Math.pow(1.06, streak);
streak++;
resultMessage += `You correctly guessed even! You are now on a streak of ${streak}`;
} else if (betType === 'odd' && wheelResult % 2 !== 0) {
multi = 2.1;
resultMessage += `You correctly guessed odd!`;
multi = 2 * Math.pow(1.06, streak);
streak++;
resultMessage += `You correctly guessed odd! You are now on a streak of ${streak}`;
} else {
streak = 0;
resultMessage += `You guessed wrongly. Skill issue.`;
}

Expand All @@ -104,6 +112,7 @@ class Roulette extends Command {
await this.client.db.addUserAttr(interaction.user.id, 'roulette_amount_won', winnings);
await this.client.db.addUserAttr(interaction.user.id, 'roulette_relative_won', multi);
await this.client.db.addUserAttr(interaction.user.id, 'credits', winnings - amount);
await this.client.db.setUserAttr(interaction.user.id, 'roulette_streak', streak);

await interaction.editReply({ embeds: [new Discord.EmbedBuilder()
.setColor(multi > 0 ? '#00AA00' : '#AA0000')
Expand Down

0 comments on commit 00a256d

Please sign in to comment.