Package Exports
- roll-dice
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (roll-dice) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
roll-dice
A dice rolling engine.
Usage
There are two ways to roll dice.
- standard dice format:
d20,2d8+2 - union syntax:
[cat|dog|fish],[ red | green | blue ],[thing one|thing two|thing three]
let DiceRoller = require('dice-roller');
let diceRoller = new DiceRoller();
let result = diceRoller.roll('d20');
// {"result":10,"faces":20,"rolls":[10],"modifier":0}diceRoller.roll('2d8');
// {"result":7,"faces":8,"rolls":[1,6],"modifier":0}
diceRoller.roll('[cat|dog|fish]');
// {"result":"dog","faces":["cat","dog","fish"]}
diceRoller.roll('[thing one|thing two|thing three]');
// {"result":"thing two","faces":["thing one","thing two","thing three"]}
diceRoller.roll('10d4+2');
/*
{
"result":25,
"faces":4,
"rolls":[2,2,4,1,1,2,1,4,3,3],
"modifier":2
}
*/