Utilities to RPG Masters/Users
$ npm install @muxed/rpg-utils
Import the instaled Package
import { RpgUtils } from '@muxed/rpg-utils'
This class is constructed with a new RpgUtils()
. We can pass a parameter to create this pool new RpgUtils(20)
. The parameter is the Faces of the dice (6 by default).
This class have methods:
let pool = new RpgUtils(10);
pool.cleanPoolOfDices(); // Clean a saved dices in the class
pool.rollDices(4) // Return an Array(4) of random number between 1 and 10 (the Faces)
pool.rollDicesAsync(6) // Return a Promise of Array<numbers>
pool.addNewRolls(3); // Add 3 new rolls to the pool
pool.addNewRolls(3,20); // Add 3 new rolls of 20 faces to the pool
pool.sumRolls() // Return the sum of all pool
pool.modifyRoll(3); // Add modifications to the rolls
pool.setCritical(10); // Set the critical hit
pool.setFailure(10); // Set the failure hit
/* ADVANCED */
pool.headOrTails(4); // Check a Coin flip (4 times)
pool.checkSuccess(8); // Check if the rolls is Success
pool.checkSuccess(4, 2, true) // Check if roll is success with 2 dices and down success
// We can access to the Faces and number of Dices and set it
pool.faces = 6;
console.log(pool.faces); // 6
// TS support interfaces Dice and ResponseRoll
import { Dice } from '@muxed/rpg-utils'
const dices: Array<Dice> = [];
Structure of a Dice
{
faces: number,
roll: number,
rollModified: number,
modificator?: number,
critical?: number,
failure?:number,
min: number,
max: number
}
Structure of a Response for Advanced rolls
{
rolls: Array<number | string | undefined>,
modifiedRolls?: Array<number | string | undefined>,
success:string,
countSuccess: number,
countFail: number,
countCritical?: number,
countFailure?: number
}
Install the Jest dependencies if not in global
$ npm install
Run the tests
$ npm test
$ npm run coverage
Please read CONTRIBUTING for details on our CODE OF CONDUCT, and the process for submitting pull requests.
MIT © MuXeD
⌨️ with ❤︎ by MuXeD