1.2.2 • Published 6 years ago

@rolodromo/rpgen v1.2.2

Weekly downloads
1
License
GPL
Repository
github
Last release
6 years ago

@rolodromo/rpgen

This module is set of tools for RPG games. It contains:

  • A random table generator
  • A dice roller generator

Installation

You can install it as a node module

$> npm install -S @rolodromo/rpgen

Or add it to your HTML directly from unpkg CDN:

<script src="//unpkg.com/@rolodromo/rpgen"></script>

And then is accesible globally as rpgen object.

Usage

Basic die roller

const rpgen = require('@rolodromo/rpgen')
const myRoller = rpgen.roller.create('best 3 of 4d6+1')

console.log(myRoller()) // output: 16

Live demo (with VueJS)

Multi dice roller

const rpgen = require('@rolodromo/rpgen')
const myRoller = rpgen.roller.create('best 3 of 4d6+1', { repeat: 6 })

console.log(myRoller()) // output: [16, 13, 12, 14, 13, 15]

Live demo (with VueJS)

Basic random table

const myGenerator = rpgen.generator.create(`
;@tpl|main
- [lines]
- [roll]

;lines
line 1 is random
line 2 is awesome
line 3 is great

;roll
1d20 roll: [1d20]
`)
  
console.log(generator.generate()) 
// output: 
// - line 2 is awesome
// - 1d20 roll: 14

Live demo (with VueJS)

TODO

  • Add more complex table generator examples
  • Allow combination of rolls (ex: 4d6 + 3d8)
  • Improve dev workflow with a better webpack config
  • Add filter to convert from number to words (ex: 12 => twelve, 100 => one hundred, etc)
  • Maybe migrate to nearley grammar parser

Previous work

This is the successor of my other unfinished projects: