Just a die roller library written in ES6 ES2015, use for whatever obscure purpose.
npm install --save justdie
To use directly in the browser:
<script src="path/to/yourCopyOf/justdie.js"></script>
or the minified version:
<script src="path/to/yourCopyOf/justdie.min.js"></script>
On install a Node compliant index.js
will be created automatically:
npm install
but you can run it manually as well to create a index.js
:
npm run build
Create a die and roll it:
let die6 = die(6);
die6() // 1-6
Or use the roll function
let die6 = die(6);
roll(die6); // 1-6
The roll function can take a pool of dice:
roll(die(10), die(10), die(10)); // 3-30
and ofc mixed dice pools:
roll(die(8), die(12), die(4)); // 3-24
You can make more verbose rolls:
let d20 = die(20);
roll_verbose(d20); // { "result": 1-20, "minmax": [1, 20], "sides": 20 }
roll_verbose(d20, d20, d20); // [{ "result": 1-20, "minmax": [1, 20], "sides": 20 }, ...]
You can supply simple modifiers to any die
roll(die(8, 2)); // 3-10
roll(die(6, 4)); // 5-10
roll(die(4, -2)); // 0-2
roll(die(100, -43)); // 0-57
Note that when using negative modifiers we allow zero (0) as result.
In the terminal run:
npm test
- (
?
) But couldn't all this be achieved using a random_num util? - (
!
) You are correct, it could! And you are boring. Please stop talking.
This project is currently in development state. Use at your own risk.
MIT