mog13 / DXJS

MIT License
2 stars 1 forks source link
conventional-dice dandd default-dice dice dice-rolls dxjs face game js random roll utility webpack2

DXJS

codecov

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