1.2.0 • Published 8 months ago

nat20 v1.2.0

Weekly downloads
2
License
MIT
Repository
github
Last release
8 months ago

Nat20

A simple library for simulating dice rolls for use in RPG games :)

Installation

Using npm

npm install nat20

Usage

import { DiceRoller, d } from "nat20";

const diceRoller = new DiceRoller();

diceRoller.roll("2d6"); // Should return a number between 2 and 12

diceRoller.roll("2a6"); // Should throw an erro due to this being an invalid expression

// Alternatively, you can use a callback
diceRoller.roll("d6 + 6", (result, error) => {
    // The result should be a number between 7 anad 12
    // Tf the expression is invalid, you can access the error message here instead of it being thrown
});

// You can also simply roll a single dice, taking the number of sides as a parameter
const result = d(20) // Should return a number between 1 and 20
1.2.0

8 months ago

1.1.1

8 months ago

1.1.0

8 months ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago