//config
minbet=1;// gia tri ***
heso=[]; // day so
maxCicle=50; //lượt quay
TimeStop=60*60;
bolUn=false;
pushHs=function(){
    heso.push(2);
    heso.push(3);
    heso.push(5);
    heso.push(6);
//2,3,5,6
};
pushHs();
//variable
***=minbet;
fHs=0;
nHs=0;
stop=false;
//log
wn=0;
total=0;
wsr=0;
hsm=0;
lstBtc=$('#balance').text();
lstBtc*=100000000;
profit=0;
wprofit=0;
//wait
wait=400;
iwait=400;
fbalance=0;
balance=0;
timestap=Date.now();
timeline=0;
cicle=0;
maxHs=0;
printLog=function(){
    console.log("Total/Win: "+total+"/"+wn+"\nWSR/HSM: "+wsr+"/"+hsm+" win chance: "+wprofit+"% profit: "+profit+" Cicle: "+(cicle+1)+" Time: "+timeline+"s");
};
Float2String=function(num){
    var div=num/100000000;
    if(div.toString().indexOf("e")==-1)
        return div.toString();
    var s=num/10000+"";
    f=s.substring(0,2);
    s=s.substring(2);
    return f+"0000"+s;
};
betFun=function(){
    var win=$('#double_your_btc_bet_win').text();
    if(win!=""){
        //win
        wn++;
        wsr++;
        hsm=0;
    }else{
        if(nHs!=0){
            if(fHs!=0)
                heso.unshift(fHs);
            heso.push(nHs);
            heso.push(fHs+nHs);
        }
        hsm++;
        wsr=0;
    }
  
    if(heso.length==0){
        //calBtc();
        //printLog();
        pushHs();
        cicle++;
//        return;
    }
  
    if(cicle==maxCicle){
        calBtc();
        printLog();
        console.log("MaxHs: "+maxHs);
        return;
    }
  
    timeline=Math.round((Date.now()-timestap)/1000);
  
    if(heso.length>1){
        fHs=heso.shift();
        nHs=heso.pop();
    }
    else{
        nHs=heso.pop();
        fHs=0;
    }
  
    printHs();
    console.log("Heso: "+(fHs+nHs));
    if(fHs+nHs>maxHs)
        maxHs=fHs+nHs;
    ***=minbet*(fHs+nHs);
    hsm++;
      
   $('#double_your_btc_stake').val(Float2String(***));
   fbalance=balance;
 
    if(!stop)
       nextStep();
};
calBtc=function(){
    balance=$('#balance').text();
    balance*=100000000;
  
    profit=balance-lstBtc;
    wprofit=(wn*100)/total;
};
printHs=function(){
    console.log(fHs+"-"+heso+"-"+nHs);
}
nextStep=function(){
    //balance
    calBtc();
  
    if(balance!=fbalance||bolUn){
        bolUn=false;
        $('#double_your_btc_bet_hi_button').click();
        total++;
        printLog();
        setTimeout(betFun, iwait + Math.round(Math.random() * 1000));
    }else{
        console.log("wait");
        setTimeout(nextStep,wait);
    }
};
betFun();