@mog13/dxjs
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

DXJS

DXJS is a library for simulating dice rolls commonly used in tabletop games. It provides a range of standard dice from d2 to d100, as well as the ability to define and roll custom dice. The library allows dice rolls to be specified both programmatically and via an interpreted string format, making it highly versatile for various use-cases.

Installation

npm install @mog13/dxjs

Usage

const { Dice, roll } = require('@mog13/dxjs');

// roll standard dx dice
roll("d20"); // 1-20
roll("2d20 + 1d6"); // 3-46
roll("d1+d2+d3+d4+d5+d6+d7+d8+d9"); // 9-45

// create your own dice
const myNewDice = new Dice("myNewDice", [0,25,50,75,100]);
myNewDice.roll(); // 0-100
roll("myNewDice"); // 0-100
roll("5myNewDice * d4"); // 0-2000

Package Sidebar

Install

npm i @mog13/dxjs

Weekly Downloads

2

Version

2.0.1

License

MIT

Unpacked Size

145 kB

Total Files

33

Last publish

Collaborators

  • mog13