Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mog13/dxjs


https://github.com/mog13/dxjs

conventional-dice dandd default-dice dice dice-rolls dxjs face game js random roll utility webpack2

Last synced: 2 months ago
JSON representation

Awesome Lists containing this project

README

        

## DXJS
[![codecov](https://codecov.io/gh/mog13/DXJS/graph/badge.svg?token=bYrtpjhYB2)](https://codecov.io/gh/mog13/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
```bash
npm install @mog13/dxjs
```

### Usage
```javascript
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

```