Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- roll: function(arg, room) {
- var bomb = arg.split(' ')[1];
- arg = arg.replace(/(bomb|BOMB)/g, '');
- if (arg.indexOf('-') === -1) {
- arg = arg.split('+');
- }
- else if (arg.indexOf('-') > -1) {
- arg = arg.split('-');
- if (arg[1]) {
- arg[1] = -1 * arg[1];
- }
- }
- if (!arg[1]) {
- arg[1] = 0;
- }
- var spl = arg[0].split('d');
- if (!spl[1] || !spl[0]) {
- if (!spl[0]) {
- spl[0] = spl[1];
- }
- var random = Math.floor(Math.random() * spl[0]) + 1;
- this.say(room, '**Roll:** ' + random);
- }
- else {
- var random = 0;
- var text = [];
- for (var i = 0; i < spl[0]; i++) {
- tarDice = Math.floor(Math.random() * spl[1]) + 1;
- random += tarDice;
- text.push(tarDice);
- if(tarDice > 6 && tarDice < 9){
- if(!bomb || toId(bomb) !== 'bomb'){
- continue;
- }
- tarDice = Math.floor(Math.random() * 8) + 1;
- random += tarDice;
- text.push('BOMB: ' + tarDice);
- }
- }
- this.say(room, (text.length < 21 ? '(Individual Rolls: ' + text.join(', ') + ')' : '') + ' **Roll:** ' + (random + arg[1] * 1));
- }
- },
Advertisement
Add Comment
Please, Sign In to add comment