Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var config = {
- betBalance: { type: 'multiplier', label: 'Max portion of balance to start bet with.', value: 0.0001 },
- baseBet: { type: 'balance', label: 'Extra amount added to base bet', value: 0 },
- averageVariation: { type: 'multiplier', label: 'Average variation for min/max payout', value: 0.5 },
- maxPayout: { type: 'multiplier', label: 'Upper bound limit on payout', value: 3.5 },
- minPayout: { type: 'multiplier', label: 'Lower bound limit on payout', value: 1.3 },
- cargo: { type: 'number', label: 'Cargo of history length to use for build median', value: 20 },
- minProfit: { type: 'balance', label: 'Minimal profit', value: -50000 },
- maxProfit: { type: 'balance', label: 'Maximal profit', value: 10000 },
- skips_freq: { type: 'number', label: 'Skips after restart', value: 0 },
- reset_profits: { type: 'checkbox', label: 'Reset profit at hitting limit of min/max profits', value: true },
- reset_seed_at_restart: { type: 'checkbox', label: 'On bust seed also will be reset', value: true },
- reset_seed_target_at_restart: { type: 'checkbox', label: 'Reset seed on profit goal complete', value: false },
- stop_on_double_loss: { type: 'checkbox', label: 'Stop on double loss of minProfit', value: true },
- betSpeed: { type: 'number', label: 'Bet Speed(ms)', value: 1 },
- maxBalance: { type: 'number', label: 'Stop script @ Balance bits', value: 6000 },
- };
- var config_hided = {
- fast: false,
- reset_browser_stats_at_begin: true,
- nosound: true,
- play_intro: true,
- debug: true,
- };
- var engine = this
- var locked_balance = this.balance
- var startingBalance = this.balance
- var findStreak = 0
- var streakRolls = 0
- var streakLossCount = 0
- var maxBalance = config.maxBalance.value
- var results = [], loses = [], vectorApex = 0, nextBet = 0, nonce = 1, total_profit = 0;
- var min_Profit = config.minProfit.value, max_Profit = config.maxProfit.value , profit = 0, baseBet = config.baseBet.value, losses = 0, reached = false, total_profit = 0;
- var wagered = 0, gross_profit = 0;
- var minPayout = config.minPayout.value, maxPayout = config.maxPayout.value;
- var normal_bettable = config.betBalance.value;
- var ripped = false
- var hitter_counter = 0, recovery_rolls = 0, defence_rolls = 0;
- var result, profit_risk = 0, wins = 0;
- Array.prototype.median = function (span) {
- let arr = results.slice(0, (span ? Math.max(1, Math.min(50, span)) : 50)).map(a => a.bust).sort((a, b) => { return a - b })
- let mid = arr.length / 2, med = mid % 1 ? arr[mid - 0.5] : (arr[mid - 1] + arr[mid]) / 2;
- return med;
- };
- /***************************************************************** */
- function recovery_mode (state, effect = 0){
- switch (state) {
- case true:
- console.log(`Recovery started!`)
- recovery_rolls = effect;
- case false:
- console.log(`Recovery ended!`)
- hitter_counter = 0;
- }
- }
- function defence_mode (state, effect = 0){
- switch (state) {
- case true:
- console.log(`Defence started!`)
- defence_rolls = effect;
- case false:
- console.log(`Defence ended!`)
- defence_rolls = 0;
- }
- }
- /********************* - Assign to betting - ************************ */
- const origBet = this.bet;
- this.bet = async function () {
- await updateLog()
- nonce++
- return origBet.apply(this, arguments);
- };
- const origSkip = this.skip;
- this.skip = async function () {
- await updateLog()
- nonce++
- return origSkip.apply(this, arguments);
- };
- /************************** - Effects - ************************* */
- function recovery_effect(multiplier_modificator){
- if (hitter_counter < 2) return
- let recovery_multiplier = multiplier_modificator
- let recovery_bettable = config.betBalance.value * recovery_multiplier
- if (recovery_rolls > 0){
- normal_bettable = recovery_bettable;
- recovery_rolls--;
- console.log(`Recovery mode will lasts more ${recovery_rolls} rolls`)
- }
- if (recovery_rolls <= 0) {
- normal_bettable = config.betBalance.value;
- recovery_rolls = 0
- }
- }
- function defence_effect(multiplier_modificator){
- if (hitter_counter < 3) return
- let defence_multiplier = multiplier_modificator
- let defence_bettable = config.betBalance.value / defence_multiplier
- if (defence_rolls > 0){
- //normal_bettable = defence_bettable;
- minPayout = config.minPayout.value + config.averageVariation.value
- maxPayout = config.maxPayout.value + config.averageVariation.value
- defence_rolls--;
- console.log(`Defence mode will lasts more ${recovery_rolls} rolls`)
- } else {
- //normal_bettable = config.betBalance.value;
- minPayout = config.minPayout.value
- maxPayout = config.maxPayout.value
- defence_rolls = 0;
- }
- }
- /*************************** - Targets - **************************** */
- function clampTarget(target) { return Math.max(minPayout, Math.min(maxPayout, target)); }
- function calcTarget(results) {
- const pLen = results.length
- if ( pLen < config.cargo.value) { return; } /* Not enough input to slice. Returning.*/
- const r = results.slice(-config.cargo.value).sort((a, b) => a - b), len = r.length, mid = Math.floor(len / 2)
- return clampTarget((len % 2 ? r[mid] : ((r[mid - 1] + r[mid]) / 2)));
- }
- /************************** - Bets - ************************** */
- function roundBit(bet) { return Math.max(100, Math.round(bet / 100) * 100);}
- const calcBet = () => {
- const betBalPerc = normal_bettable, lossCount = loses.length || 0;
- baseBet = roundBit(config.baseBet.value + (engine.balance * (betBalPerc / (200 - lossCount))));
- vectorApex = calcTarget(results);
- if (!lossCount) { return baseBet; }
- losses = (loses.reduce((a, b) => a + b) * 100);
- nextBet = roundBit((baseBet + losses) / (vectorApex - 1));
- return nextBet;
- };
- /*************************** - Methods - *********************** */
- async function updateLog(){
- var maximum_lose = ` Maximum lose: ${session_win() / 100} `
- let extra = ` Extra base bet ${(baseBet / 100).toFixed()} + `
- let rolls_amount = `Nonce: ${nonce} `
- let Dmode = `[D]`
- let Rmode = `[R]`
- let Bbet = `[B = ${Math.round(normal_bettable).toFixed()}]`
- let HC = `[HC = ${hitter_counter}]`
- if (recovery_rolls > 0){Rmode = `[R = ${recovery_rolls}]`} else {Rmode = ``}
- if (defence_rolls > 0){Dmode = `[D = ${defence_rolls}]`} else {Dmode = ``}
- if (hitter_counter > 0){HC = `[HC = ${hitter_counter}]`} else {HC = ``}
- if (config.baseBet.value == 0){ extra = `` }
- engine.clearLog()
- engine.log(`${rolls_amount}|${extra} | NextBet: ${(losses / 100).toFixed()} / ${vectorApex.toFixed(2)}x = ${( nextBet / 100)} bits | Start Bal: ${startingBalance} | streakRolls: ${streakRolls} | Streak Loss: ${streakLossCount}`)
- if (reached){
- engine.log(`${HC}${Dmode}${Rmode}${Bbet}${maximum_lose}| PROFIT: ${(profit / 100).toFixed(2)} | ${(getTotalProfit())} bits`)
- } else {
- engine.log(`${HC}${Dmode}${Rmode}${Bbet}${maximum_lose}| profit goal: ${max_Profit / 100} | PROFIT: ${(profit / 100).toFixed(2)} | ${(getTotalProfit())} bits`)
- }
- if (config_hided.debug){engine.log(`${min_Profit / 100} | ${config.minProfit.value / 100} | ${session_win() / 100} | ${wins}`)}
- await sleep(config.betSpeed.value);
- }
- function get_random(rnd = 10) { return Math.round(Math.random() * rnd) + 1 }
- function sleep(ms = config.betSpeed.value) { if(ms != 0) { return new Promise(resolve => setTimeout(resolve, ms)) }};
- async function skip_games(context, skips){
- //if (config.skips_freq.value > 0){
- for (let i = 0; i < get_random(skips); i++){
- const { multiplier } = await context.skip();
- }
- //}
- }
- function getProfit(){
- let current_profit = (((wagered + gross_profit) - wagered) / 100).toFixed(2)
- return current_profit
- }
- function getTotalProfit(){
- return (total_profit / 100).toFixed(2)
- }
- function updateProfit(value){
- if (value > 0){
- gross_profit += value
- }
- wagered += Math.abs(value)
- profit += value
- total_profit += value
- }
- async function checkConditions(){
- let _minProfit;
- if (wins == 0) {_minProfit = config.minProfit.value }
- if ((wins * (config.maxProfit.value / 2)) - nextBet < session_win()) {
- loses = []
- wins = 0
- profit = 0
- nextBet = roundBit(calcBet())
- if (config.reset_seed_target_at_restart.value){
- //await generateSeed(engine)
- // findStreak = 0
- // await streakFinder()
- }
- }
- //await getBuffs()
- }
- function session_win(){
- let give_cost = config.maxProfit.value
- if (profit > config.maxProfit.value){
- profit -= give_cost // |> buy
- // </> trade
- wins = wins + 1 // <| receive item
- }
- //nextBet = roundBit(calcBet())
- let formula = 0
- if (wins > 0){
- formula = (wins * config.maxProfit.value) / 2
- } else if (wins <= 0) {
- formula = config.minProfit.value
- }
- return formula
- }
- async function getBuffs() {
- if (engine.balance < locked_balance + config.minProfit.value) {
- await get_initial_data(engine)
- if (config.stop_on_double_loss.value) {
- // engine.log(`Stopped script due loss`)
- // engine.stop()
- findStreak = 0
- await streakFinder(1)
- } else {
- hitter_counter++
- if (hitter_counter >= 1 && recovery_rolls <= 0) {
- recovery_mode(true, 30)
- }
- if (hitter_counter >= 2 && defence_rolls <= 0) {
- defence_mode(true, 50)
- }
- }
- }
- }
- // CHECK FOR ACTIVE EFFECTS
- function checkBuffs() {
- defence_effect(3)
- recovery_effect(3)
- }
- async function generateSeed(context) {
- try {
- const { server_seed_hash } = await context.newSeedPair()
- await context.setClientSeed(server_seed_hash)
- nonce = 1
- }
- catch (e) { console.log(`Seed Pair is already was set and still not used.`) }
- }
- async function play_tick_sound(sound, delay = true){
- let second = 1000
- if (!delay) second = 0
- if (config_hided.fast == false) await sleep(second)
- if (!config_hided.nosound) SE.play_raw(SE.song(sound))
- }
- async function count_down(context){
- let _nextBet = nextBet / 100
- context.log(`Game is restarting!`)
- play_tick_sound(0)
- context.clearLog()
- context.log(`Starts in...3 seconds!`)
- play_tick_sound(0)
- context.log(`NEXT BET: ${_nextBet} bits`)
- context.clearLog()
- context.log(`Starts in...2 seconds!`)
- play_tick_sound(0)
- context.log(`NEXT BET: ${_nextBet} bits`)
- context.clearLog()
- context.log(`Starts in...1 seconds!`)
- play_tick_sound(0)
- context.log(`NEXT BET: ${_nextBet} bits`)
- context.clearLog()
- context.log(`-------STARTED-------`)
- play_tick_sound(1)
- context.log(`NEXT BET: ${_nextBet} bits`)
- context.clearLog()
- if (config.skips_freq.value > 0) await skip_games(context, config.skips_freq.value)
- }
- class SoundEngine{
- constructor() {
- this.id = -1
- this.url = ``
- this.host = `https://raw.githubusercontent.com/ruzli/misc/master/`
- this.format = `.wav`
- this.name = ``
- this.library = []
- this.sound_track = [ `cl_hihat`, `claves`, `conga1`, `cowbell`, `hi_conga`, `hightom`, `rimshot`, `snare`, `tom1`, `sc` ]
- this.muted = false
- this.default_sound_betting = 8
- this.save(`https://freesound.org/data/previews/274/274178_5123851-lq.mp3`)
- this.save(`https://freesound.org/data/previews/411/411639_5121236-lq.mp3`)
- if (config_hided.play_intro ) this.play_raw(this.song(1))
- }
- get song_library(){
- return this.library
- }
- /* Playing sound loop by number or by name from sound track listed below. */
- async sound_loop(sound_number = default_sound_betting(), name){
- await this.play(sound_number, name)
- }
- async sound_beat(multiplier, beat_mode = false, beat_target = undefined) {
- if (multiplier == undefined) {
- console.log(`Something is wrong with sound engine.`)
- await sleep(3000)
- return
- }
- if (beat_mode) {
- if (multiplier < 5) {
- SoundEngine.prototype.sound_loop(8)
- } else if (multiplier < 10) {
- SoundEngine.prototype.sound_loop(1)
- } else if (multiplier < 15) {
- SoundEngine.prototype.sound_loop(2)
- } else if (multiplier < 20) {
- SoundEngine.prototype.sound_loop(5)
- } else if (multiplier < 25) {
- SoundEngine.prototype.sound_loop(4)
- } else if (multiplier < 30) {
- SoundEngine.prototype.sound_loop(6)
- } else if (multiplier < 35) {
- SoundEngine.prototype.sound_loop(7)
- } else if (multiplier < 40) {
- SoundEngine.prototype.sound_loop(0)
- } else {
- SoundEngine.prototype.sound_loop(3)
- }
- } else {
- if (multiplier >= beat_target || beat_target != undefined) {
- SoundEngine.prototype.sound_loop(8)
- } else {
- SoundEngine.prototype.sound_loop(3)
- }
- }
- }
- set default_sound_betting(default_sound_number){
- this.default_sound = default_sound_number
- }
- link(){
- if (this.name != ``){
- return this.url + this.name + this.format
- }
- }
- song(song_number){
- return this.library[song_number]
- }
- save(url){
- this.library.push(url)
- }
- async play(sound_number, name){
- let sound_track = this.sound_track
- let url = this.host
- let format = this.format
- let full_string = url + name + format
- if (name != undefined) {
- full_string = url + name + format
- } else if (sound_number != undefined) {
- full_string = url + sound_track[ sound_number ] + format
- } else {
- console.log(`Sound ${sound_number} not found.`)
- }
- const audio = new Audio(full_string)
- if (!this.muted) await audio.play()
- return new Promise(resolve => audio.onended = resolve)
- }
- async play_raw(url){
- const audio = new Audio(url)
- if (!this.muted) await audio.play()
- return new Promise(resolve => audio.onended = resolve)
- }
- }
- var SE = new SoundEngine;
- async function get_initial_data(context, rolls_to_gather = config.cargo.value){
- results = []
- while(results.length < rolls_to_gather) {
- const { multiplier } = await context.skip();
- results.push(multiplier);
- if (!config_hided.nosound) SE.sound_loop(8)
- }
- }
- async function streakFinder(s=0) {
- if(findStreak == 1){
- return
- }
- findStreak = 1
- profit = 0
- const streakToWait = 7
- const streakTofind = 1.5
- let RETRY = true
- nonce = 0
- streakRolls = 0
- streakLossCount = 0
- var streakskipStep = 1 /* 0 = skip | 1 = bet */
- var streakskip_enabled = true
- var stengine = engine
- if(s==1)await engine.newSeedPair()
- while (RETRY) {
- if(nonce > 100){
- RETRY = false
- await get_initial_data(engine)
- gong()
- }
- console.log(`In a row: ${streakLossCount}`)
- streakRolls++
- const {
- multiplier
- } = await analyzeBet()
- if (multiplier < streakTofind) {
- streakLossCount++
- } else {
- streakLossCount = 0
- }
- if (streakLossCount == streakToWait) {
- console.log(`${streakRolls} streakRolls has pasted to catch streak. Good luck!`)
- await get_initial_data(engine)
- gong()
- RETRY = false
- // await this.stop()
- }
- }
- async function betSize(streakLossCount) {
- if (streakLossCount == streakToWait) {
- console.log(`${streakRolls} streakRolls has pasted to catch streak. Good luck!`)
- await get_initial_data(engine)
- gong()
- RETRY = false
- // await this.stop()
- }
- return 100
- }
- function gong() {
- const audio = new Audio("https://bustadice.com/5bb187b7ef764e76fb519939f77288c1.mp3")
- audio.play()
- return new Promise(resolve => audio.onended = resolve)
- }
- async function analyzeBet() {
- const streakresult = streakskip_enabled ? streakskipStep ? await engine.bet(100, 1.01) : await engine.skip() : await engine.bet(100, 1.01);
- streakskipStep = !streakskipStep;
- return streakresult;
- }
- }
- var RUNNING = true
- var main = async () => {
- if (config_hided.reset_browser_stats_at_begin) this.resetStatistics()
- await get_initial_data(this)
- while(RUNNING){
- //checkBuffs()
- //await streakFinder(1)
- nextBet = roundBit(calcBet())
- vectorApex = calcTarget(results) // Get target
- await checkConditions()
- result = await this.bet(roundBit(nextBet),vectorApex.toFixed(2));
- if (!config_hided.nosound) SE.sound_loop(8)
- results.push(result.multiplier);
- if (result.multiplier < result.target) { // LOSE
- updateProfit(-result.value)
- loses.push(nextBet / 100);
- const loss = loses.reduce((a, b) => a + b);
- if((engine.balance-startingBalance) <= min_Profit/2){
- //engine.stop()
- startingBalance = engine.balance
- findStreak = 0
- //loses = []
- await streakFinder(1)
- await get_initial_data(this)
- }
- } else { // WIN
- loses = []
- updateProfit((result.value * result.target) - result.value);
- if(engine.balance/100 > maxBalance) engine.stop()
- if((engine.balance-startingBalance) >= max_Profit){
- startingBalance = engine.balance
- // findStreak = 0
- // await streakFinder(1)
- await get_initial_data(this)
- }
- }
- }
- };
- async function restart_game(){
- if (engine.balance < locked_balance + config.minProfit.value ){
- locked_balance = engine.balance
- console.log(`Restarting game`)
- await engine.stop()
- //await skip_games(context, config.cargo.value)
- }
- }
- /* Prevent script from lost connection to server */
- while (true) {
- // WATCH FOR ERROR IN MAIN LOOP
- try {await main()} // MAIN LOOP
- catch (error) {
- // ERROR EVENTS TO HANDLE
- if (error.message === "connection closed") {
- await this.log("Connection closed. Restarting script");
- RUNNING = true
- continue;
- } else if (error.message === "insufficient balance") {
- await this.log("Not enough balance to bet");
- } else {
- throw error;
- };
- };
- };
- var config = {
- betBalance: { type: 'multiplier', label: 'Max portion of balance to start bet with.', value: 0.0001 },
- baseBet: { type: 'balance', label: 'Extra amount added to base bet', value: 0 },
- averageVariation: { type: 'multiplier', label: 'Average variation for min/max payout', value: 0.5 },
- maxPayout: { type: 'multiplier', label: 'Upper bound limit on payout', value: 3.5 },
- minPayout: { type: 'multiplier', label: 'Lower bound limit on payout', value: 1.3 },
- cargo: { type: 'number', label: 'Cargo of history length to use for build median', value: 20 },
- minProfit: { type: 'balance', label: 'Minimal profit', value: -50000 },
- maxProfit: { type: 'balance', label: 'Maximal profit', value: 10000 },
- skips_freq: { type: 'number', label: 'Skips after restart', value: 0 },
- reset_profits: { type: 'checkbox', label: 'Reset profit at hitting limit of min/max profits', value: true },
- reset_seed_at_restart: { type: 'checkbox', label: 'On bust seed also will be reset', value: true },
- reset_seed_target_at_restart: { type: 'checkbox', label: 'Reset seed on profit goal complete', value: false },
- stop_on_double_loss: { type: 'checkbox', label: 'Stop on double loss of minProfit', value: true },
- betSpeed: { type: 'number', label: 'Bet Speed(ms)', value: 1 },
- maxBalance: { type: 'number', label: 'Stop script @ Balance bits', value: 6000 },
- };
- var config_hided = {
- fast: false,
- reset_browser_stats_at_begin: true,
- nosound: true,
- play_intro: true,
- debug: true,
- };
- var engine = this
- var locked_balance = this.balance
- var startingBalance = this.balance
- var findStreak = 0
- var streakRolls = 0
- var streakLossCount = 0
- var maxBalance = config.maxBalance.value
- var results = [], loses = [], vectorApex = 0, nextBet = 0, nonce = 1, total_profit = 0;
- var min_Profit = config.minProfit.value, max_Profit = config.maxProfit.value , profit = 0, baseBet = config.baseBet.value, losses = 0, reached = false, total_profit = 0;
- var wagered = 0, gross_profit = 0;
- var minPayout = config.minPayout.value, maxPayout = config.maxPayout.value;
- var normal_bettable = config.betBalance.value;
- var ripped = false
- var hitter_counter = 0, recovery_rolls = 0, defence_rolls = 0;
- var result, profit_risk = 0, wins = 0;
- Array.prototype.median = function (span) {
- let arr = results.slice(0, (span ? Math.max(1, Math.min(50, span)) : 50)).map(a => a.bust).sort((a, b) => { return a - b })
- let mid = arr.length / 2, med = mid % 1 ? arr[mid - 0.5] : (arr[mid - 1] + arr[mid]) / 2;
- return med;
- };
- /***************************************************************** */
- function recovery_mode (state, effect = 0){
- switch (state) {
- case true:
- console.log(`Recovery started!`)
- recovery_rolls = effect;
- case false:
- console.log(`Recovery ended!`)
- hitter_counter = 0;
- }
- }
- function defence_mode (state, effect = 0){
- switch (state) {
- case true:
- console.log(`Defence started!`)
- defence_rolls = effect;
- case false:
- console.log(`Defence ended!`)
- defence_rolls = 0;
- }
- }
- /********************* - Assign to betting - ************************ */
- const origBet = this.bet;
- this.bet = async function () {
- await updateLog()
- nonce++
- return origBet.apply(this, arguments);
- };
- const origSkip = this.skip;
- this.skip = async function () {
- await updateLog()
- nonce++
- return origSkip.apply(this, arguments);
- };
- /************************** - Effects - ************************* */
- function recovery_effect(multiplier_modificator){
- if (hitter_counter < 2) return
- let recovery_multiplier = multiplier_modificator
- let recovery_bettable = config.betBalance.value * recovery_multiplier
- if (recovery_rolls > 0){
- normal_bettable = recovery_bettable;
- recovery_rolls--;
- console.log(`Recovery mode will lasts more ${recovery_rolls} rolls`)
- }
- if (recovery_rolls <= 0) {
- normal_bettable = config.betBalance.value;
- recovery_rolls = 0
- }
- }
- function defence_effect(multiplier_modificator){
- if (hitter_counter < 3) return
- let defence_multiplier = multiplier_modificator
- let defence_bettable = config.betBalance.value / defence_multiplier
- if (defence_rolls > 0){
- //normal_bettable = defence_bettable;
- minPayout = config.minPayout.value + config.averageVariation.value
- maxPayout = config.maxPayout.value + config.averageVariation.value
- defence_rolls--;
- console.log(`Defence mode will lasts more ${recovery_rolls} rolls`)
- } else {
- //normal_bettable = config.betBalance.value;
- minPayout = config.minPayout.value
- maxPayout = config.maxPayout.value
- defence_rolls = 0;
- }
- }
- /*************************** - Targets - **************************** */
- function clampTarget(target) { return Math.max(minPayout, Math.min(maxPayout, target)); }
- function calcTarget(results) {
- const pLen = results.length
- if ( pLen < config.cargo.value) { return; } /* Not enough input to slice. Returning.*/
- const r = results.slice(-config.cargo.value).sort((a, b) => a - b), len = r.length, mid = Math.floor(len / 2)
- return clampTarget((len % 2 ? r[mid] : ((r[mid - 1] + r[mid]) / 2)));
- }
- /************************** - Bets - ************************** */
- function roundBit(bet) { return Math.max(100, Math.round(bet / 100) * 100);}
- const calcBet = () => {
- const betBalPerc = normal_bettable, lossCount = loses.length || 0;
- baseBet = roundBit(config.baseBet.value + (engine.balance * (betBalPerc / (200 - lossCount))));
- vectorApex = calcTarget(results);
- if (!lossCount) { return baseBet; }
- losses = (loses.reduce((a, b) => a + b) * 100);
- nextBet = roundBit((baseBet + losses) / (vectorApex - 1));
- return nextBet;
- };
- /*************************** - Methods - *********************** */
- async function updateLog(){
- var maximum_lose = ` Maximum lose: ${session_win() / 100} `
- let extra = ` Extra base bet ${(baseBet / 100).toFixed()} + `
- let rolls_amount = `Nonce: ${nonce} `
- let Dmode = `[D]`
- let Rmode = `[R]`
- let Bbet = `[B = ${Math.round(normal_bettable).toFixed()}]`
- let HC = `[HC = ${hitter_counter}]`
- if (recovery_rolls > 0){Rmode = `[R = ${recovery_rolls}]`} else {Rmode = ``}
- if (defence_rolls > 0){Dmode = `[D = ${defence_rolls}]`} else {Dmode = ``}
- if (hitter_counter > 0){HC = `[HC = ${hitter_counter}]`} else {HC = ``}
- if (config.baseBet.value == 0){ extra = `` }
- engine.clearLog()
- engine.log(`${rolls_amount}|${extra} | NextBet: ${(losses / 100).toFixed()} / ${vectorApex.toFixed(2)}x = ${( nextBet / 100)} bits | Start Bal: ${startingBalance} | streakRolls: ${streakRolls} | Streak Loss: ${streakLossCount}`)
- if (reached){
- engine.log(`${HC}${Dmode}${Rmode}${Bbet}${maximum_lose}| PROFIT: ${(profit / 100).toFixed(2)} | ${(getTotalProfit())} bits`)
- } else {
- engine.log(`${HC}${Dmode}${Rmode}${Bbet}${maximum_lose}| profit goal: ${max_Profit / 100} | PROFIT: ${(profit / 100).toFixed(2)} | ${(getTotalProfit())} bits`)
- }
- if (config_hided.debug){engine.log(`${min_Profit / 100} | ${config.minProfit.value / 100} | ${session_win() / 100} | ${wins}`)}
- await sleep(config.betSpeed.value);
- }
- function get_random(rnd = 10) { return Math.round(Math.random() * rnd) + 1 }
- function sleep(ms = config.betSpeed.value) { if(ms != 0) { return new Promise(resolve => setTimeout(resolve, ms)) }};
- async function skip_games(context, skips){
- //if (config.skips_freq.value > 0){
- for (let i = 0; i < get_random(skips); i++){
- const { multiplier } = await context.skip();
- }
- //}
- }
- function getProfit(){
- let current_profit = (((wagered + gross_profit) - wagered) / 100).toFixed(2)
- return current_profit
- }
- function getTotalProfit(){
- return (total_profit / 100).toFixed(2)
- }
- function updateProfit(value){
- if (value > 0){
- gross_profit += value
- }
- wagered += Math.abs(value)
- profit += value
- total_profit += value
- }
- async function checkConditions(){
- let _minProfit;
- if (wins == 0) {_minProfit = config.minProfit.value }
- if ((wins * (config.maxProfit.value / 2)) - nextBet < session_win()) {
- loses = []
- wins = 0
- profit = 0
- nextBet = roundBit(calcBet())
- if (config.reset_seed_target_at_restart.value){
- //await generateSeed(engine)
- // findStreak = 0
- // await streakFinder()
- }
- }
- //await getBuffs()
- }
- function session_win(){
- let give_cost = config.maxProfit.value
- if (profit > config.maxProfit.value){
- profit -= give_cost // |> buy
- // </> trade
- wins = wins + 1 // <| receive item
- }
- //nextBet = roundBit(calcBet())
- let formula = 0
- if (wins > 0){
- formula = (wins * config.maxProfit.value) / 2
- } else if (wins <= 0) {
- formula = config.minProfit.value
- }
- return formula
- }
- async function getBuffs() {
- if (engine.balance < locked_balance + config.minProfit.value) {
- await get_initial_data(engine)
- if (config.stop_on_double_loss.value) {
- // engine.log(`Stopped script due loss`)
- // engine.stop()
- findStreak = 0
- await streakFinder(1)
- } else {
- hitter_counter++
- if (hitter_counter >= 1 && recovery_rolls <= 0) {
- recovery_mode(true, 30)
- }
- if (hitter_counter >= 2 && defence_rolls <= 0) {
- defence_mode(true, 50)
- }
- }
- }
- }
- // CHECK FOR ACTIVE EFFECTS
- function checkBuffs() {
- defence_effect(3)
- recovery_effect(3)
- }
- async function generateSeed(context) {
- try {
- const { server_seed_hash } = await context.newSeedPair()
- await context.setClientSeed(server_seed_hash)
- nonce = 1
- }
- catch (e) { console.log(`Seed Pair is already was set and still not used.`) }
- }
- async function play_tick_sound(sound, delay = true){
- let second = 1000
- if (!delay) second = 0
- if (config_hided.fast == false) await sleep(second)
- if (!config_hided.nosound) SE.play_raw(SE.song(sound))
- }
- async function count_down(context){
- let _nextBet = nextBet / 100
- context.log(`Game is restarting!`)
- play_tick_sound(0)
- context.clearLog()
- context.log(`Starts in...3 seconds!`)
- play_tick_sound(0)
- context.log(`NEXT BET: ${_nextBet} bits`)
- context.clearLog()
- context.log(`Starts in...2 seconds!`)
- play_tick_sound(0)
- context.log(`NEXT BET: ${_nextBet} bits`)
- context.clearLog()
- context.log(`Starts in...1 seconds!`)
- play_tick_sound(0)
- context.log(`NEXT BET: ${_nextBet} bits`)
- context.clearLog()
- context.log(`-------STARTED-------`)
- play_tick_sound(1)
- context.log(`NEXT BET: ${_nextBet} bits`)
- context.clearLog()
- if (config.skips_freq.value > 0) await skip_games(context, config.skips_freq.value)
- }
- class SoundEngine{
- constructor() {
- this.id = -1
- this.url = ``
- this.host = `https://raw.githubusercontent.com/ruzli/misc/master/`
- this.format = `.wav`
- this.name = ``
- this.library = []
- this.sound_track = [ `cl_hihat`, `claves`, `conga1`, `cowbell`, `hi_conga`, `hightom`, `rimshot`, `snare`, `tom1`, `sc` ]
- this.muted = false
- this.default_sound_betting = 8
- this.save(`https://freesound.org/data/previews/274/274178_5123851-lq.mp3`)
- this.save(`https://freesound.org/data/previews/411/411639_5121236-lq.mp3`)
- if (config_hided.play_intro ) this.play_raw(this.song(1))
- }
- get song_library(){
- return this.library
- }
- /* Playing sound loop by number or by name from sound track listed below. */
- async sound_loop(sound_number = default_sound_betting(), name){
- await this.play(sound_number, name)
- }
- async sound_beat(multiplier, beat_mode = false, beat_target = undefined) {
- if (multiplier == undefined) {
- console.log(`Something is wrong with sound engine.`)
- await sleep(3000)
- return
- }
- if (beat_mode) {
- if (multiplier < 5) {
- SoundEngine.prototype.sound_loop(8)
- } else if (multiplier < 10) {
- SoundEngine.prototype.sound_loop(1)
- } else if (multiplier < 15) {
- SoundEngine.prototype.sound_loop(2)
- } else if (multiplier < 20) {
- SoundEngine.prototype.sound_loop(5)
- } else if (multiplier < 25) {
- SoundEngine.prototype.sound_loop(4)
- } else if (multiplier < 30) {
- SoundEngine.prototype.sound_loop(6)
- } else if (multiplier < 35) {
- SoundEngine.prototype.sound_loop(7)
- } else if (multiplier < 40) {
- SoundEngine.prototype.sound_loop(0)
- } else {
- SoundEngine.prototype.sound_loop(3)
- }
- } else {
- if (multiplier >= beat_target || beat_target != undefined) {
- SoundEngine.prototype.sound_loop(8)
- } else {
- SoundEngine.prototype.sound_loop(3)
- }
- }
- }
- set default_sound_betting(default_sound_number){
- this.default_sound = default_sound_number
- }
- link(){
- if (this.name != ``){
- return this.url + this.name + this.format
- }
- }
- song(song_number){
- return this.library[song_number]
- }
- save(url){
- this.library.push(url)
- }
- async play(sound_number, name){
- let sound_track = this.sound_track
- let url = this.host
- let format = this.format
- let full_string = url + name + format
- if (name != undefined) {
- full_string = url + name + format
- } else if (sound_number != undefined) {
- full_string = url + sound_track[ sound_number ] + format
- } else {
- console.log(`Sound ${sound_number} not found.`)
- }
- const audio = new Audio(full_string)
- if (!this.muted) await audio.play()
- return new Promise(resolve => audio.onended = resolve)
- }
- async play_raw(url){
- const audio = new Audio(url)
- if (!this.muted) await audio.play()
- return new Promise(resolve => audio.onended = resolve)
- }
- }
- var SE = new SoundEngine;
- async function get_initial_data(context, rolls_to_gather = config.cargo.value){
- results = []
- while(results.length < rolls_to_gather) {
- const { multiplier } = await context.skip();
- results.push(multiplier);
- if (!config_hided.nosound) SE.sound_loop(8)
- }
- }
- async function streakFinder(s=0) {
- if(findStreak == 1){
- return
- }
- findStreak = 1
- profit = 0
- const streakToWait = 7
- const streakTofind = 1.5
- let RETRY = true
- nonce = 0
- streakRolls = 0
- streakLossCount = 0
- var streakskipStep = 1 /* 0 = skip | 1 = bet */
- var streakskip_enabled = true
- var stengine = engine
- if(s==1)await engine.newSeedPair()
- while (RETRY) {
- if(nonce > 100){
- RETRY = false
- await get_initial_data(engine)
- gong()
- }
- console.log(`In a row: ${streakLossCount}`)
- streakRolls++
- const {
- multiplier
- } = await analyzeBet()
- if (multiplier < streakTofind) {
- streakLossCount++
- } else {
- streakLossCount = 0
- }
- if (streakLossCount == streakToWait) {
- console.log(`${streakRolls} streakRolls has pasted to catch streak. Good luck!`)
- await get_initial_data(engine)
- gong()
- RETRY = false
- // await this.stop()
- }
- }
- async function betSize(streakLossCount) {
- if (streakLossCount == streakToWait) {
- console.log(`${streakRolls} streakRolls has pasted to catch streak. Good luck!`)
- await get_initial_data(engine)
- gong()
- RETRY = false
- // await this.stop()
- }
- return 100
- }
- function gong() {
- const audio = new Audio("https://bustadice.com/5bb187b7ef764e76fb519939f77288c1.mp3")
- audio.play()
- return new Promise(resolve => audio.onended = resolve)
- }
- async function analyzeBet() {
- const streakresult = streakskip_enabled ? streakskipStep ? await engine.bet(100, 1.01) : await engine.skip() : await engine.bet(100, 1.01);
- streakskipStep = !streakskipStep;
- return streakresult;
- }
- }
- var RUNNING = true
- var main = async () => {
- if (config_hided.reset_browser_stats_at_begin) this.resetStatistics()
- await get_initial_data(this)
- while(RUNNING){
- //checkBuffs()
- //await streakFinder(1)
- nextBet = roundBit(calcBet())
- vectorApex = calcTarget(results) // Get target
- await checkConditions()
- result = await this.bet(roundBit(nextBet),vectorApex.toFixed(2));
- if (!config_hided.nosound) SE.sound_loop(8)
- results.push(result.multiplier);
- if (result.multiplier < result.target) { // LOSE
- updateProfit(-result.value)
- loses.push(nextBet / 100);
- const loss = loses.reduce((a, b) => a + b);
- if((engine.balance-startingBalance) <= min_Profit/2){
- //engine.stop()
- startingBalance = engine.balance
- findStreak = 0
- //loses = []
- await streakFinder(1)
- await get_initial_data(this)
- }
- } else { // WIN
- loses = []
- updateProfit((result.value * result.target) - result.value);
- if(engine.balance/100 > maxBalance) engine.stop()
- if((engine.balance-startingBalance) >= max_Profit){
- startingBalance = engine.balance
- // findStreak = 0
- // await streakFinder(1)
- await get_initial_data(this)
- }
- }
- }
- };
- async function restart_game(){
- if (engine.balance < locked_balance + config.minProfit.value ){
- locked_balance = engine.balance
- console.log(`Restarting game`)
- await engine.stop()
- //await skip_games(context, config.cargo.value)
- }
- }
- /* Prevent script from lost connection to server */
- while (true) {
- // WATCH FOR ERROR IN MAIN LOOP
- try {await main()} // MAIN LOOP
- catch (error) {
- // ERROR EVENTS TO HANDLE
- if (error.message === "connection closed") {
- await this.log("Connection closed. Restarting script");
- RUNNING = true
- continue;
- } else if (error.message === "insufficient balance") {
- await this.log("Not enough balance to bet");
- } else {
- throw error;
- };
- };
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement