dnd5e-dice-roller
TypeScript icon, indicating that this package has built-in type declarations

0.0.13 • Public • Published

dnd5e-dice-roller

npm Version Build NPM License size

Generate dice rolls based on standard ttrpg dice string.

For example:s

  • 1d4 - 1 roll of a 4 sided dice. Returns a result between 1 and 4
  • d6 - 1 roll of a 6 sided dice. Returns a result between 1 and 6
  • 3d8 - 3 rolls of an 8 sided dice. Returns a result between 3 and 24
  • 1d6+2 - 1 roll of a 6 sided dice, plus 2. Returns a result between 3 and 8
  • 1d4-1 - 1 roll of a 4 sided dice, minus 1. Returns a result between 0 and 3
  • 4d6dl1 - 4 rolls of a 6 sided dice, dropping the lowest. Returns a result between 3 and 18
  • 2d20dh1 - 2 rolls of a 20 sided dice, dropping the lowest. (i.e. Rolling with disadvantage)
  • 2d20d1+3 - 2 rolls of a 20 sided dice, dropping the lowest, plus 3. (i.e. Rolling with advantage with a modifier)

Usage

Default export returns the total and the the rolls of each die

import diceRoller  from 'dnd5e-dice-roller';

diceRoller("2d8+3"); // Returns { total: 17, rolls: [8, 6], rollStr: "2d8+3"  }

Named exports of diceRoller (behaves the same as the default) and roll to just return the total

import { diceRoller, roll }  from 'dnd5e-dice-roller';

diceRoller("2d8+3"); // Returns { total: 17, rolls: [8, 6], rollStr: "2d8+3"  }
roll("2d8+3"); // Returns 17

Package Sidebar

Install

npm i dnd5e-dice-roller

Weekly Downloads

26

Version

0.0.13

License

ISC

Unpacked Size

22.6 kB

Total Files

25

Last publish

Collaborators

  • mitchb09