Skip to content

armstnp/ivory-dice

Repository files navigation

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

About

A die-roller, inspired by roll20.net's engine

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published