Advertisement
CrimsonNoble

Part 3 : Storing and Displaying Stats

Mar 1st, 2015
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /////////////////////////////////////////
  2. //Recording and Displaying Stats       //
  3. /////////////////////////////////////////
  4. //~CrimsonNoble
  5.  
  6. //Base Bet Settings//                  
  7. basebet       =1;  // Amount in satoshi
  8. basecondition ='<'; // '<' for under '>' for over
  9. winchance     =0.01;// 49.5 has 2x payout...if your rolling under,
  10. //Other Settings////
  11. win_increment  =0;    //Increase bet by this amount(in satoshi) when you win.
  12. win_multiplier =1;    //Multiply bet by this amount when you win.(1 is no change)
  13. win_reset      =false;//If true when you win bet amount goes back to base bet.
  14. loss_increment =0;    //Increase bet by this amount(in satoshi) when you lose.
  15. loss_multiplier=1;    //Multiply bet by this amount when you lose.(1 is no change)
  16. loss_reset     =false;//If true when you lose bet amount goes back to base bet.
  17. min_wager      =0;    //Bet will never go lower then this.(satoshi)
  18. max_wager      =99999;//Bet will never go higher then this.(satoshi)
  19. roll_remaining =true; //When true if your balance is too low to make a bet then you bet what you have left.
  20. stop_on_win    =true;
  21.  
  22. switch_hilow     = 0;    //switches from over to under/vice vesa every X rolls, 0 means no switching
  23. random_condition =false; //Randomly picks high or low each roll, Overrides switch_hilow
  24. //Assign Base Values////
  25. truebet=basebet;truecondition=basecondition;pause=true;balance=0;hilow_count=0;session_profit=0;max_redstreak=0;redstreak=0;
  26. xlossdata=0;
  27. //Load previously stored information//
  28. if(!isNaN(localStorage.session_profit)){session_profit=Number(localStorage.session_profit);}
  29. if(!isNaN(localStorage.max_redstreak)) {max_redstreak=Number(localStorage.max_redstreak);}
  30. if(!isNaN(localStorage.redstreak))     {redstreak=Number(localStorage.redstreak);}
  31. ////////////////////////
  32. gui_startBot="<center><button style='background-color:red'   onclick='pause=!pause;startBot();'>Start Bot</button><br></center>";
  33. gui_pauseBot="<center><button style='background-color:green' onclick='pause=!pause;pauseBot();'>Pause Bot</button><br></center>";
  34. $('.hero__main').append("<div id='bot_controls' style='background-color:black'>"+gui_startBot+"</div>");
  35. $('.hero__main').append("<div id='bot_stats' style='background-color:black'></div>");
  36. $('.hero__main').append("<div id='resetswitch' style='background-color:black'><center><button onclick='reset_stats();'>Reset Session</button></center></div>");
  37.                  
  38. bot_controls=document.getElementById('bot_controls');
  39. bot_stats   =document.getElementById('bot_stats');  
  40.                                                                        
  41. setInterval(function (){
  42.   if(pause===false){  
  43.    if(truebet>max_wager){truebet=max_wager;}
  44.    if(truebet<min_wager){truebet=min_wager;}
  45.    if(roll_remaining===true && balance<truebet && balance>1){
  46.       betData = {
  47.           amount: Math.floor(balance),
  48.           condition: truecondition,
  49.           target: winchance
  50.       }  
  51.     }else{    
  52.       betData = {
  53.           amount: Math.floor(truebet),
  54.           condition: truecondition,
  55.           target: winchance
  56.       }
  57.     }
  58.     $.ajax({
  59.                 url: 'https://api.primedice.com/api/bet?access_token='+localStorage.token,
  60.                 type: 'POST',
  61.                 data: betData,
  62.                 datatype: 'json',
  63.                 async: true,
  64.                 success: function (data, textStatus, jqXHR){
  65.                   balance=data.user.balance-1;
  66.                   session_profit+=data.bet.profit;
  67.                   if(switch_hilow>0){
  68.                       hilow_count++;
  69.                       if(hilow_count>=switch_hilow){
  70.                           hilow_count=0;
  71.                           if(truecondition=='<'){truecondition='>';}
  72.                           else{truecondition='<';}                    
  73.                           winchance-=100;
  74.                           winchance*=-1;    
  75.                       }
  76.                   }
  77.                   if(random_condition===true){
  78.                         var rnd=Math.floor((Math.random()*2)+1);  
  79.                         if(rnd==1){newcondition='>';}else{newcondition='<';}
  80.                         if(newcondition!=truecondition){
  81.                           truecondition=newcondition;
  82.                           winchance-=100;
  83.                           winchance*=-1;      
  84.                         }
  85.                   }
  86.                   if(redstreak>max_redstreak){max_redstreak=redstreak;}
  87.                   if(session_profit>0){session_profitColor="<font color='green'>";}
  88.                   else{session_profitColor="<font color='red'>";}
  89.                   bot_stats.innerHTML="Statistics:"+
  90.                                       "<br>Current Bet: "+Math.floor(truebet)+
  91.                                       "<br>Session Profit: "+session_profitColor+session_profit+"</font>"+
  92.                                       "<br>RedStreak: "+redstreak+"("+max_redstreak+")";
  93.                   if(data.bet.win===true){        //Bet Won://
  94.                         truebet*=win_multiplier;
  95.                         truebet+=win_increment;
  96.                         if(win_reset===true){truebet=basebet;}  
  97.                         redstreak=0;
  98.                         if(stop_on_win===true){pause=true;}
  99.                   }else{                          //Bet Lost://
  100.                         truebet*=loss_multiplier;
  101.                         truebet+=loss_increment;
  102.                         if(loss_reset===true){truebet=basebet;}  
  103.                         redstreak++;                      
  104.                   }    
  105.                 $('.btn__text.select div').html("Balance:"+(balance/100000000).toFixed(8));                                  
  106.                 localStorage.session_profit= Number(session_profit);
  107.                 localStorage.max_redstreak = Number(max_redstreak);
  108.                 localStorage.redstreak     = Number(redstreak);                                  
  109.                 }
  110.     });    
  111.   }  
  112. }, 150);
  113.  
  114. function reset_stats(){
  115.     localStorage.session_profit=0;
  116.     localStorage.max_redstreak =0;
  117.     localStorage.redstreak =0;
  118.     session_profit=0;
  119.     max_redstreak =0;
  120.     redstreak=0;
  121.     xlossdata=0;
  122. }
  123.  
  124. function pauseBot(){pause=true; bot_controls.innerHTML=gui_startBot;}
  125. function startBot(){pause=false;bot_controls.innerHTML=gui_pauseBot;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement