Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/mog13/dxjs
- Owner: mog13
- License: mit
- Created: 2016-02-11T23:06:56.000Z (almost 9 years ago)
- Default Branch: main
- Last Pushed: 2023-10-31T22:58:12.000Z (about 1 year ago)
- Last Synced: 2024-10-25T18:38:32.759Z (3 months ago)
- Topics: conventional-dice, dandd, default-dice, dice, dice-rolls, dxjs, face, game, js, random, roll, utility, webpack2
- Language: TypeScript
- Size: 832 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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```