Primedice 2
Primedice 2
var options = {
compressed: true,
follow_max: 5,
rejectUnauthorized: true,
timeout: 20000,
user_agent: 'ChaosBot/0.2.1',
follow_set_cookies: true
}
needle.defaults(options);
function onErr(err) {
console.log(err);
return 1;
}
var profiles = [
{
target: 98,
condition: '<',
amount: 0,
cost: 0,
maxchance: 98,
minchance: 0.01,
bankat: 0,
stoplossenabled: false,
maxstreakcost: 0,
rnd: false,
mode2: true,
mode2zig: false,
stepped: false,
static: false,
username: 'user1',
password: 'pass1',
token: '',
bankuser: 'bank'
}, {
target: 99.93,
condition: '>',
amount: 1,
cost: 966666,
maxchance: 98,
minchance: 0.06,
bankat: 0,
stoplossenabled: false,
maxstreakcost: 0,
rnd: false,
mode2: true,
mode2zig: false,
stepped: true,
static: false,
username: 'user2',
password: 'pass2',
token: '',
bankuser: 'bank'
}
];
var lowgaps = [
{ chance: 0.01, nonce: -1, score: 0 },
{ chance: 0.02, nonce: -1, score: 0 },
{ chance: 0.03, nonce: -1, score: 0 },
{ chance: 0.04, nonce: -1, score: 0 },
{ chance: 0.05, nonce: -1, score: 0 },
{ chance: 0.06, nonce: -1, score: 0 },
{ chance: 0.07, nonce: -1, score: 0 },
{ chance: 0.08, nonce: -1, score: 0 },
{ chance: 0.09, nonce: -1, score: 0 },
{ chance: 0.1, nonce: -1, score: 0 },
{ chance: 0.15, nonce: -1, score: 0 },
{ chance: 0.2, nonce: -1, score: 0 },
{ chance: 0.25, nonce: -1, score: 0 },
{ chance: 0.3, nonce: -1, score: 0 },
{ chance: 0.4, nonce: -1, score: 0 },
{ chance: 0.5, nonce: -1, score: 0 },
{ chance: 0.75, nonce: -1, score: 0 },
{ chance: 1.0, nonce: -1, score: 0 },
{ chance: 1.5, nonce: -1, score: 0 },
{ chance: 2.0, nonce: -1, score: 0 },
{ chance: 5.0, nonce: -1, score: 0 },
{ chance: 10.0, nonce: -1, score: 0 },
{ chance: 20.0, nonce: -1, score: 0 },
{ chance: 30.0, nonce: -1, score: 0 },
{ chance: 40.0, nonce: -1, score: 0 },
{ chance: 49.0, nonce: -1, score: 0 },
{ chance: 60.0, nonce: -1, score: 0 },
{ chance: 70.0, nonce: -1, score: 0 },
{ chance: 80.0, nonce: -1, score: 0 },
{ chance: 90.0, nonce: -1, score: 0 },
{ chance: 95.0, nonce: -1, score: 0 }
];
var highgaps = [
{ chance: 0.01, nonce: -1, score: 0 },
{ chance: 0.02, nonce: -1, score: 0 },
{ chance: 0.03, nonce: -1, score: 0 },
{ chance: 0.04, nonce: -1, score: 0 },
{ chance: 0.05, nonce: -1, score: 0 },
{ chance: 0.06, nonce: -1, score: 0 },
{ chance: 0.07, nonce: -1, score: 0 },
{ chance: 0.08, nonce: -1, score: 0 },
{ chance: 0.09, nonce: -1, score: 0 },
{ chance: 0.1, nonce: -1, score: 0 },
{ chance: 0.15, nonce: -1, score: 0 },
{ chance: 0.2, nonce: -1, score: 0 },
{ chance: 0.25, nonce: -1, score: 0 },
{ chance: 0.3, nonce: -1, score: 0 },
{ chance: 0.4, nonce: -1, score: 0 },
{ chance: 0.5, nonce: -1, score: 0 },
{ chance: 0.75, nonce: -1, score: 0 },
{ chance: 1.0, nonce: -1, score: 0 },
{ chance: 1.5, nonce: -1, score: 0 },
{ chance: 2.0, nonce: -1, score: 0 },
{ chance: 5.0, nonce: -1, score: 0 },
{ chance: 10.0, nonce: -1, score: 0 },
{ chance: 20.0, nonce: -1, score: 0 },
{ chance: 30.0, nonce: -1, score: 0 },
{ chance: 40.0, nonce: -1, score: 0 },
{ chance: 49.0, nonce: -1, score: 0 },
{ chance: 60.0, nonce: -1, score: 0 },
{ chance: 70.0, nonce: -1, score: 0 },
{ chance: 80.0, nonce: -1, score: 0 },
{ chance: 90.0, nonce: -1, score: 0 },
{ chance: 95.0, nonce: -1, score: 0 }
];
var ownuserinfo;
var betres;
var balance = 0;
var startbalance = 0;
var winstreak = 0;
var losestreak = 0;
var lasttarget = 0;
var lastroll = 0.0;
var lastcondition = '<';
var lastbet = amount;
var lastwon = false;
var totalbet = 0;
var banked = 0;
var losses = 0;
var wins = 0;
return value.join('');
}
function login() {
var chunk;
while (chunk = this.read()) {
token = chunk.access_token;
}
}
function loginend() {
needle.get(url + '/users/1?access_token=' + token).on('readable',
getownuserinfo).on('end', getownuserinfoend);
if(balance < 1) {
console.log("Balance is less than 1 satoshi, waiting
for funds... ");
amount = 0;
needle.get(url + '/users/1?access_token=' +
token).on('readable', getownuserinfo).on('end', getownuserinfoend);
setTimeout(betend, 20000);
return;
}
rebet()
}
}
, 300);
}
function bank() {
var res;
var chunk;
while (chunk = this.read())
res = chunk;
function bankend() {
}
function bet() {
betres = null;
var res;
var chunk;
while (chunk = this.read())
res = chunk;
if(typeof(res.user) != 'undefined') {
betres = res.bet;
balance = res.user.balance;
beterr = false;
} else {
console.log('error, retrying bet');
beterr = true;
}
if(betres == null)
beterr = true;
if(beterr)
betres = null;
if(betres != null)
lastbetid = betres.id;
else
lastbetid = 0;
if(beterr)
console.log(res.toString())
}
var lastbetid = 0;
minchance = Math.round(minchance*100)/100;
maxchance = Math.round(maxchance*100)/100;
minchance = Math.round(minchance*100)/100;
maxchance = Math.round(maxchance*100)/100;
function betend() {
if(betres != null && betres.id == lastbetid) {
if(betres.win) {
if(losestreak > 0) {
losestreak = 0;
winstreak = 1;
} else {
winstreak++;
}
wins++;
} else {
if(winstreak > 0) {
winstreak = 0;
losestreak = 1;
} else {
losestreak++;
}
losses++;
}
banked += bankamount;
balance -= bankamount;
startbalance = balance;
needle.post(url + '/tip?access_token=' + token, {username:
bankuser, amount: bankamount}).on('readable', bank).on('end', bankend);
//bankat += 200000;
}
lastbetid = 0;
if (first) {
first = false;
setTimeout(rebet, waittime);
}
var amountsave = 0;
var betlog;
var fs = require('fs');
readbetlog();
function readbetlog() {
var data = fs.readFileSync('bet_log-' + profile.username + '.txt');
if(data == null || data == '') {
console.log('Error reading bet log.')
} else {
console.log('Bet log read successfully.');
console.log(data.toString());
betlog = JSON.parse(data);
}
}
function writebetlog() {
if(!fs.writeFileSync('bet_log-' + profile.username + '.txt',
JSON.stringify(betlog)))
console.log('Bet log saved.');
else
console.log('Error saving bet log.');
}
function getpayout(chance) {
return roundtoprecision(100./chance*0.99, 5);
}
if(!stepped) {
while(wager > 0 && ((wager-1) * payout)-(wager-1) >= streakCost +
minprofit) {
wager -= 1;
}
}
if(wager < 1)
wager = 1;
return wager;
}
function settarget(chance, conditionhigh) {
if (conditionhigh) {
target = 99.99-chance;
condition = '>';
} else {
target = chance;
condition = '<';
}
}
} else {
}
}
if (conditionhigh) {
target = targetroll;
chance = 99.99-target;
condition = '>';
} else {
target = targetroll
chance = target;
condition = '<';
}
return chance;
}
function getchance() {
if (profile.condition == '>') {
return (9999-profile.target*100)/100;
} else {
return profile.target;
}
}
var maxbalance = 0;
var rolltarget = {
target: 0,
condition: '>'
};
function rebet() {
if(beterr || betres == null) {
needle.post(url + '/bet?access_token=' + token, {
amount: amount,
target: target,
condition: condition
}).on('readable', bet).on('end', betend);
return;
}
if(balance < 1) {
if(!broke) {
broke = true;
amountsave = amount;
}
amount = 0;
needle.get(url + '/users/1?access_token=' + token).on('readable',
getownuserinfo).on('end', getownuserinfoend);
setTimeout(betend, 15000);
return;
}
lastwon = betres.win;
lastroll = betres.roll;
lasttarget = betres.target;
lastcondition = betres.condition;
updategaps(betres.nonce, lastroll);
var lowgap = gethighgapscore(lowgaps, betres.nonce);
var highgap = gethighgapscore(highgaps, betres.nonce);
if(lastwon) {
if(raised) {
amountsave = 0;
raised = false;
}
}
if(resumetarget) {
if((resumetarget.condition == '>' && lastroll > resumetarget.target) ||
(resumetarget.condition == '<' && lastroll <
resumetarget.target)) {
resumetarget = null;
}
}
if(lastwon)
currlevel = 0;
if(!vgap.vgap) {
if(ishighv) {
vgap.vgap = highvgap;
vgap.islow = false;
} else {
vgap.vgap = lowvgap;
vgap.islow = true;
}
if(first && vgap.vgap.chance < profile.minchance) {
vgap.vgap.chance = profile.minchance;
if(vgap.islow && profile.condition == '>')
vgap.islow = false;
else if(!vgap.islow && profile.confition == '<')
vgap.islow = true;
onswitch = true;
}
//console.log(lowvgap, highvgap, vgap, levels, currlevel)
}
if(lastwon) {
losestreakcost = 0;
currlevel++;
if(profile.rnd) {
if(condition == '<')
condition = '>';
else
condition = '<';
if(condition == '>')
target = 99.99-profile.maxchance;
else
target = profile.maxchance;
}
if(profile.mode2) {
currpayout = getpayout(profile.maxchance);
}
} else {
target = lastroll;
}
if(resumetarget) {
if(!profile.mode2) {
target = resumetarget.target;
condition = resumetarget.condition;
}
losestreakcost -= resumetarget.cost;
resumetarget = null;
}
mode2first = true;
onswitch = false;
mode2zigpaydirup = true;
} else {
var chance = 0;
if(condition == '<') {
chance = target;
} else {
chance = 99.99-target;
}
if (ishighv) {
condition = '>';
chance = switchhighvgap.chance;
vgap.islow = false;
vgap.vgap = switchhighvgap;
} else {
condition = '<';
chance = switchlowvgap.chance;
vgap.islow = true;
vgap.vgap = switchlowvgap;
}
currlevel += 1+extralevel;
if(currlevel >= maxlevel)
currlevel = maxlevel-1;
profile.minchance = chance;
//console.log(vgap);
} else {
var minchance = profile.minchance;
var maxchance = profile.maxchance;
if(condition == '<') {
target = chance;
} else {
target = 99.99-chance;
}
}
}
if(betres.nonce % 1000 == 0)
console.log(lowgaps, highgaps)
if(betres.nonce % 100 == 0)
console.log(vgap, lowvgap, highvgap)
resumetarget = {
target: target, condition: condition, cost: losestreakcost
};
onswitch = true;
if(switchlow) {
target = switchscore.chance;
condition = '<';
} else {
target = 99.99-switchscore.chance;
condition = '>';
}
}
}
if(!profile.static) {
var chance = 0;
if(condition == '<') {
chance = target;
} else {
chance = 99.99-target;
}
if(switchamount > 0) {
amount = getwagerforprofit(chance, losestreakcost, switchamount,
profile.stepped);
losestreakcost += switchamount;
switchamount = 0;
} else {
if(profile.mode2 && lastwon && vgap.vgap && vgap.vgap.score > 0)
{
var scorebonus = 0;
if(balance > 100000000) {
scorebonus = vgap.vgap.score*2;
} else if(balance > 25000000) {
scorebonus = vgap.vgap.score;
} else if(balance > 5000000) {
scorebonus = vgap.vgap.score*0.5;
} else {
scorebonus = vgap.vgap.score*0.25;
}
amount = getwagerforprofit(chance, losestreakcost,
profile.amount+scorebonus, profile.stepped)
if(amount < 16)
amount = 16;
} else {
amount = getwagerforprofit(chance, losestreakcost,
profile.amount, profile.stepped);
}
}
losestreakcost += amount;
if(balance < 1)
amount = 0;
lasthighscore = highgap;
lastlowscore = lowgap;
totalbet += amount;
lastamount = amount;
betres = null;
beterr = true;
needle.post(url + '/bet?access_token=' + token, {
amount: amount, target: target, condition: condition
}).on('readable', bet).on('end', betend);
}
function getuserinfo(name) {
//console.log(name)
return needle.get(url + '/users/:' + name);
}
function getownuserinfo() {
var chunk;
while (chunk = this.read())
ownuserinfo = chunk.user;
console.log(chunk)
}
function getownuserinfoend() {
if(ownuserinfo != null) {
balance = ownuserinfo.balance;
gotownuserinfo = true;
}
}
if(token == '')
needle.post(url + '/login', { username: username, password:
password }).on('readable', login).on('end', loginend);
else
loginend();