~eli_oat/dice

Utility for rolling dice

refs

master
browse  log 

clone

read-only
https://git.sr.ht/~eli_oat/dice
read/write
git@git.sr.ht:~eli_oat/dice

You can also use your local clone with git send-email.

#Dice

Here is a little class to roll dice given a string in standard dice notation, e.g. 2d20+3.

#How to use

Instantiate an instance of the class for each player, and then go nuts!

// instantiate yo' players
const playerSarah = new diceRoller();
const playerEli = new diceRoller();

// play the game
playerSarah.roll('2d10-4');
playerEli.roll('2d12+12');
playerSarah.roll('1d12');
playerEli.roll('1d2');


// check the log!
console.log('==== Sarah\'s log ====');
playerSarah.log.forEach(logEntry => {
  console.log(logEntry.input + " : " + logEntry.result + " : " + logEntry.timestamp);
});

console.log('==== Eli\'s log ====');
playerEli.log.forEach(logEntry => {
  console.log(logEntry.input + " : " + logEntry.result + " : " + logEntry.timestamp);
});