dnd-5e-cr-calculator

2.1.0 • Public • Published

dnd-5e-cr-calculator

An npm module that calculates Challenge Rating for Dungeons & Dragons 5th Edition.

How to Use

The main function of the CR Calculator is is calculate() and it takes five arguments: Hit Points, Armor Class, Damage per Round, Attack Bonus, and Save DC. It uses the arguments to calculate the monster's Challenge Rating as described in the Dungeons & Dragons 5th Edition Dungeon Master's Guide.

// An example
var cr = require('dnd-5e-cr-calculator');
 
// Arguments in order: HP, AC, DpR, Atk, Save DC
var value = cr.calculate(5, 14, 30, 5, 14);
 
// value should equal '1'
console.log("Your challenge rating is: " + value);

Alternatively, you can use the calculateWithDice() to enter Damage per Round in the dice string format used in the D&D sourcebooks. When this function is used, the Damage per Round is calculated as an average of the dice formula provided. This is then provided to the calculate() function to return the CR value.

// An example of calculateWithDice()
var cr = require('dnd-5e-cr-calculator');
 
// Arguments: HP, AC, DpR in dice format, Atk, Save DC
var value = cr.calculateWithDice(5, 14, '7d6+5', 5, 14)
 
// value should equal '1' because '7d6+5' averages to 30
console.log("Your challenge rating is: " + value);

How to Run

The D&D 5e CR Calculator is written in Coffeescript, and the package.json contains scripts for compiling the Coffeescript and running tests locally. To get the project up and running locally is very simple:

git clone
npm install
npm run compile

Also, running the tests is as simple as npm run test or npm run test:watch.

Licensing

The dnd-5e-cr-calculator package is released under the MIT license.

Acknowledgements

Dungeons & Dragons is property of Wizards of the Coast.

Readme

Keywords

none

Package Sidebar

Install

npm i dnd-5e-cr-calculator

Weekly Downloads

1

Version

2.1.0

License

MIT

Last publish

Collaborators

  • asmodeusxi