@stacon/roll

1.0.0 • Public • Published

Roll

A simple program that emulates dice rolls with custom number of dimensions and times rolled. Like rolling 5d20 but with a function.

Usage

import Roll, { d, sum } from '@stacon/roll'

// Create a die
const D20 = d(20);

// Sigle die roll
console.log(Roll(D20)) // should log a number between 1 - 20 like a d20 roll would.

// Multiple dice roll of the same dimensions
const resultsArr = Roll.times(5)(D20) // returns an array of numbers between 1 - 20
console.log(resultsArr) // should log e.g [ 19, 20, 1, 5, 11 ]
console.log(sum(resultsArr)) // should return the sum of results are e.g. 56

/@stacon/roll/

    Package Sidebar

    Install

    npm i @stacon/roll

    Weekly Downloads

    2

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    13.4 kB

    Total Files

    23

    Last publish

    Collaborators

    • stacon