javascript 投注脚本改进-投注随机

q9rjltbz  于 2023-04-10  发布在  Java
关注(0)|答案(2)|浏览(115)

我试图通过添加一些随机性来改进下面的脚本。因为现在它只对“double_your_btc_bet_hi_button”id下注。
我的想法是生成一个随机数,并根据其结果进行投注。但我不知道我supose如何做到这一点。
另一个下注按钮的ID是“double_your_btc_bet_lo_button”。

var minstake   = 0.00000001;  // valor base
var autorounds = 100;         // n° de rolls
var handbrake  = 0.0001;  // valor lose pause game
var autoruns   = 1;

function playnow() {
   if (autoruns > autorounds ) { console.log('Limit reached'); return; }
   document.getElementById('double_your_btc_bet_hi_button').click();
   setTimeout(checkresults, 123);
   return;}
function checkresults() {
   if (document.getElementById('double_your_btc_bet_hi_button').disabled === true) {
          setTimeout(checkresults, 246);
          return;
   }
   var stake = document.getElementById('double_your_btc_stake').value * 1;
   var won = document.getElementById('double_your_btc_bet_win').innerHTML;
   if (won.match(/(\d+\.\d+)/) !== null) { won = won.match(/(\d+\.\d+)/)[0]; } else { won = false; }
   var lost = document.getElementById('double_your_btc_bet_lose').innerHTML;
   if (lost.match(/(\d+\.\d+)/) !== null) { lost = lost.match(/(\d+\.\d+)/)[0]; } else { lost = false; }
   if (won && !lost) { stake = minstake; console.log('Bet #' + autoruns + '/' + autorounds + ': Won  ' + won  + ' Stake: ' + stake.toFixed(8)); }
   if (lost && !won) { stake = lost * 2.1; console.log('Bet #' + autoruns + '/' + autorounds + ': Lost ' + lost + ' Stake: ' + stake.toFixed(8)); }
   if (!won && !lost) { console.log('Something went wrong'); return; }
   document.getElementById('double_your_btc_stake').value = stake.toFixed(8);
   autoruns++;
   if (stake >= handbrake) {
          document.getElementById('handbrakealert').play();
          console.log('Handbrake triggered! Execute playnow() to override');
       return;
   }
   setTimeout(playnow, 111);
   return;

   }playnow()
e4yzc0pl

e4yzc0pl1#

我试过使用Math.random,但现在它只下注lo,只玩一次。

var minstake   = 0.00000001;  // valor base
  var autorounds = 99999;         // n° de rolls
  var handbrake  = 0.0001;  // valor lose pause game
  var autoruns   = 1;

 function getRandomNumber() {Math.floor(Math.random() * 2) + 1;
   };

 function playnow() {
     if (autoruns > autorounds ) { console.log('Limit reached'); return; }

     if (getRandomNumber!==1) {
            document.getElementById('double_your_btc_bet_lo_button').click();
            setTimeout(checkresultslo, 123);
            return;
            function checkresultslo() {
            if (document.getElementById('double_your_btc_bet_lo_button').disabled === true) {
            setTimeout(checkresultslo, 246);
            return;}}}
     if (getRandomNumber!==2) {
            document.getElementById('double_your_btc_bet_hi_button').click();
            setTimeout(checkresultshi, 123);
            return;
            function checkresultshi() {
            if (document.getElementById('double_your_btc_bet_hi_button').disabled === true) {
            setTimeout(checkresultshi, 246);
            return;}}}
       }
     var stake = document.getElementById('double_your_btc_stake').value * 1;
     var won = document.getElementById('double_your_btc_bet_win').innerHTML;
     if (won.match(/(\d+\.\d+)/) !== null) { won = won.match(/(\d+\.\d+)/)[0]; } else { won = false; }
     var lost = document.getElementById('double_your_btc_bet_lose').innerHTML;
     if (lost.match(/(\d+\.\d+)/) !== null) { lost = lost.match(/(\d+\.\d+)/)[0]; } else { lost = false; }
     if (won && !lost) { stake = minstake; console.log('Bet #' + autoruns + '/' + autorounds + ': Won  ' + won + ' Stake: ' + stake.toFixed(8)); }
     if (lost && !won) { stake = lost * 2.1; console.log('Bet #' + autoruns + '/' + autorounds + ': Lost ' + lost + ' Stake: ' + stake.toFixed(8)); }
     if (!won && !lost) { console.log('Something went wrong');}
     document.getElementById('double_your_btc_stake').value = stake.toFixed(8);
     autoruns++;
     if (stake >= handbrake) {
            document.getElementById('handbrakealert').play();
            console.log('Handbrake triggered! Execute playnow() to override');
     }
     setTimeout(playnow, 111);
     playnow()
x3naxklr

x3naxklr2#

if(Math.random() > 0.2) $('#double_your_btc_bet_lo_button').click();//20%
    else $('#double_your_btc_bet_hi_button').click();

相关问题