ruzli
8/29/2018 - 3:12 AM

1.7 with sleep at streaks

1.7 with sleep at streaks

const baseBet = 1
const baseTarget = 1.7
const maximumBet = 100000
const multiplierBet = 2.41
const minimalToRunScript = 300

const changeSeed = true

const changeSeedAfterStreakOf = 3
/* Sleep Levels */
let sleep2 = 1000
let sleep3 = 1000
let sleep4 = 1400
let sleep5 = 2000
let sleep6 = 2000
let sleep7 = 3000

let losses = 1
let bet = 1
let engine = this
let tbet = bet
let lost = 0
let wins = 0

var since = new Date()
var d = new Date()

while(true){ 
    if (this.balance / 100 < minimalToRunScript){
        this.log('Minimal balance is reached, stopping script')
        await this.stop()
    }
    if (bet * losses >= maximumBet){losses = 1}
    tbet = Math.floor(toSatoshi(bet))
    const { multiplier} = await this.bet(toSatoshi(toBits(tbet) * Math.floor(toSatoshi(toBits(losses)))), baseTarget)
    if (lost == 2){ await sleep(sleep2) }
    if (lost == 3){ await sleep(sleep3) }
    if (lost == 4){ await sleep(sleep4) 
    gong()}
    if (lost == 5){ await sleep(sleep5) 
    gong()}
    if (lost == 6){ await sleep(sleep6) }
    gong()
    if (lost == 7){ await sleep(sleep7) }
    gong()
    if (lost >= 8){ await sleep(5000) 
    gong()
    elapsedtime()}
    this.log(`Current balance ${toBits(this.balance)}`)
 
    if (multiplier < baseTarget){     /*   [LOSS]   */
        lost++
        wins = 0
        if(changeSeed == true && lost == changeSeedAfterStreakOf){
            await generateSeed()
            collectSound()
        }
    
        //bet = (losses * baseBet)
        if (baseBet * losses >= maximumBet){
            //losses--
        }else{
        losses = losses * multiplierBet +Math.floor(multiplierBet/0.7)
        }
    }else{                               /*    [WIN]   */
        wins++
        if (wins > 2){ lost = 0 }
 
     
        losses = Math.round(losses / multiplierBet)
          if (losses <= baseBet){
              losses = 1
          }
         // bet = baseBet - bet
        }  
}
   
  function gong() {
    const audio = new Audio("https://bustadice.com/5bb187b7ef74e76fb519939f77288c1.mp3")
    audio.play()
    return new Promise(resolve => audio.onended = resolve)
  }
  function collectSound(){
    let pathStr = "http://kz-developer.ru/sounds/chisHandle" + getRandomInt(6,7) + ".wav"      
      const audio = new Audio (pathStr)
      audio.play()
      return new Promise(resolve => audio.onended = resolve)
  }
 
  async function generateSeed(){
      const { server_seed_hash } = await engine.newSeedPair()
      engine.log(`Server seed: ${server_seed_hash}`)
      try {
          const clientSeed = randomSeed()
          await engine.setClientSeed(clientSeed)
          engine.log(`Seed was set to: ${clientSeed}`)
      }
      catch(e){
          engine.log(`Client seed already was reset and not used`)
      }
  }
 
  function randomSeed(){
      const words = ['Alegra ','Bravon ','Charlik ','Delago ','Zecho ','Forextromb ','Hotelka ','Gnomus ','Addicted ','Aurelia ','Zigalo ','Wiverma ',
      'Mariner ','Octoberfest ','Nascar ','Papaja ','Alberts ','Gomus ','Fierra ','GTO ','Unicorn ','Vicantus ','Siski ','Xavier ','Poiuplet ','Antutulika ']
 
      return words[Math.floor(words.length * Math.random())] + words[Math.floor(words.length * Math.random())] + words[Math.floor(words.length * Math.random())]
  }
  function getRandomInt(min, max){
      return Math.floor(Math.random() * (max - min)) + min;
  }
  function toBits(satoshi){
    return satoshi / 100
  }
  function toSatoshi(bits){
    return bits * 100
  }
  function sleep(ms) {
    return new Promise(resolve => setTimeout(resolve, ms))
  }
  function elapsedtime() {
    let sincePast = new Date()
    let sincePastDate = d - sincePast
    engine.log(`Since last time show: ${sincePastDate.getHours()}:${sincePastDate.getMinutes()}:${sincePastDate.getSeconds()}`)
    d = new Date()
  }