Advertisement
Guest User

Untitled

a guest
Dec 26th, 2015
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. ////////////CONFING
  2. var initialBetAmount = 1; //
  3. var mode = '2'; // 1 or 2(1= red-black, red-black same coins number, 2= red-black, red-black, 2x coins all the time)
  4. var betColor = 'red'; //
  5. //////////////////////////////
  6.  
  7. function tick()
  8. {
  9. var a=getStatus();if(a!==lastStatus&&"unknown"!==a){switch(a){case"waiting":bet();break;case"rolled":rolled()}lastStatus=a,printInfo()
  10. }
  11. }function checkBalance()
  12. {
  13. return getBalance()<currentBetAmount?(console.warn("BANKRUPT! Not enough balance for next bet, aborting."),clearInterval(refreshIntervalId),!1):!0
  14. }
  15. function printInfo()
  16. {
  17. var a=" \nStatus: "+lastStatus+"\nRolls played: "+currentRollNumber+"\nInitial bet amount: "+initialBetAmount+"\nCurrent bet amount: "+currentBetAmount+"\nLast roll result: "+(null===wonLastRoll()?"-":wonLastRoll()?"won":"lost");console.log(a)
  18. }
  19. function rolled()
  20. {
  21. return"1"===mode?void one():(two(),void currentRollNumber++)
  22. }
  23. function one()
  24. {
  25. //currentBetAmount=wonLastRoll()?2*currentBetAmount:initialBetAmount
  26. currentBetAmount=initialBetAmount
  27. if(lastBetColor=="red")
  28. {
  29. betColor='black'
  30. }
  31. else
  32. {
  33.  
  34. betColor='red'
  35. }
  36. }
  37. function two()
  38. {
  39. //currentBetAmount=wonLastRoll()?initialBetAmount:2*currentBetAmount
  40. currentBetAmount=wonLastRoll()?initialBetAmount:2*currentBetAmount
  41. if(lastBetColor=="red")
  42. {
  43. betColor='black'
  44. }
  45. else
  46. {
  47. betColor='red'
  48. }
  49. }
  50.  
  51. function bet()
  52. {
  53. checkBalance()&&(setBetAmount(currentBetAmount),setTimeout(placeBet,50))
  54. }
  55. function setBetAmount(a)
  56. {
  57. $betAmountInput.val(a)
  58. }
  59. function placeBet()
  60. {
  61. return"red"===betColor?($redButton.click(),void(lastBetColor="red")):($blackButton.click(),void(lastBetColor="black"))
  62. }
  63. function getStatus()
  64. {
  65. var a=$statusBar.text();if(hasSubString(a,"Rolling in"))return"waiting";if(hasSubString(a,"***ROLLING***"))return"rolling";if(hasSubString(a,"rolled")){var b=parseInt(a.split("rolled")[1]);return lastRollColor=getColor(b),"rolled"}return"unknown"
  66. }
  67. function getBalance()
  68. {
  69. return parseInt($balance.text())
  70. }
  71. function hasSubString(a,b)
  72. {
  73. return a.indexOf(b)>-1
  74. }
  75. function getColor(a)
  76. {
  77. return 0==a?"green":a>=1&&7>=a?"red":"black"
  78. }
  79. function wonLastRoll()
  80. {
  81. return lastBetColor?lastRollColor===lastBetColor:null
  82. }
  83. var currentBetAmount=initialBetAmount,currentRollNumber=1,lastStatus,lastBetColor,lastRollColor,$balance=$("#balance"),$betAmountInput=$("#betAmount"),$statusBar=$(".progress #banner"),$redButton=$("#panel1-7 .betButton"),$blackButton=$("#panel8-14 .betButton"),refreshIntervalId=setInterval(tick,500);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement