🎲 Comes with all the basic polyhedral dice 🎲
🎲 Simple interface for creating custom or 'funky' dice 🎲
🎲 Pools is a simple helper for rolling multiple dice 🎲
npm install @damienbullis/dice
# or
yarn add @damienbullis/dice
# or
pnpm add @damienbullis/dice
To roll dice, you can use the Dice
function.
import { Dice } from "@damienbullis/dice";
// Create some dice
const d4 = Dice(4);
const d6 = Dice(6);
const d8 = Dice(8);
d4(); // rolls a single d4
// returns [ 2 ]
d6(2); // rolls two d6's
// returns [ 3, 6 ]
d8(3); // rolls three d8's
// returns [ 8, 2, 2 ]
If you have a need for dice with symbols, multiple values per facing, or to change the probability curve.
import { Dice } from "@damienbullis/dice";
// Create a custom die
const SuccessDie = Dice([
"Success+Crit",
"Success",
"Success",
"Failure+Crit",
"Failure",
"Failure",
]);
SuccessDie(); // rolls the die once
// returns [ "Failure+Crit" ]
To roll a pool of dice, you can use the Pool
function in conjunction with the Dice
function.
import { Dice, Pool } from "@damienbullis/dice";
const d6 = Dice(6);
const d20 = Dice(20);
// Create a pool of dice
const pool = Pool(d6, d20);
pool(); // rolls the pool once
// returns [ [ 3, 20 ] ]
pool(2); // rolls the pool twice
// returns [ [ 6, 12 ], [ 1, 18 ] ]
- Add error handling
- Add tests
- Publish to NPM
- Better Types*
- Custom Weights for Dice*
- Custom Random Number Generator's*
*Not sure about these yet...
Contributions are welcome! Please open an issue or PR.