Skip to content

Instantly share code, notes, and snippets.

@BitChop
Forked from dsetzer/bab-script.js
Created August 18, 2019 04:11
Show Gist options
  • Save BitChop/8b4845c03d97ef52ea942cd73b9e2e39 to your computer and use it in GitHub Desktop.
Save BitChop/8b4845c03d97ef52ea942cd73b9e2e39 to your computer and use it in GitHub Desktop.
bustabit random delay bet with countdown
var config = {};
var baseBet = 1 * 100; // base bet in satoshis
var basePayout = 1.05;
var betMultiplier = 1.03; // bet multiplied on win
log('Script is running..');
var currentBet = baseBet;
engine.on('GAME_STARTING', onGameStarted);
engine.on('GAME_ENDED', onGameEnded);
function onGameStarted() {
if (Math.floor(Math.random() * 4) == 1) {
engine.bet(roundBit(currentBet), basePayout);
log('Placed bet of ', parseFloat(currentBet / 100).toFixed(2), 'bits');
}
}
function onGameEnded() {
var lastGame = engine.history.first();
// If we wagered, it means we played
if (!lastGame.wager) {
return;
}
// we won..
if (lastGame.cashedAt) {
currentBet *= betMultiplier;
log('We won, so next bet will be', parseFloat(currentBet / 100).toFixed(2), 'bits');
} else {
stop('We lost, stopping script..');
}
}
function roundBit(bet) {
return Math.round(bet / 100) * 100;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment