Advertisement
MasterFloat

Untitled

Dec 9th, 2015
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.39 KB | None | 0 0
  1. var house = {
  2. ante: 3,
  3. enabled: true,
  4. };
  5.  
  6. var faces = [["http://cdn.bulbagarden.net/upload/f/f0/Celadon_Game_Corner_7_FRLG.png", "http://cdn.bulbagarden.net/upload/5/5e/Celadon_Game_Corner_R_FRLG.png"],
  7. ["http://cdn.bulbagarden.net/upload/1/16/Celadon_Game_Corner_Pikachu_FRLG.png", "http://cdn.bulbagarden.net/upload/5/5b/Celadon_Game_Corner_Psyduck_FRLG.png" ],
  8. ["http://cdn.bulbagarden.net/upload/a/a2/Celadon_Game_Corner_Magnemite_FRLG.png", "http://cdn.bulbagarden.net/upload/e/e8/Celadon_Game_Corner_Shellder_FRLG.png"],
  9. ];
  10.  
  11. function slotMachine(roll1, roll2, roll3) {
  12. return '<center><div style="display: inline-block; background: #949698; border: 1px solid #000; border-radius: 2px; padding: 5px;"><table style="background: #3C3C3C; margin-right: auto; margin-left: auto; border: 1px solid #000; border-radius: 2px;" cellspacing="8"><tr><td style="padding-top: 4px; padding-bottom: 4px; border: 1px solid #AF8749; border-radius: 2px; background: -webkit-linear-gradient(#FDFDFD, #D7D7D7); background: -o-linear-gradient(#FDFDFD, #D7D7D7); background: -moz-linear-gradient(#FDFDFD, #D7D7D7); background: linear-gradient(#FDFDFD, #D7D7D7);"><img src="' + roll1 + '" height="24" width="32"></td><td style="padding-top: 4px; padding-bottom: 4px; border: 1px solid #AF8749; border-radius: 2px; background: -webkit-linear-gradient(#FDFDFD, #D7D7D7); background: -o-linear-gradient(#FDFDFD, #D7D7D7); background: -moz-linear-gradient(#FDFDFD, #D7D7D7); background: linear-gradient(#FDFDFD, #D7D7D7);"><img src="' + roll2 + '" height="24" width="32"></td><td style="padding-top: 4px; padding-bottom: 4px; border: 1px solid #AF8749; border-radius: 2px; background: -webkit-linear-gradient(#FDFDFD, #D7D7D7); background: -o-linear-gradient(#FDFDFD, #D7D7D7); background: -moz-linear-gradient(#FDFDFD, #D7D7D7); background: linear-gradient(#FDFDFD, #D7D7D7);"><img src="' + roll3 + '" height="24" width="32"></td></tr></table></div><img src="http://i.imgur.com/Ry0uzS7.png?3"></center>'
  13. };
  14.  
  15. function rollReels() {
  16. var rarity = Math.floor((Math.random() * 3));
  17. if (rarity === 2) {
  18. return faces[0][Math.floor(Math.random() * 2)];
  19. }
  20. else if (rarity === 1) {
  21. return faces[1][Math.floor(Math.random() * 2)];
  22. }
  23. else if (rarity === 0) {
  24. return faces[2][Math.floor(Math.random() * 2)];
  25. }
  26. };
  27.  
  28. exports.commands = {
  29.  
  30. slots: {
  31. start: 'roll',
  32. roll: function (target, room, user) {
  33. var prob = Math.floor((Math.random() * 50));
  34. if (room.id !== 'casino') return this.errorReply('Slots must be played in The Casino.');
  35. if (house.enabled === false) return this.errorReply('Slots is currently disabled.');
  36. if(!Db('money')[user.userid]) Db('money')[user.userid] = 0;
  37. if (house.ante > Db('money')[user.userid]) return this.sendReply("You do not have enough bucks to play slots.");
  38. var newTotal = (Db('money')[user.userid] || 0) - house.ante;
  39. Db('money')[user.userid] = newTotal;
  40. Db.save();
  41. var roll1;
  42. var roll2;
  43. var roll3;
  44. if (prob < 1 && prob >= 0) {
  45. roll1 = rollReels();
  46. roll2 = roll1;
  47. roll3 = roll1;
  48. }
  49. if (prob < 8 && prob >= 1) {
  50. var sides = Math.floor((Math.random() * 2));
  51. if (sides === 0) {
  52. roll1 = rollReels();
  53. roll2 = rollReels();
  54. roll3 = roll2;
  55. }
  56. if (sides === 1) {
  57. roll3 = rollReels();
  58. roll2 = rollReels();
  59. roll1 = roll2;
  60. }
  61. }
  62. if (prob < 49 && prob >= 8) {
  63. roll1 = rollReels();
  64. roll2 = rollReels();
  65. roll3 = rollReels();
  66. }
  67.  
  68. var display = slotMachine(roll1, roll2, roll3);
  69. this.sendReplyBox(display);
  70.  
  71. if (roll1 === roll2 && roll2 !== roll3) {
  72. var win = false;
  73. var winnings = house.ante;
  74. var userTotal = (Db('money')[user.userid] || 0) + winnings;
  75. Db('money')[user.userid] = userTotal;
  76. Db.save();
  77. return this.sendReply("You hit 2 in a row and got your ante back.")
  78. }
  79.  
  80. if (roll1 !== roll2 && roll2 === roll3) {
  81. var win = false;
  82. var winnings = house.ante;
  83. var userTotal = (Db('money')[user.userid] || 0) + winnings;
  84. Db('money')[user.userid] = userTotal;
  85. Db.save();
  86. return this.sendReply("You hit 2 in a row and got your ante back.")
  87. }
  88.  
  89. if (roll1 === roll2 && roll2 === roll3) {
  90. if (roll1 === faces[0][0] || roll1 === faces[0][1]) {
  91. var win = true;
  92. var winnings = 30 + house.ante;
  93. this.sendReply("You've hit the jackpot!");
  94. room.addRaw('<h3> ' + user + ' has hit a Jackpot on the slots!</h3>');
  95. }
  96. else if (roll1 === faces[1][0] || roll1 === faces[1][1]) {
  97. var win = true;
  98. var winnings = 15 + house.ante;
  99. this.sendReply("You've won 15 Bucks!");
  100. }
  101. else if (roll1 === faces[2][0] || roll1 === faces[2][1]) {
  102. var win = true;
  103. var winnings = 10 + house.ante;
  104. this.sendReply("You've won 10 Bucks!");
  105. }
  106. }
  107. else {
  108. return this.sendReply("Better luck next time!");
  109. }
  110. if (win) {
  111. var userTotal = (Db('money')[user.userid] || 0) + winnings;
  112. Db('money')[user.userid] = userTotal;
  113. Db.save();
  114. logMoney(user + " won " + winnings + " from the slots.");
  115.  
  116. }
  117. },
  118. rollhelp: ["Plays a game of dice after paying the ante. Must be played in casino."],
  119.  
  120. enable: function (target, room, user, cmd) {
  121. if (!user.can('makechatroom')) return this.errorReply('/slots enable - Access Denied.');
  122. house.enabled = true;
  123. this.sendReply("Slots has been enabled.");
  124. },
  125. enablehelp: ["Enable the playing of slots."],
  126.  
  127. disable: function (target, room, user, cmd) {
  128. if (!user.can('makechatroom')) return this.errorReply('/slots disable - Access Denied.');
  129. house.enabled = false;
  130. this.sendReply("Slots has been disabled.");
  131. },
  132. disablehelp: ["Disable the playing of slots."],
  133.  
  134. ante: function (target, room, user) {
  135. if (!user.can('hotpatch')) return this.errorReply('/slots ante - Access Denied.');
  136. if (!target) return this.parse('/help antehelp');
  137. if (typeof target === 'string') return this.sendReply(target);
  138. house.ante = target;
  139. this.sendReply("The ante for playing slots has been set to " + house.ante + " .");
  140. },
  141. antehelp: ["Sets the ante for playing slots. Require ~."]
  142. },
  143. slotshelp: ["commands for /slots are:",
  144. "/slots enable - Enable the playing of slots.",
  145. "/slots disable - Disable the playing of slots.",
  146. "/slots ante - Sets the ante for playing slots. Require ~.",
  147. "/slots roll - Pay the ante and play a game of slots.",]
  148. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement