searching of talents aborted prematurely.

This commit is contained in:
Marcus Netz
2020-11-24 22:15:45 +01:00
parent e17476db21
commit f536a02a45
2 changed files with 16 additions and 16 deletions

View File

@ -7,7 +7,7 @@ module.exports = async (message, args, db) => {
return;
}
let level = 8;
let attributename;
let attributename;
await db.find({
user: message.author.tag,
@ -19,14 +19,16 @@ module.exports = async (message, args, db) => {
message.reply('Sorry, Für dich habe ich keinen Eintrag 😥\n' +
'Bitte gib mir den Attributswert, auf welchen du würfeln möchtest.');
return;
}
}
else {
// try to get id of short formatted attributes.
if (args[0].length == 2) {
for (const i in globals.Werte) {
if (globals.Werte[i].kuerzel == args[0].toUpperCase()) attributename = globals.Werte[i].id;
if (globals.Werte[i].kuerzel == args[0].toUpperCase()) {
attributename = globals.Werte[i].id;
}
}
}
}
else {
attributename = args[0].toLowerCase();
}
@ -34,7 +36,7 @@ module.exports = async (message, args, db) => {
if (docs[0].character.attributes[i].id == attributename) level = docs[0].character.attributes[i].level;
}
}
}
}
else {
level = args[0];
}
@ -48,7 +50,7 @@ module.exports = async (message, args, db) => {
if (countOccurrences(dice, 1) == 2) {
message.reply('Du hast einen kritischen Erfolg erzielt (' + dice.join(', ') + ')! 🎉🥳🎆');
return;
}
}
else if (countOccurrences(dice, 20) == 2) {
message.reply('Du hast einen Patzer (' + dice.join(', ') + ')! 😭 Viel Erfolg beim nächsten mal!');
return;
@ -57,22 +59,22 @@ module.exports = async (message, args, db) => {
if (attributename) {
message.reply('Du hast die Probe auf ' + attributename + ' (Stufe ' + level + ') bestanden.\n' +
'Deine 🎲: ' + dice.join(', '));
}
}
else {
message.reply('Du hast die Probe (Stufe ' + level + ') bestanden.\n' +
'Deine 🎲: ' + dice.join(', '));
}
}
}
else if (attributename) {
message.reply('Du hast die Probe auf ' + attributename + ' (Stufe ' + level + ') leider nicht bestanden 😢.\n' +
'Deine 🎲: ' + dice.join(', '));
}
}
else {
message.reply('Du hast die Probe (Stufe ' + level + ') leider nicht bestanden 😢.\n' +
'Deine 🎲: ' + dice.join(', '));
}
});
}
}
catch (e) {
throw e;
}

View File

@ -15,18 +15,16 @@ module.exports = async (message, args, db) => {
}
const values = [];
const roll = [];
let found = false;
let talent
let bonus = 0;
let ok = 0;
let patzer = 0;
let crit = 0;
for (i in docs[0].character.skills) {
if (docs[0].character.skills[i].id == args[0]) {bonus = docs[0].character.skills[i].level; found = true;}
}
if (!found) {
message.reply('Sorry, das Talent ist mir unbekannt.');
return;
if (docs[0].character.skills[i].id == talent) {bonus = docs[0].character.skills[i].level;}
}
const bonus_orig = bonus;
const result = globals.Talente.find(talent => talent.id === args[0]);