kory75 / CharacterSheetGenerator

Ultimate character sheet generator project. All in one files with random generator, saving and printing.
3 stars 2 forks source link

Dice roller helper #7

Closed reyrodrigez closed 10 years ago

reyrodrigez commented 10 years ago

A Dice Roller Singleton would be really useful and could be included to every individual charsheet project. Let's move the conversation here from the pull request. As we discussed earlier a method is required that returns a number from any dice formula. Example: 3d6 returns a number between 3 and 18, 2d10+1d4+3 returns a number between 6 and 27, etc...

kory75 commented 10 years ago

I recommend:

Dice.roll('d10'); Dice.roll('1'); Dice.roll('-2'); and Dice.sumRolls(array dices);

function Dice.sumRolls(new_rolls){ result = 0; new_rolls.forEach (function(one_roll){ result = result + Dice.roll(one_roll); }); return result }