fritzy/jsdice


License: Other

Language: JavaScript


jsDice

adopted and mangled from jsDice.com

The standard dice rolling format for tabletop games is [times]d[sides]. Typical dice strings could add/subtract formats and static numbers together.

jsDice is a small library for parsing dice formula strings as well as rolling the dice.

Basic Usage

var Dice = require('jsdice');
var dieroll = new Dice('4d6   d20 - 3');
var results = dieroll.roll();
console.log(results.total);
// 24
console.log(results.results);
// [ 2, 5, 4, 5, 11, -3 ]

Installation

This adaptation of jsDice is written for Node.js, and may be used browser-side with browserify.

npm install jsdice

Stats Template Usage

When initializing the dice, you can pass a stats object as a second argument to be using in the formula.

var stats = {dex: 12, str: 4, int: 19, agility: 9};
diceroll = new Dice('d10   {str}', stats);
console.log(diceroll.roll());
//{ results: [ 3, 4 ], total: 7 }

Project Statistics

Sourcerank 6
Repository Size 96.7 KB
Stars 5
Forks 3
Watchers 1
Open issues 0
Dependencies 0
Contributors 1
Tags 0
Created
Last updated
Last pushed

Top Contributors See all

Nathan Fritz

Packages Referencing this Repo

jsdice
A simple d20 dice parser and roller based on http://jsdice.com
Latest release 1.1.0 - Updated - 5 stars

Something wrong with this page? Make a suggestion

Last synced: 2017-09-07 21:37:10 UTC

Login to resync this repository