Nondeterministic Polynomial Munchies

npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

justdie

1.1.3 • Public • Published

Just Die

Just Die JS logo

Just a die roller library written in ES6 ES2015, use for whatever obscure purpose.

Installation

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>

Build

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

Documentation

Single die

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

Dice pools

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

Verbose rolls

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 }, ...]

Roll modifiers

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.

Running The Test Suite

In the terminal run:

npm test

FAQ

  • (?) But couldn't all this be achieved using a random_num util?
  • (!) You are correct, it could! And you are boring. Please stop talking.

Disclaimer

This project is currently in development state. Use at your own risk.

License

MIT

install

npm i justdie

Downloadsweekly downloads

5

version

1.1.3

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability