Skip to content

Instantly share code, notes, and snippets.

@zundra
Last active July 4, 2021 19:47
Show Gist options
  • Save zundra/03238a9b03666603071e5e33fe6eafc0 to your computer and use it in GitHub Desktop.
Save zundra/03238a9b03666603071e5e33fe6eafc0 to your computer and use it in GitHub Desktop.
var config = {
first_wager: {
value: 1000,
type: "balance",
label: "first wager",
},
second_wager: {
value: 5000,
type: "balance",
label: "second wager",
},
third_wager: {
value: 15000,
type: "balance",
label: "third wager",
},
payout: {
value: 2.1,
type: "multiplier",
label: "payout",
},
losing_streak_count: {
value: 3,
type: "multiplier",
label: "losing streak count"
},
bust_watch_max: {
value: 2,
type: "multiplier",
label: "watch for busts under this value"
}
};
var bustWatchCount = 0;
var bustLoseCount = 0;
var wager = 0;
log("Script is running..");
engine.on("GAME_STARTING", onGameStarted);
engine.once("GAME_STARTING", () => engine.on("GAME_ENDED", onGameEnded));
function onGameStarted() {
log("Bust while watching count = " + bustWatchCount, "max count = ", config.losing_streak_count.value);
log("Bust while betting count = " + bustLoseCount, "max count = 3");
if (bustWatchCount >= config.losing_streak_count.value) {
if (bustLoseCount < 3) {
makeBet(calculateNextBet());
} else {
log("Hit max losing streak, resetting...")
bustLoseCount = 0;
bustWatchCount = 0;
}
}
}
function onGameEnded() {
var lastGame = engine.history.first();
if (!lastGame.wager && lastGame.bust < config.bust_watch_max.value) {
bustWatchCount++;
return;
}
if (!lastGame.wager) {
return;
}
if (lastGame.cashedAt) {
var profit = (wager * lastGame.cashedAt - wager) / 100;
log("Won", profit.toFixed(2), "bits");
bustLoseCount = 0;
bustWatchCount = 0;
} else {
bustLoseCount++;
log("Busted during betting. Count = ", bustLoseCount);
}
}
function calculateNextBet() {
wager = 0;
if (bustLoseCount == 0) {
wager = config.first_wager.value;
} else if (bustLoseCount == 1) {
wager = config.second_wager.value;
} else if (bustLoseCount == 2) {
wager = config.third_wager.value;
}
return roundBit(wager);
}
function roundBit(bit) {
return Math.round(bit / 100) * 100;
}
function roundValue(value) {
return Math.round(value / 100);
}
function makeBet(betVal) {
engine.bet(betVal, config.payout.value);
log(
"betting",
roundValue(betVal),
"on",
config.payout.value,
"x",
"Attempt [" + (bustLoseCount + 1) + "]"
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment