sparkychild

Untitled

Jul 13th, 2015
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. roll: function(arg, room) {
  2. var bomb = arg.split(' ')[1];
  3. arg = arg.replace(/(bomb|BOMB)/g, '');
  4. if (arg.indexOf('-') === -1) {
  5. arg = arg.split('+');
  6. }
  7. else if (arg.indexOf('-') > -1) {
  8. arg = arg.split('-');
  9. if (arg[1]) {
  10. arg[1] = -1 * arg[1];
  11. }
  12. }
  13.  
  14. if (!arg[1]) {
  15. arg[1] = 0;
  16. }
  17. var spl = arg[0].split('d');
  18. if (!spl[1] || !spl[0]) {
  19. if (!spl[0]) {
  20. spl[0] = spl[1];
  21. }
  22. var random = Math.floor(Math.random() * spl[0]) + 1;
  23. this.say(room, '**Roll:** ' + random);
  24. }
  25. else {
  26. var random = 0;
  27. var text = [];
  28. for (var i = 0; i < spl[0]; i++) {
  29. tarDice = Math.floor(Math.random() * spl[1]) + 1;
  30. random += tarDice;
  31. text.push(tarDice);
  32. if(tarDice > 6 && tarDice < 9){
  33. if(!bomb || toId(bomb) !== 'bomb'){
  34. continue;
  35. }
  36. tarDice = Math.floor(Math.random() * 8) + 1;
  37. random += tarDice;
  38. text.push('BOMB: ' + tarDice);
  39. }
  40. }
  41.  
  42. this.say(room, (text.length < 21 ? '(Individual Rolls: ' + text.join(', ') + ')' : '') + ' **Roll:** ' + (random + arg[1] * 1));
  43. }
  44. },
Advertisement
Add Comment
Please, Sign In to add comment