Jslint (#14)
* linting, rolling dice now calculates the sum of each shown value. * package update
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
const globals = require('../globals')
|
||||
const db = globals.db
|
||||
const Random = require('random')
|
||||
const globals = require('../globals');
|
||||
const db = globals.db;
|
||||
const Random = require('random');
|
||||
/*
|
||||
"meleeweapons": [{
|
||||
"amount": 1,
|
||||
@ -32,27 +32,24 @@ module.exports = {
|
||||
db.find({
|
||||
user: message.author.tag,
|
||||
}, function(err, docs) {
|
||||
if (!docs.length > 0) {
|
||||
if (docs.length === 0) {
|
||||
return message.reply(globals.Replies.find(r => r.id === 'NOENTRY').string);
|
||||
}
|
||||
else {
|
||||
|
||||
Random.use(message.author.tag);
|
||||
let dice = []
|
||||
/*for (i in docs[0].character.skills) {
|
||||
if (docs[0].character.skills[i].id == args[0]) level = docs[0].character.skills[i].level;
|
||||
}
|
||||
*/
|
||||
const Weapon = globals.MeleeWeapons.find(weapon => weapon.id === args[0])
|
||||
if(!Weapon) { return message.reply(globals.Replies.find(r => r.id === 'NO_SUCH_WEAPON').string)}
|
||||
const DieModificator = Weapon.diemodificator
|
||||
let sum = DieModificator
|
||||
let dice = [];
|
||||
const Weapon = globals.MeleeWeapons.find(weapon => weapon.id === args[0]);
|
||||
|
||||
if(!Weapon) { return message.reply(globals.Replies.find(r => r.id === 'NO_SUCH_WEAPON').string);}
|
||||
const DieModificator = Weapon.diemodificator;
|
||||
let sum = DieModificator;
|
||||
for (let i = 0; i < Weapon.dice; i++) {
|
||||
dice.push(Random.int(1,6))
|
||||
dice.push(Random.int(1,6));
|
||||
}
|
||||
dice.forEach(result => {
|
||||
sum += result
|
||||
})
|
||||
sum += result;
|
||||
});
|
||||
message.reply('Deine 🎲: ' + dice.join(',') + '.\n' + Weapon.name + ' richtet ` ' + sum + ' ` Schaden an. (' + Weapon.dice + 'W6+' + Weapon.diemodificator +')');
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user