rpgdice

0.2.0 • Public • Published

rpgdice

by: ok 2012

Simple eventful dice for rpg or any dicegame.

Designed to support multiple games and players using the same dice, for example in multiple socket.io rooms.

Usage

Install the module: npm install rpgdice

Require the module: var dice = require('rpgdice');

Roll the dice: dice.roll('1d6+4', 'player1', 'game1')

  • the dice must be in the form of rolls d sides
  • the modifier (+4 etc.), the playername and the gamename can be omitted*

events

dice.on(' event ', function ( args ) {});

'rolling', dice, roller, game

when a player rolls

  • dice string
  • roller string
  • game string

'roll', roll, roller, game

when a single dice rolls

  • roll string
  • roller string
  • game string

'result', dice, rolls, result, roller, game

when all the dice have been rolled

  • dice string
  • rolls array
  • result number
  • roller string
  • game string

'misroll', error, roller, game

if the dice was malformed or other errors occur

  • error error
  • roller string
  • game string

License

MIT: http://ok.mit-license.org/

Dependents (0)

Package Sidebar

Install

npm i rpgdice

Weekly Downloads

0

Version

0.2.0

License

MIT

Last publish

Collaborators

  • gildean