-
Notifications
You must be signed in to change notification settings - Fork 1
/
martingale.js
86 lines (79 loc) · 2.56 KB
/
martingale.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
var satoshi = require('./api.js');
var usr = 'c4049a9f3749d2967a275543453fb403';
var myRoll = 5;
var initialBet = 100;
var currentBet = initialBet;
var result;
var resultSet = false;
var betPercantage = 49.049;
var betCount = 100;
var betQueue = betCount;
var exchangeRate = 1;
var losing = false;
satoshi.newRound(usr, function(data) {
firstRound(data);
});
function firstRound(data) {
betCount = betCount - 1;
console.log("");
console.log("Bet " + betCount + "/" + betQueue);
satoshi.placeBet({
userHash: usr,
bet: currentBet,
gameId: data.id,
serverHash: data.hash,
clientRoll: myRoll,
belowRollToWin: Math.floor((65536/100*betPercantage)-1)
}, anotherRound);
}
var anotherRound = function(data) {
if (resultSet === false) {
result = data.userBalanceInSatoshis;
resultSet = true;
}
if (data.bet.result == 'win') {
console.log("Bet " + betCount + "/" + betQueue);
console.log("Current Balance:" + data.userBalanceInSatoshis * exchangeRate);
console.log("Current Result:" + (data.userBalanceInSatoshis - result) * exchangeRate);
losing = false;
currentBet = initialBet;
} else if (data.bet.result == 'loss') {
console.log("Bet " + betCount + "/" + betQueue + " 💥");
console.log("Current Balance:" + data.userBalanceInSatoshis * exchangeRate);
console.log("Current Result:" + (data.userBalanceInSatoshis - result) * exchangeRate);
losing = true;
currentBet = currentBet * 2;
} else {
console.log("Bug Next.");
}
console.log("Next bet: " + currentBet * exchangeRate);
if (betCount > 0) {
betCount = betCount - 1;
console.log("");
satoshi.placeBet({
userHash: usr,
bet: currentBet,
gameId: data.nextRound.id,
serverHash: data.nextRound.hash,
clientRoll: myRoll,
belowRollToWin: Math.floor((65536/100*betPercantage)-1)
}, anotherRound);
} else if (losing === true) {
console.log("Bet cycle is over, winning back remaining…");
console.log("");
satoshi.placeBet({
userHash: usr,
bet: currentBet,
gameId: data.nextRound.id,
serverHash: data.nextRound.hash,
clientRoll: myRoll,
belowRollToWin: Math.floor((65536/100*betPercantage)-1)
}, anotherRound);
} else {
console.log("");
console.log("Bet cycle finished.");
console.log("Final Balance: " + data.userBalanceInSatoshis * exchangeRate);
console.log("Result: " + (data.userBalanceInSatoshis - result) * exchangeRate);
return;
}
};