View difference between Paste ID: xuP1XUbK and pyQmtuZu
SHOW: | | - or go back to the newest paste.
1
var config = {
2
    n: { value: '1', type: 'text', label: 'Rounds since last game >= multiplier (n)'},
3
    t: { value: 2, type: 'multiplier', label: 'Multiplier (t)'},
4
    wager: { value: 0, type: 'balance', label: 'Wager'}
5
};
6-
6+
 
7
// Globals
8
const n = parseInt(config.n.value);
9
const t = config.t.value;
10
const wager = config.wager.value;
11
let m = 0;
12-
12+
 
13
// Ensure user input makes sense
14
if(isNaN(n)) {
15
    stop('n must be an integer');
16
} else if(n < 0) {
17
    stop('n cannot be less than 0');
18
} else if(n === 0) {
19
    log('Warning: n is 0, the script will be betting on every game');
20
} else if(t > 1000) {
21
    log('Warning: You are using a very high multiplier');
22
    log('Using large values can cause the script to freeze temporarily');
23
}
24-
24+
 
25
// Recursive function to find the number of games since a multiplier
26
function findM(m, hash) {
27
  return new Promise((resolve, reject) => {
28-
    gameResultFromHash(hash).then((result) => {
28+
    let result = gameResultFromHash(hash);
29
      if(result >= t) {
30
        resolve(m);
31
      } else {
32-
        SHA256(hash).then((newHash) => {
32+
        let newHash = SHA256(hash);
33
          findM(m + 1, newHash).then((m) => {
34
            resolve(m);
35
          });
36-
        });
36+
37
  });
38-
    });
38+
39
 
40
// Place a bet with the specified options
41-
41+
42
  log('Placing bet');
43
  checkBalance();
44
  engine.bet(wager, t);
45
}
46
 
47
// Pre-check before betting
48-
48+
49
  if(userInfo.balance < config.wager.value) {
50
    stop('Insufficient balance');
51
  }
52
}
53
 
54
// Happens after the initial "sync", and after every game ending
55-
55+
56
  if(engine.history.first().bust >= t && !initial) {
57
    log(`Multiplier for finished game was >= ${t}x, resetting count. `);
58
    m = 0;
59
    log(`${n-m} round(s) of multipliers < ${t}x before betting remaining`);
60
  } else {
61
    if(!initial) m++;
62
    if(m >= n) {
63
      placeBet();
64
      m = 0;
65
    } else {
66
      log(`${n-m} round(s) of multipliers < ${t}x before betting remaining`);
67
    }
68
  }
69
}
70
 
71
findM(0, engine.history.first().hash).then((value) => {
72-
72+
73
  m = value;
74
  log(`${m} game(s) since multiplier of or at least ${t}x`);
75
  checkParams(true);
76
  // Set up event listeners to continue the script after the initial stage
77
  engine.on('GAME_ENDED', () => {
78
    checkParams();
79
  });
80
});