Created
May 27, 2021 07:26
-
-
Save ruzli/d8605a7fd4afd21d34b442fc1c966b9b to your computer and use it in GitHub Desktop.
Lightguide for bustabit v2, accurate clean version
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: { value: 100, type: 'balance', label: 'Base Bet' }, | |
payout: { value: 2, type: 'multiplier', label: 'Payout' }, | |
} | |
var Profit = 0, Total_Profit = 0, Total_Rolls = 0, Playing = true, baseList = [ 1, 2, 3 ], RolledGames = 0; | |
var PAYOUT = config.payout.value, WAGER = config.wager.value; | |
/* -------------------------------------------------------------- */ | |
if (engine.gameState === "GAME_STARTING") PerformBet() | |
/* Event handler to start betting round. */ | |
engine.on('GAME_STARTING', () => { | |
if (!Playing) ResetVariables() // STAGE: Conditions and requirements checking on validating to reset game for new cycle | |
let currentBet = GetCurrentBet(); | |
if (!currentBet) { | |
Playing = false; // If our bet is null, then we starting new betting cycle | |
ResetVariables(); // Reset variables to begin with new betting cycle | |
} | |
PerformBet(); // STAGE: Create if can bet and place it | |
}) | |
/* Event handler to proceed last game roll. */ | |
engine.on('GAME_ENDED', () => { | |
let lastGame = engine.history.first(); // Last game roll information | |
if (!lastGame.wager) return // If we wagered, it means we played | |
let lastBet = GetCurrentBet(); // Last bet we have made | |
if (lastGame.cashedAt) { /* WON */ | |
if (baseList.length > 1) baseList.splice(baseList.length - 1, 1) | |
baseList.splice(0, 1); // Reduce our list of bets | |
Profit += Math.round((lastBet * (PAYOUT - 1)) / 100); | |
log(`[WON] +${Math.round((lastBet * (PAYOUT - 1)) / 100)} bits`); | |
} else { /* LOST */ | |
baseList.push(lastBet / WAGER); | |
Profit -= (lastBet / 100); | |
log(`[LOST] -${(lastBet / 100)} bits`); | |
} | |
RolledGames++; | |
StatsOutput(); | |
}) | |
/* Resets variables of script to start new betting cycle. */ | |
function ResetVariables() { | |
Playing = true; | |
if (Profit > 0) Total_Profit += Profit | |
Profit = 0; | |
RolledGames = 0; | |
baseList = [1, 2, 3]; | |
} | |
/* Perform bet. */ | |
function PerformBet() { | |
let currentBet = GetCurrentBet(); // Form next bet amount we will bet with | |
if (!currentBet) return // We finish cycle of betting round | |
engine.bet(currentBet, PAYOUT); | |
Total_Rolls++; | |
log(`[${RolledGames}#] [BET = ${Math.round(currentBet / 100)}] [PAYOUT = ${PAYOUT}x] [To Recover = ${Profit}]`); | |
} | |
/* Form next bet what we will use to bet. */ | |
function GetCurrentBet() { | |
let currentBet = null; // Preparing variable of bet, for next checking on conditions | |
// If Profit is non-negative, return to base | |
if (Profit >= 0 && RolledGames > 0) return currentBet // Reset to base bet by putting current bet into null state | |
if (baseList.length >= 2) { | |
currentBet = (baseList[ 0 ] + baseList[baseList.length - 1]) * WAGER; | |
} else if (baseList.length === 1) { | |
currentBet = (baseList[ 0 ] * WAGER) * 2; | |
} | |
return currentBet; | |
} | |
/* Statistics to show after roll was finished. */ | |
function StatsOutput(){ | |
let output = `${Total_Rolls}# | Profit ${Total_Profit} bits`; | |
if (baseList.length > 1) output += ` | ${baseList.length} list length left to play` | |
log(output); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how come it starts at 4 bit bets?