* linting, rolling dice now calculates the sum of each shown value.

* package update
This commit is contained in:
2021-02-09 17:23:23 +01:00
committed by GitHub
parent 20fb66643e
commit 9c0c365cd5
13 changed files with 201 additions and 202 deletions

View File

@ -13,16 +13,18 @@ module.exports = {
Random.use(message.author.tag);
let msg;
let arguments = args.join('');
arguments = arguments.split(globals.DiceRegex);
if (arguments.length == 2) {
let arguments = args.join('').split(globals.DiceRegex);
if (arguments.length >= 2) {
let bonus = 0;
const numberOfDice = parseInt(arguments[0]);
const diceValues = parseInt(arguments[1]);
console.log(diceValues)
if (arguments.length==3) { bonus = parseInt(arguments[2]); }
let sum = bonus;
const roll = [];
for (let i = 0; i < numberOfDice; i++) {
const a = Random.int(1, diceValues);
roll.push(a);
sum += a;
}
if (numberOfDice == 1) {
msg = 'n';
@ -30,7 +32,8 @@ module.exports = {
else {
msg = ' ' + numberOfDice;
}
message.reply('Das sind deine Ergebnisse für deine' + msg + ' ' + diceValues + '-seitigen 🎲: ' + roll.join(', ') + '.');
//message.reply('Das sind deine Ergebnisse für deine' + msg + ' ' + diceValues + '-seitigen 🎲: ' + roll.join(', ') + '. (Gesamt: ' + roll.reduce((pv, cv) => pv + cv, 0) + ' + ' + bonus[1] + ' = ' + sum + ')');
message.reply(`Das sind die Ergebnisse für deine${msg} ${diceValues}-seitigen 🎲: ${roll.join(', ')}. (Gesamt: ${roll.reduce((pv, cv) => pv + cv, 0)} + ${bonus} = ${sum})`);
}
},
};