https://github.com/dlom/anydice
anydice roller
https://github.com/dlom/anydice
anydice dice random
Last synced: about 1 year ago
JSON representation
anydice roller
- Host: GitHub
- URL: https://github.com/dlom/anydice
- Owner: dlom
- License: mit
- Created: 2017-09-22T02:49:39.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-26T21:49:26.000Z (about 8 years ago)
- Last Synced: 2025-03-25T14:06:16.316Z (about 1 year ago)
- Topics: anydice, dice, random
- Language: TypeScript
- Size: 13.7 KB
- Stars: 11
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
anydice.js
==========
[](https://www.npmjs.com/package/anydice)
Note: AnyDice is not particularly _fast_; results can take a second or two to come back
## API
### Simple
```javascript
const { roll } = require("anydice");
// import { roll } from "anydice";
// later...
console.log(await roll("output [highest 1 of 2d20]+10"));
```
### Advanced
```javascript
const { AnyDice } = require("anydice");
// later...
const input = `output [highest 1 of 2d20]+10
output 3d6 named "result 2"`;
const result = await AnyDice.run(input);
const rolls = result.roll(result.first(), 10); // [highest 1 of 2d20]+10
const possibleValues = result.possibleValues("result 2"); // 3d6
console.log(rolls);
console.log(possibleValues);
```