* fixing typos * merge Dynamic commands (#3) * Update README.md * Update README.md * fixing typos * dynamically read new commands inside folder. * eslint, update package.json due to moving files Co-authored-by: Marcus Netz <marcus.netz@godyo.com> * fix talent checking on empty arguments list * Origin/message embed (#4) * add first embedded message on tp.js * move db from message commands * fix missing arguments list, add need_args * add global Message Replies. * add more global Message Replies. * more embedded messages. fixing string * missing comma * adding a few more strings on talents. Co-authored-by: Marcus Netz <marcus.netz@godyo.com> * fixing creating from json file * bugfix: db not defined * possible fix for nonworking talent? * fix double msg * fix: aliases are now being used * change: show command displays now some character attributes * added various aliases to commands, added global strings. * added melee combat rolling. * removed purse from creation of character * added attack command to bring some combat features. * added weapons command, renamed some command files. * updated README for new commands Co-authored-by: Marcus Netz <marcus.netz@godyo.com>
64 lines
1.8 KiB
JavaScript
64 lines
1.8 KiB
JavaScript
const globals = require('../globals')
|
|
const db = globals.db
|
|
const Random = require('random')
|
|
/*
|
|
"meleeweapons": [{
|
|
"amount": 1,
|
|
"equipped": true,
|
|
"handling": [],
|
|
"ruleelement": {
|
|
"id": "dolch",
|
|
"type": "meleeweapon"
|
|
}
|
|
}, {
|
|
"amount": 1,
|
|
"equipped": true,
|
|
"handling": [],
|
|
"ruleelement": {
|
|
"id": "waqqif",
|
|
"type": "meleeweapon"
|
|
}
|
|
}],
|
|
*/
|
|
module.exports = {
|
|
name: 'ranged',
|
|
description: 'Würfelt den Attackewert auf eine Nahkampfwaffe.',
|
|
aliases: ['fernkampf'],
|
|
usage: '<Waffe>',
|
|
needs_args: true,
|
|
|
|
async exec(message, args) {
|
|
try {
|
|
db.find({
|
|
user: message.author.tag,
|
|
}, function(err, docs) {
|
|
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
|
|
for (let i = 0; i < Weapon.dice; i++) {
|
|
dice.push(Random.int(1,6))
|
|
}
|
|
dice.forEach(result => {
|
|
sum += result
|
|
})
|
|
message.reply('Du schlägst mit ' + Weapon.name + ' zu. (' + Weapon.dice + 'W6+' + Weapon.diemodificator +')\nDeine 🎲: ' + dice.join(',') + '.\n' + 'Dein Angriff macht **' + sum + '** Schaden.');
|
|
}
|
|
});
|
|
}
|
|
catch (e) {
|
|
throw e;
|
|
}
|
|
},
|
|
}; |