Files
dsabot/functions/Roll.js
TobenderZephyr c6cacdae5e switched nedb to nedb-promises (#37)
* breaking change: switched to nedb-promises
* Linting
* some dev dependencies
* more tests
* updated package version
* bug fixing
* changed isNaN to isString
* (fix) args[0]
2021-05-03 18:39:33 +02:00

18 lines
431 B
JavaScript

const { Random } = require('@dsabot/Random');
//const Random = require('random');
const roll = (numberOfDice, numberOfEyes, tag) => {
const dice = [];
let sum = 0;
if (tag) {
Random.use(tag);
}
for (let i = 0; i < numberOfDice; i += 1) {
const result = Random.int(1, numberOfEyes);
dice.push(result);
sum += result;
}
return { dice, sum };
};
module.exports = { roll };