Last active
October 16, 2020 01:11
-
-
Save ruzli/4843e3926cfe07610d281f9e1d127407 to your computer and use it in GitHub Desktop.
Pumpkins
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var config = { | |
wager: { label: "Wager", type: "balance", value: 100 }, | |
min_pay: { label: "Min payout", type: "multiplier", value: 5 }, | |
max_pay: { label: "Max payout", type: "multiplier", value: 40 }, | |
max_loss: { label: "Max lose", type: "balance", value: -100000 }, | |
bets_prog: { label: "Progression betting", type: "checkbox", value: true }, | |
prog_reset: { label: "Progression reset", type: "checkbox", value: false }, | |
progression_bet_amount: { label: "Bet Progression", type: "balance", value: 100 }, | |
}; | |
var balance_monitor_rolls = 20, balance_monitor_rolls_counter = 0, nonce = 1; | |
var startingBalance = this.balance, nextTierBalance = startingBalance * 5, engine = this; | |
async function balanceMonitor() { | |
await engine.log(`Nonce of current seed ${nonce}`); | |
nonce++; | |
if (startingBalance > engine.balance) { | |
balance_monitor_rolls_counter++; | |
await engine.log(`Dangerous! Seed going to change once ${balance_monitor_rolls_counter}/${balance_monitor_rolls}`); | |
if (balance_monitor_rolls_counter >= balance_monitor_rolls) { | |
balance_monitor_rolls_counter = 0; | |
nonce = 1; | |
engine.log(`Seed was changed!`); | |
await engine.newSeedPair(); | |
} | |
} else { | |
balance_monitor_rolls_counter = 0; | |
} | |
if (engine.balance > nextTierBalance) { | |
startingBalance = engine.balance; | |
nextTierBalance = startingBalance * 10; | |
} | |
} | |
var steps = 0; | |
var target = 1.01; | |
var turns = 0; | |
var profit = 0; | |
var bet_amount; | |
while (true) { | |
await balanceMonitor(); | |
if (steps <= 0){ | |
const { multiplier } = await this.bet(100, 1.01); | |
if (multiplier < config.max_pay.value && multiplier > config.min_pay.value) { | |
if (multiplier != 1.0){ | |
if (config.prog_reset.value){ | |
bet_amount = config.wager.value | |
} | |
target = multiplier; | |
steps = multiplier; | |
} | |
} | |
} else { | |
steps--; | |
if (config.bets_prog.value) { | |
bet_amount = config.wager.value + (turns * config.progression_bet_amount.value); | |
} else { | |
bet_amount = config.wager.value; | |
} | |
if (profit < config.max_loss.value) { await this.stop(); } | |
const { multiplier } = await this.bet(roundBit(bet_amount), target); | |
if (profit < config.max_loss.value) { | |
await this.stop(); | |
} | |
if (target > multiplier) { | |
profit -= bet_amount; | |
playSound(); | |
turns++; | |
} else { | |
profit += bet_amount * target - bet_amount | |
sound_bell(); | |
turns = 0; | |
steps = 0; | |
} | |
} | |
this.clearLog(); | |
this.log(`Profit: ${Math.round(profit / 100)}`); | |
} | |
async function playSound(name = "dud") { | |
// Usable names: dud, dud2, win, big_win, | |
let url = "https://raw.githubusercontent.com/JartanFTW/sounds/master/" + name + ".mp3" | |
const audio = new Audio(url) | |
await audio.play() | |
return new Promise(resolve => audio.onended = resolve) | |
} | |
async function sound_bell() { | |
return new Promise(resolve => { | |
const audio = new Audio(`https://www.soundjay.com/misc/small-bell-ring-01a.mp3`) | |
audio.autoplay = true; | |
audio.onended = resolve | |
}); | |
} | |
function roundBit(bet) { return Math.max(100, Math.round((bet) / 100) * 100) } | |
async function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment