A die-roller, inspired by roll20.net's engine
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
test
.editorconfig
.eslintrc
.gitignore
.travis.yml
karma.conf.js
license.md
mocha.config.js
package.json
readme.md
webpack.config.js

readme.md

ivory-dice

Build Status Dependency Status

Rolls any-sided die with customizable input generators.

Installation

$ npm install --save ivory-dice

Usage

const ivoryDice = require('ivory-dice');
var rollResult = ivoryDice((min, max) => Math.floor(Math.random()*(max - min + 1) + min), 6);

API

ivoryDice(generator, [sides])

Rolls a die using the given generator, returning the resulting roll.

The roll will be well-behaved with respect to the generator, i.e. if the generator provides a value X, the unmodified roll of the die will be X.

Parameters

  • Function generator: A random generator accepting two arguments, an integer min and an integer max, and returning an integer that is between the two inclusively. The function may contractually expect min <= max.
  • Number sides: The number of sides of the die to be rolled. Must be >= 1. Default: 6

Return

  • Number - The die roll result

License

MIT © Nathan Armstrong