Mini Dice
A mini tool to generate random number based on dice roll 🎲
Usage
var Dice = ; // Roll the dice !var random = Dice; // Roll two 12-sided dicevar damage = Dice;// Roll five 20-sided dicevar ennemies = Dice; // Find the minimum rollvar minScore = Dice;// Find the maximum rollvar criticalStrike = Dice > 18;
API
var Dice = ;
This module give access to a static class Dice
, whith 3 methods
roll
compute the sum of successive dice rollmaxRoll
compute the maximum value obtained from successive dice rollminRoll
compute the minimum value obtained from successive dice roll
Accepted Input
All three methods accept the same type of input, which describes the number of dice to roll and the number of sides of the dice.
String
You can use a single String
as input.
It should be formatted as "NdS"
where N is the number of dice, d is the separator, and S the number of sides.
Example: roll("4D20")
Note: You can use either lower-case or upper-case d as a separator
Array
You can use a single Array
as input.
The first two values will be used as N the number of dice and S the number of sides, respectively.
** Example:** roll([4, 20])
Number & String
You can use two Number
or String
as input.
The first value will be used as N the number of dice, and the second value as S the number of sides.
** Example:** roll(4,20)
Note: Both values can have different types, but they need to parsable as integers.
One Number / String
If you are feeling lazy, and only wants to give one input, you can.
The Number
or String
will be used as N the number of dice, and the number of sides is 6
by default.
Installation
The module can be installed from npm
npm install mini-dice
It can also be installed by including the mini-dice.js
file in your project
License
This project is licensed under the WTFPL - see LICENSE for more details
Acknowledgments
This tool was used to test the creation of a simple node module, and continuous integration with Travis. Since it is used by some people, it should stay here for a while.