Advertisement
Guest User

Untitled

a guest
Apr 28th, 2016
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.58 KB | None | 0 0
  1. "use strict";
  2.  
  3. var needle = require('needle');
  4. var prompt = require('sync-prompt').prompt;
  5.  
  6. var options = {
  7. compressed: true,
  8. follow_max: 5,
  9. rejectUnauthorized: true,
  10. timeout: 20000,
  11. user_agent: 'ChaosBot/0.2.1',
  12. follow_set_cookies: true
  13. }
  14.  
  15. needle.defaults(options);
  16.  
  17. var url = 'https://api.primedice.com/api';
  18.  
  19. function onErr(err) {
  20. console.log(err);
  21. return 1;
  22. }
  23.  
  24. var profiles = [
  25. {
  26. target: 98,
  27. condition: '<',
  28. amount: 2,
  29. cost: 0,
  30.  
  31. maxchance: 98,
  32. minchance: 0.01,
  33.  
  34. bankat: 0,
  35. stoplossenabled: false,
  36. maxstreakcost: 0,
  37.  
  38. rnd: false,
  39. mode2: true,
  40. mode2zig: false,
  41. stepped: true,
  42. static: false,
  43.  
  44. username: '',
  45. password: '',
  46. token: '',
  47. bankuser: ''
  48. }, {
  49. target: 99.93,
  50. condition: '>',
  51. amount: 1,
  52. cost: 966666,
  53.  
  54. maxchance: 98,
  55. minchance: 0.06,
  56.  
  57. bankat: 0,
  58. stoplossenabled: false,
  59. maxstreakcost: 0,
  60.  
  61. rnd: false,
  62. mode2: true,
  63. mode2zig: false,
  64. stepped: true,
  65. static: false,
  66.  
  67. username: 'user2',
  68. password: 'pass2',
  69. token: '',
  70. bankuser: 'bank'
  71. }
  72. ];
  73.  
  74. // FIXME add proper support for profiles
  75.  
  76. // Must edit the index each launch 0 based(first profile index is 0)
  77.  
  78. var profile = profiles[0];
  79.  
  80. var lowgaps = [
  81. { chance: 0.01, nonce: -1, score: 0 },
  82. { chance: 0.02, nonce: -1, score: 0 },
  83. { chance: 0.03, nonce: -1, score: 0 },
  84. { chance: 0.04, nonce: -1, score: 0 },
  85. { chance: 0.05, nonce: -1, score: 0 },
  86. { chance: 0.06, nonce: -1, score: 0 },
  87. { chance: 0.07, nonce: -1, score: 0 },
  88. { chance: 0.08, nonce: -1, score: 0 },
  89. { chance: 0.09, nonce: -1, score: 0 },
  90. { chance: 0.1, nonce: -1, score: 0 },
  91. { chance: 0.15, nonce: -1, score: 0 },
  92. { chance: 0.2, nonce: -1, score: 0 },
  93. { chance: 0.25, nonce: -1, score: 0 },
  94. { chance: 0.3, nonce: -1, score: 0 },
  95. { chance: 0.4, nonce: -1, score: 0 },
  96. { chance: 0.5, nonce: -1, score: 0 },
  97. { chance: 0.75, nonce: -1, score: 0 },
  98. { chance: 1.0, nonce: -1, score: 0 },
  99. { chance: 1.5, nonce: -1, score: 0 },
  100. { chance: 2.0, nonce: -1, score: 0 },
  101. { chance: 5.0, nonce: -1, score: 0 },
  102. { chance: 10.0, nonce: -1, score: 0 },
  103. { chance: 20.0, nonce: -1, score: 0 },
  104. { chance: 30.0, nonce: -1, score: 0 },
  105. { chance: 40.0, nonce: -1, score: 0 },
  106. { chance: 49.0, nonce: -1, score: 0 },
  107. { chance: 60.0, nonce: -1, score: 0 },
  108. { chance: 70.0, nonce: -1, score: 0 },
  109. { chance: 80.0, nonce: -1, score: 0 },
  110. { chance: 90.0, nonce: -1, score: 0 },
  111. { chance: 95.0, nonce: -1, score: 0 }
  112. ];
  113.  
  114. var highgaps = [
  115. { chance: 0.01, nonce: -1, score: 0 },
  116. { chance: 0.02, nonce: -1, score: 0 },
  117. { chance: 0.03, nonce: -1, score: 0 },
  118. { chance: 0.04, nonce: -1, score: 0 },
  119. { chance: 0.05, nonce: -1, score: 0 },
  120. { chance: 0.06, nonce: -1, score: 0 },
  121. { chance: 0.07, nonce: -1, score: 0 },
  122. { chance: 0.08, nonce: -1, score: 0 },
  123. { chance: 0.09, nonce: -1, score: 0 },
  124. { chance: 0.1, nonce: -1, score: 0 },
  125. { chance: 0.15, nonce: -1, score: 0 },
  126. { chance: 0.2, nonce: -1, score: 0 },
  127. { chance: 0.25, nonce: -1, score: 0 },
  128. { chance: 0.3, nonce: -1, score: 0 },
  129. { chance: 0.4, nonce: -1, score: 0 },
  130. { chance: 0.5, nonce: -1, score: 0 },
  131. { chance: 0.75, nonce: -1, score: 0 },
  132. { chance: 1.0, nonce: -1, score: 0 },
  133. { chance: 1.5, nonce: -1, score: 0 },
  134. { chance: 2.0, nonce: -1, score: 0 },
  135. { chance: 5.0, nonce: -1, score: 0 },
  136. { chance: 10.0, nonce: -1, score: 0 },
  137. { chance: 20.0, nonce: -1, score: 0 },
  138. { chance: 30.0, nonce: -1, score: 0 },
  139. { chance: 40.0, nonce: -1, score: 0 },
  140. { chance: 49.0, nonce: -1, score: 0 },
  141. { chance: 60.0, nonce: -1, score: 0 },
  142. { chance: 70.0, nonce: -1, score: 0 },
  143. { chance: 80.0, nonce: -1, score: 0 },
  144. { chance: 90.0, nonce: -1, score: 0 },
  145. { chance: 95.0, nonce: -1, score: 0 }
  146. ];
  147.  
  148. var username = profile.username;
  149. var password = profile.password;
  150. var token = profile.token;
  151.  
  152. var condition = profile.condition;
  153.  
  154. var ownuserinfo;
  155. var betres;
  156.  
  157. var waittimemin = 300;
  158. var waittimemax = 350;
  159.  
  160. var bankamountmin = 50001;
  161. var bankat = 150000000;
  162. var bankuser = profile.bankuser;
  163.  
  164. var balance = 0;
  165. var startbalance = 0;
  166.  
  167. var winstreak = 0;
  168. var losestreak = 0;
  169.  
  170. var losestreakcost = profile.cost;
  171.  
  172. var amount = getwagerforprofit(getchance(profile.target), profile.cost, profile.amount, profile.stepped);
  173.  
  174. var lasttarget = 0;
  175. var lastroll = 0.0;
  176. var lastcondition = '<';
  177. var lastbet = amount;
  178. var lastwon = false;
  179.  
  180. var totalbet = 0;
  181. var banked = 0;
  182.  
  183. var target = profile.target;
  184. var condition = profile.condition;
  185.  
  186. var gotownuserinfo = false;
  187.  
  188. var losses = 0;
  189. var wins = 0;
  190.  
  191. var first = true;
  192.  
  193. function random(howMany, chars) {
  194. chars = chars
  195. || "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789";
  196. var rnd = crypto.randomBytes(howMany),
  197. value = new Array(howMany),
  198. len = chars.length;
  199.  
  200. for (var i = 0; i < howMany; i++)
  201. value[i] = chars[rnd[i] % len]
  202.  
  203. return value.join('');
  204. }
  205.  
  206. function login() {
  207. var chunk;
  208. while (chunk = this.read()) {
  209. token = chunk.access_token;
  210. }
  211. }
  212.  
  213. function loginend() {
  214. needle.get(url + '/users/1?access_token=' + token).on('readable', getownuserinfo).on('end', getownuserinfoend);
  215.  
  216. var interval = setInterval(
  217. function() {
  218. if(gotownuserinfo) {
  219. balance = ownuserinfo.balance;
  220. startbalance = balance;
  221. clearInterval(interval);
  222.  
  223. if(balance < 1) {
  224. console.log("Balance is less than 1 satoshi, waiting for funds... ");
  225.  
  226. amount = 0;
  227. needle.get(url + '/users/1?access_token=' + token).on('readable', getownuserinfo).on('end', getownuserinfoend);
  228. setTimeout(betend, 20000);
  229. return;
  230. }
  231.  
  232. rebet()
  233. }
  234. }
  235. , 300);
  236. }
  237.  
  238. function bank() {
  239. var res;
  240. var chunk;
  241. while (chunk = this.read())
  242. res = chunk;
  243.  
  244. maxbalance = balance = res.balance;
  245. console.log(res);
  246. }
  247.  
  248. function bankend() {
  249. }
  250.  
  251. var beterr = false;
  252.  
  253. function bet() {
  254. betres = null;
  255.  
  256. var res;
  257. var chunk;
  258. while (chunk = this.read())
  259. res = chunk;
  260.  
  261. if(typeof(res.user) != 'undefined') {
  262. betres = res.bet;
  263. balance = res.user.balance;
  264.  
  265. beterr = false;
  266. } else {
  267. console.log('error, retrying bet');
  268. beterr = true;
  269. }
  270.  
  271. if(betres == null)
  272. beterr = true;
  273. if(beterr)
  274. betres = null;
  275.  
  276. if(betres != null)
  277. lastbetid = betres.id;
  278. else
  279. lastbetid = 0;
  280.  
  281. if(beterr)
  282. console.log(res.toString())
  283. }
  284.  
  285. var green = [ "\x1b[1;32m", "\x1b[0m" ];
  286. var red = [ "\x1b[1;31m", "\x1b[0m" ];
  287.  
  288. var lastbetid = 0;
  289.  
  290. var waittime = 350;
  291.  
  292. function updategaps(nonce, roll) {
  293. for(var i = 0; i < lowgaps.length; ++i) {
  294. if(roll < lowgaps[i].chance)
  295. lowgaps[i].nonce = nonce;
  296. }
  297. computegapscores(lowgaps, nonce);
  298.  
  299. for(var i = 0; i < highgaps.length; ++i) {
  300. if(roll > (9999-Math.round(highgaps[i].chance*100))/100)
  301. highgaps[i].nonce = nonce;
  302. }
  303. computegapscores(highgaps, nonce);
  304. }
  305.  
  306. function computegapscores(gaps, nonce) {
  307. var score;
  308.  
  309. for(var i = 0; i < gaps.length; ++i) {
  310. score = 0.0;
  311. if(gaps[i].nonce >= 0) {
  312. score = (nonce-gaps[i].nonce)*gaps[i].chance/100;
  313. score = Math.round(score*1e5)/1e5;
  314. gaps[i].score = score;
  315. }
  316. }
  317. }
  318.  
  319. function gethighgapscore(gaps, nonce, minchance, maxchance) {
  320. var gapidx = -1;
  321. var highscore = 0.0;
  322. var score = 0.0;
  323.  
  324. minchance = minchance || 0.01;
  325. maxchance = maxchance || 98.0;
  326.  
  327. minchance = Math.round(minchance*100)/100;
  328. maxchance = Math.round(maxchance*100)/100;
  329.  
  330. for(var i = 0; i < gaps.length; ++i) {
  331. score = 0.0;
  332. if(gaps[i].nonce >= 0) {
  333. if(gaps[i].chance >= minchance && gaps[i].chance <= maxchance) {
  334. score = gaps[i].score;
  335. if(score > highscore) {
  336. highscore = score;
  337. gapidx = i;
  338. }
  339. }
  340. }
  341. }
  342.  
  343. var gap = null;
  344. if(gapidx >= 0) {
  345. gap = gaps[gapidx];
  346. return { chance: gap.chance, score: highscore };
  347. }
  348.  
  349. return { chance: 0, score: 0 };
  350. }
  351.  
  352. function getlowestgapofscore(gaps, nonce, minchance, maxchance, minscore) {
  353. var gapidx = -1;
  354. var score = 0.0;
  355. var highscore = 0.0;
  356.  
  357. minchance = minchance || 0.01;
  358. maxchance = maxchance || 98.0;
  359.  
  360. minchance = Math.round(minchance*100)/100;
  361. maxchance = Math.round(maxchance*100)/100;
  362.  
  363. for(var i = gaps.length-1; i > 0; --i) {
  364. score = 0.0;
  365. if(gaps[i].nonce >= 0) {
  366. if(gaps[i].chance >= minchance && gaps[i].chance <= maxchance) {
  367. score = gaps[i].score;
  368. if(score > minscore) {
  369. highscore = score;
  370. gapidx = i;
  371. }
  372. }
  373. }
  374. }
  375.  
  376. var gap = null;
  377. if(gapidx >= 0) {
  378. gap = gaps[gapidx];
  379. //console.log(gap.chance, highscore)
  380.  
  381. return { chance: gap.chance, score: highscore };
  382. }
  383.  
  384. return { chance: 0, score: 0 };
  385. }
  386.  
  387. var lasthighscore = 0, lastlowscore = 0;
  388.  
  389. function betend() {
  390. if(betres != null && betres.id == lastbetid) {
  391. if(betres.win) {
  392. if(losestreak > 0) {
  393. losestreak = 0;
  394. winstreak = 1;
  395. } else {
  396. winstreak++;
  397. }
  398. wins++;
  399. } else {
  400. if(winstreak > 0) {
  401. winstreak = 0;
  402. losestreak = 1;
  403. } else {
  404. losestreak++;
  405. }
  406. losses++;
  407. }
  408.  
  409. var seqs = [ green, red ];
  410. var use = 0;
  411. if(betres.win)
  412. use = 0;
  413. else
  414. use = 1;
  415.  
  416. var profit = (balance + banked - startbalance).toFixed(0);
  417. console.log(profile.username + ' ' + Math.floor(Date.now() / 1000) +
  418. ' ' + betres.id + ' ' + betres.nonce + ' ' + Math.floor(balance).toFixed(0) +
  419. '(' + seqs[use][0] + betres.profit.toFixed(0) + seqs[use][1] + ') ' +
  420. betres.condition + betres.target + ' ' + betres.roll +
  421. ' bet ' + totalbet.toFixed(0) +
  422. ' (' + green[0] + 'W' + winstreak + green[1] + ':' + red[0] + 'L' + losestreak + red[1] + ') cost(' + losestreakcost.toFixed(0) + ')');
  423.  
  424. if(profile.bankat > 0 && balance >= profile.bankat) {
  425. var bankamount = Math.floor(balance*0.15);
  426. if(bankamount < 50001)
  427. bankamount = 50001;
  428.  
  429. banked += bankamount;
  430. balance -= bankamount;
  431. startbalance = balance;
  432. needle.post(url + '/tip?access_token=' + token, {username: bankuser, amount: bankamount}).on('readable', bank).on('end', bankend);
  433. //bankat += 200000;
  434. }
  435. lastbetid = 0;
  436. if (first) {
  437. first = false;
  438.  
  439. for(var i = 0; i < lowgaps.length; ++i) {
  440. lowgaps[i].nonce = betres.nonce;
  441. }
  442.  
  443. for(var i = 0; i < highgaps.length; ++i) {
  444. highgaps[i].nonce = betres.nonce;
  445. }
  446. }
  447. }
  448.  
  449. setTimeout(rebet, waittime);
  450. }
  451.  
  452. var balancehit = false;
  453.  
  454. var waiting = true;
  455.  
  456. var amountsave = 0;
  457.  
  458. var broke = false;
  459. var raised = false;
  460.  
  461. var betlog;
  462.  
  463. var fs = require('fs');
  464. readbetlog();
  465.  
  466. function readbetlog() {
  467. var data = fs.readFileSync('bet_log-' + profile.username + '.txt');
  468. if(data == null || data == '') {
  469. console.log('Error reading bet log.')
  470. } else {
  471. console.log('Bet log read successfully.');
  472. console.log(data.toString());
  473. betlog = JSON.parse(data);
  474. }
  475. }
  476.  
  477. function writebetlog() {
  478. if(!fs.writeFileSync('bet_log-' + profile.username + '.txt', JSON.stringify(betlog)))
  479. console.log('Bet log saved.');
  480. else
  481. console.log('Error saving bet log.');
  482. }
  483.  
  484. function getRandom(min, max) {
  485. return Math.random() * (max - min) + min;
  486. }
  487.  
  488. function roundtoprecision(value, precision) {
  489. var power = Math.pow(10, precision);
  490. return Math.floor(value * power) / power;
  491. }
  492.  
  493. function getpayout(chance) {
  494. return roundtoprecision(100./chance*0.99, 5);
  495. }
  496.  
  497. function getwagerforprofit(chance, streakCost, minprofit, stepped) {
  498. if(streakCost < 0.)
  499. streakCost = 0.;
  500.  
  501. if(minprofit < 0.0001)
  502. minprofit = 0.0001;
  503.  
  504. var payout = getpayout(chance);
  505. var wager = 1.;
  506.  
  507. while(wager * payout-wager < streakCost + minprofit) {
  508. wager = Math.round(wager*2);
  509. }
  510.  
  511. if(!stepped) {
  512. while(wager > 0 && ((wager-1) * payout)-(wager-1) >= streakCost + minprofit) {
  513. wager -= 1;
  514. }
  515. }
  516.  
  517. if(wager < 1)
  518. wager = 1;
  519.  
  520. return wager;
  521. }
  522.  
  523. function settarget(chance, conditionhigh) {
  524. if (conditionhigh) {
  525. target = 99.99-chance;
  526. condition = '>';
  527. } else {
  528. target = chance;
  529. condition = '<';
  530. }
  531. }
  532.  
  533. function gettarget(chance, conditionhigh) {
  534. if (conditionhigh) {
  535.  
  536. } else {
  537. }
  538. }
  539.  
  540. function setchance(targetroll, conditionhigh) {
  541. var chance = 0;
  542.  
  543. if (conditionhigh) {
  544. target = targetroll;
  545. chance = 99.99-target;
  546. condition = '>';
  547. } else {
  548. target = targetroll
  549. chance = target;
  550. condition = '<';
  551. }
  552.  
  553. return chance;
  554. }
  555.  
  556. function getchance() {
  557. if (profile.condition == '>') {
  558. return (9999-profile.target*100)/100;
  559. } else {
  560. return profile.target;
  561. }
  562. }
  563.  
  564. var currpayout = profile.condition == '>' ?
  565. getpayout(99.99-profile.target) :
  566. getpayout(profile.target);
  567.  
  568. var maxbalance = 0;
  569.  
  570. var onswitch = false;
  571. var switchscore = null;
  572. var switchamount = 0;
  573. var switchlow = false;
  574.  
  575. var resumetarget = null;
  576.  
  577. var mode2zigpaydirup = true;
  578.  
  579. var rolltarget = {
  580. target: 0,
  581. condition: '>'
  582. };
  583.  
  584. var lowvgap = null;
  585. var highvgap = null;
  586. var vgap = { islow: true, vgap: lowvgap };
  587. var currvgap = null;
  588.  
  589. var mode2first = false;
  590.  
  591. var levels = [ 0.03, 0.05, 0.1, 0.2, 0.5, 1.0 ];
  592. var currlevel = 1;
  593. var maxlevel = levels.length;
  594.  
  595. var lastamount = amount;
  596.  
  597. function rebet() {
  598. if(beterr || betres == null) {
  599. needle.post(url + '/bet?access_token=' + token, {
  600. amount: amount,
  601. target: target,
  602. condition: condition
  603. }).on('readable', bet).on('end', betend);
  604. return;
  605. }
  606.  
  607. if(balance < 1) {
  608. if(!broke) {
  609. broke = true;
  610. amountsave = amount;
  611. }
  612.  
  613. amount = 0;
  614. needle.get(url + '/users/1?access_token=' + token).on('readable', getownuserinfo).on('end', getownuserinfoend);
  615. setTimeout(betend, 15000);
  616.  
  617. return;
  618. }
  619.  
  620. if(balance > 0 && broke) {
  621. amount = amountsave;
  622. broke = false;
  623. }
  624.  
  625. if(balance > maxbalance)
  626. maxbalance = balance;
  627.  
  628. lastwon = betres.win;
  629. lastroll = betres.roll;
  630. lasttarget = betres.target;
  631. lastcondition = betres.condition;
  632.  
  633. if(lastroll <= 0.1 || lastroll >= 99.89) {
  634. for(var i = 0; i < betlog.rolls.length; ++i) {
  635. if(betlog.rolls[i].roll == lastroll)
  636. betlog.rolls[i].nonce = betres.nonce;
  637. console.log(betlog.rolls[i]);
  638. }
  639. writebetlog();
  640. }
  641.  
  642. updategaps(betres.nonce, lastroll);
  643. var lowgap = gethighgapscore(lowgaps, betres.nonce);
  644. var highgap = gethighgapscore(highgaps, betres.nonce);
  645.  
  646. if(lastwon) {
  647. if(raised) {
  648. amountsave = 0;
  649. raised = false;
  650. }
  651. }
  652.  
  653. if(resumetarget) {
  654. if((resumetarget.condition == '>' && lastroll > resumetarget.target) ||
  655. (resumetarget.condition == '<' && lastroll < resumetarget.target)) {
  656. resumetarget = null;
  657. }
  658. }
  659.  
  660. if(lastwon)
  661. currlevel = 0;
  662.  
  663. lowvgap = gethighgapscore(lowgaps, betres.nonce, 0.01, levels[currlevel]);
  664. highvgap = gethighgapscore(highgaps, betres.nonce, 0.01, levels[currlevel]);
  665. var ishighv = false;
  666. if(lowvgap.chance > 0 || highvgap.chance > 0) {
  667. if(lowvgap.score > highvgap.score)
  668. ishighv = false;
  669. else
  670. ishighv = true;
  671. }
  672.  
  673. if(!vgap.vgap) {
  674. if(ishighv) {
  675. vgap.vgap = highvgap;
  676. vgap.islow = false;
  677. } else {
  678. vgap.vgap = lowvgap;
  679. vgap.islow = true;
  680. }
  681. if(first && vgap.vgap.chance < profile.minchance) {
  682. vgap.vgap.chance = profile.minchance;
  683. if(vgap.islow && profile.condition == '>')
  684. vgap.islow = false;
  685. else if(!vgap.islow && profile.confition == '<')
  686. vgap.islow = true;
  687. onswitch = true;
  688. }
  689. //console.log(lowvgap, highvgap, vgap, levels, currlevel)
  690. }
  691.  
  692. if(lastwon) {
  693. losestreakcost = 0;
  694.  
  695. currlevel++;
  696.  
  697. if(profile.rnd) {
  698. if(condition == '<')
  699. condition = '>';
  700. else
  701. condition = '<';
  702.  
  703. target = getRandom(profile.minchance, profile.maxchance);
  704. if(condition == '<')
  705. target = 99.99-target;
  706. target = Math.floor(roundtoprecision(target, 2));
  707. } else if(profile.mode2 ||
  708. ((rolltarget.condition == '>' && lastroll > 99.99-profile.minchance) ||
  709. (condition == '<' && lastroll < profile.minchance))) {
  710. profile.minchance = 0.01;
  711. if(lowvgap.chance > 0 && highvgap.chance > 0) {
  712. if (ishighv) {
  713. vgap.islow = false;
  714. vgap.vgap = highvgap;
  715. profile.minchance = highvgap.chance;
  716. condition = '>';
  717. target = 99.99-profile.maxchance;
  718. } else {
  719. vgap.islow = true;
  720. vgap.vgap = lowvgap;
  721. profile.minchance = lowvgap.chance;
  722. condition = '<';
  723. target = profile.maxchance;
  724. }
  725. //console.log(lowvgap, highvgap, ishighv, target, condition);
  726. } else {
  727. vgap.vgap = null;
  728. if(condition == '<') {
  729. if(lastroll < profile.minchance)
  730. condition = '>';
  731. } else {
  732. if(lastroll > 99.99-profile.minchance)
  733. condition = '<';
  734. }
  735.  
  736. if(condition == '>')
  737. target = 99.99-profile.maxchance;
  738. else
  739. target = profile.maxchance;
  740. }
  741.  
  742. if(profile.mode2) {
  743. currpayout = getpayout(profile.maxchance);
  744. }
  745. } else {
  746. target = lastroll;
  747. }
  748.  
  749. if(resumetarget) {
  750. if(!profile.mode2) {
  751. target = resumetarget.target;
  752. condition = resumetarget.condition;
  753. }
  754. losestreakcost -= resumetarget.cost;
  755.  
  756. resumetarget = null;
  757. }
  758. mode2first = true;
  759. onswitch = false;
  760. mode2zigpaydirup = true;
  761. } else {
  762. var chance = 0;
  763. if(condition == '<') {
  764. chance = target;
  765. } else {
  766. chance = 99.99-target;
  767. }
  768.  
  769. if(currlevel >= maxlevel)
  770. currlevel = maxlevel-1;
  771.  
  772. if(!onswitch && profile.mode2) {
  773. if(vgap.vgap && vgap.vgap.chance > 0) {
  774. //console.log(1, vgap)
  775. if(vgap.islow) {
  776. vgap.vgap = gethighgapscore(lowgaps, betres.nonce, 0.01, vgap.vgap.chance);
  777. } else {
  778. vgap.vgap = gethighgapscore(highgaps, betres.nonce, 0.01, vgap.vgap.chance);
  779. }
  780. profile.minchance = vgap.vgap.chance;
  781. }
  782.  
  783. var max = maxlevel-1;
  784. var extralevel = 0;
  785. if(currlevel > 1 && currlevel+1 < max) {
  786. extralevel = 1;
  787. }
  788.  
  789. var scoreneeded = 0.0;
  790. if(vgap.vgap.chance < 0.05)
  791. scoreneeded = 1.0;
  792. else
  793. scoreneeded = 2.0;
  794.  
  795. var switchlowvgap = getlowestgapofscore(lowgaps, betres.nonce, 0.01, levels[currlevel+extralevel], vgap.vgap.score+scoreneeded);
  796. var switchhighvgap = getlowestgapofscore(highgaps, betres.nonce, 0.01, levels[currlevel+extralevel], vgap.vgap.score+scoreneeded);
  797.  
  798. if((vgap.vgap.score > 0 && switchlowvgap.chance > 0 && switchlowvgap.score > 0) ||
  799. (switchhighvgap.chance > 0 && switchhighvgap.score > 0)) {
  800. if(switchlowvgap.score > switchhighvgap.score)
  801. ishighv = false;
  802. else
  803. ishighv = true;
  804. }
  805. if(chance <= 1.0 && vgap && vgap.vgap && vgap.vgap.chance > 0 &&
  806. (switchlowvgap.chance > 0 || switchhighvgap.chance > 0) &&
  807. (vgap.vgap.chance <= 0.05 &&
  808. (switchlowvgap.score-1 > vgap.vgap.score ||
  809. switchhighvgap.score-1 > vgap.vgap.score)) ||
  810. (vgap.vgap.chance > 0.05 &&
  811. (switchlowvgap.score-2 > vgap.vgap.score ||
  812. switchhighvgap.score-2 > vgap.vgap.score))) {
  813. console.log(vgap, switchlowvgap, switchhighvgap)
  814.  
  815. if (ishighv) {
  816. condition = '>';
  817. chance = switchhighvgap.chance;
  818. vgap.islow = false;
  819. vgap.vgap = switchhighvgap;
  820. } else {
  821. condition = '<';
  822. chance = switchlowvgap.chance;
  823. vgap.islow = true;
  824. vgap.vgap = switchlowvgap;
  825. }
  826. currlevel += 1+extralevel;
  827. if(currlevel >= maxlevel)
  828. currlevel = maxlevel-1;
  829.  
  830. profile.minchance = chance;
  831. //console.log(vgap);
  832. } else {
  833. var minchance = profile.minchance;
  834. var maxchance = profile.maxchance;
  835.  
  836. if((profile.mode2zig && mode2zigpaydirup) || !profile.mode2zig) {
  837. if(!mode2first) {
  838. if(chance == 75) {
  839. chance = 49;
  840. } else {
  841. while(chance > minchance && getpayout(chance) <= currpayout+1) {
  842. chance -= 2.0;
  843. chance = Math.round(chance*100)/100;
  844. }
  845.  
  846. }
  847.  
  848. if(chance < minchance) {
  849. chance = minchance;
  850. if(profile.mode2zig)
  851. mode2zigpaydirup = false;
  852. //console.log(chance, minchance, maxchance);
  853. }
  854. }
  855. if(mode2first) {
  856. chance = 75;
  857. mode2first = false;
  858. }
  859. } else if(profile.mode2zig && !mode2zigpaydirup) {
  860. while(chance < 0.1 && getpayout(chance) > currpayout-1) {
  861. chance += 0.01;
  862. }
  863. if(chance >= maxchance) {
  864. mode2zigpaydirup = true;
  865. }
  866. }
  867. }
  868.  
  869. //console.log(chance, minchance, maxchance);
  870. currpayout = getpayout(chance);
  871.  
  872. if(condition == '<') {
  873. target = chance;
  874. } else {
  875. target = 99.99-chance;
  876. }
  877. }
  878. }
  879.  
  880. if(betres.nonce % 1000 == 0)
  881. console.log(lowgaps, highgaps)
  882. if(betres.nonce % 100 == 0)
  883. console.log(vgap, lowvgap, highvgap)
  884.  
  885. if(!betres.won && (profile.stoplossenabled && balance >= 50001 && losestreakcost > profile.maxstreakcost)) {
  886. if(!((condition == '<' && target <= 0.1) || (condition == '>' && target > 99.88))) {
  887. console.log('Streakcost of ' + (losestreakcost+amount) + ' would exceed safety limit.');
  888. needle.post(url + '/tip?access_token=' + token, {username: bankuser, amount: balance/*Math.floor(balance-50001)*/}).on('readable', bank).on('end', bankend);
  889. balance = maxbalance = 0;
  890. setTimeout(betend, 15000);
  891. return;
  892. }
  893. }
  894.  
  895. if(!onswitch && highgap && lowgap &&
  896. (((lasthighscore.score > 4 && lastlowscore.score > 4) &&
  897. (lowgap.score == 0 || highgap.score == 0)) ||
  898. (highgap.chance <= 2.0 && highgap.score > 8) ||
  899. (lowgap.chance <= 2.0 && lowgap.score > 8) ||
  900. highgap.score > 10 || lowgap.score > 10)) {
  901. var ishigh = highgap.score > lowgap.score;
  902. var tvar = null;
  903. if(ishigh) {
  904. tvar = '>' + (99.99-highgap.chance) + '@' + highgap.score + 'x';
  905. } else {
  906. tvar = '<' + lowgap.chance + '@' + lowgap.score + 'x';
  907. }
  908. console.log('prev_variance: >' + (99.99-lasthighscore.chance) + '@' + lasthighscore.score + 'x' +
  909. ' <' + lastlowscore.chance + '@' + lastlowscore.score + 'x') + ' curr_variance: ' + tvar;
  910.  
  911. var change = prompt('High variance detected, switch to ' + tvar + ' ? ');
  912. if(change.length > 0 && change.toLowerCase() === 'y') {
  913. switchscore = highgap.score > lowgap.score ? highgap : lowgap;
  914. switchlow = lowgap.score > highgap.score;
  915.  
  916. var stramount = prompt('Amount: ');
  917. if(stramount && Number(stramount) > 0) {
  918. switchamount = Number(stramount);
  919. }
  920.  
  921. resumetarget = {
  922. target: target, condition: condition, cost: losestreakcost
  923. };
  924.  
  925. onswitch = true;
  926. if(switchlow) {
  927. target = switchscore.chance;
  928. condition = '<';
  929. } else {
  930. target = 99.99-switchscore.chance;
  931. condition = '>';
  932. }
  933. }
  934. }
  935.  
  936. if(!profile.static) {
  937. var chance = 0;
  938. if(condition == '<') {
  939. chance = target;
  940. } else {
  941. chance = 99.99-target;
  942. }
  943.  
  944. if(switchamount > 0) {
  945. amount = getwagerforprofit(chance, losestreakcost, switchamount, profile.stepped);
  946. losestreakcost += switchamount;
  947.  
  948. switchamount = 0;
  949. } else {
  950. if(profile.mode2 && lastwon && vgap.vgap && vgap.vgap.score > 0) {
  951. var scorebonus = 0;
  952. if(balance > 100000000) {
  953. scorebonus = vgap.vgap.score*2;
  954. } else if(balance > 25000000) {
  955. scorebonus = vgap.vgap.score;
  956. } else if(balance > 5000000) {
  957. scorebonus = vgap.vgap.score*0.5;
  958. } else {
  959. scorebonus = vgap.vgap.score*0.25;
  960. }
  961. amount = getwagerforprofit(chance, losestreakcost, profile.amount+scorebonus, profile.stepped)
  962. if(amount < 16)
  963. amount = 16;
  964. } else {
  965. amount = getwagerforprofit(chance, losestreakcost, profile.amount, profile.stepped);
  966. }
  967. }
  968.  
  969. if(balance-amount < getwagerforprofit(chance, losestreakcost+amount, profile.amount, profile.stepped)) {
  970. var change = prompt('Yolo ' + getwagerforprofit(chance, losestreakcost+amount, profile.amount, profile.stepped) + ' ? ');
  971. if(change.length > 0 && change.toLowerCase() === 'y') {
  972. amount = Math.floor(balance);
  973. }
  974. }
  975. } else {
  976. amount = profile.amount;
  977. if(amount*2 > balance)
  978. amount = Math.floor(balance);
  979. }
  980.  
  981. if(amount > balance)
  982. amount = balance;
  983.  
  984. losestreakcost += amount;
  985.  
  986. if(balance < 1)
  987. amount = 0;
  988.  
  989. lasthighscore = highgap;
  990. lastlowscore = lowgap;
  991.  
  992. totalbet += amount;
  993.  
  994. if(amount > 10000 && lastamount > 10000)
  995. waittime = 50;
  996. else if(amount < 10000 && lastamount > 10000)
  997. waittime = 750;
  998. else
  999. waittime = 350;
  1000.  
  1001. lastamount = amount;
  1002.  
  1003. betres = null;
  1004. beterr = true;
  1005. needle.post(url + '/bet?access_token=' + token, {
  1006. amount: amount, target: target, condition: condition
  1007. }).on('readable', bet).on('end', betend);
  1008. }
  1009. function getuserinfo(name) {
  1010. //console.log(name)
  1011. return needle.get(url + '/users/:' + name);
  1012. }
  1013.  
  1014. function getownuserinfo() {
  1015. var chunk;
  1016. while (chunk = this.read())
  1017. ownuserinfo = chunk.user;
  1018. console.log(chunk)
  1019. }
  1020.  
  1021. function getownuserinfoend() {
  1022. if(ownuserinfo != null) {
  1023. balance = ownuserinfo.balance;
  1024. gotownuserinfo = true;
  1025. }
  1026. }
  1027.  
  1028. if(token == '')
  1029. needle.post(url + '/login', { username: username, password: password }).on('readable', login).on('end', loginend);
  1030. else
  1031. loginend();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement