* 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

@ -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');
module.exports = {
name: 'attack',
@ -14,103 +14,103 @@ 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);
const Player = docs[0].character
const Weapon = globals.Weapons.find(w => w.id === args[0].toLowerCase())
if(!Weapon) { return message.reply(globals.Replies.find(r => r.id === 'NO_SUCH_WEAPON').string)}
const Player = docs[0].character;
const Weapon = globals.Weapons.find(w => w.id === args[0].toLowerCase());
if(!Weapon) { return message.reply(globals.Replies.find(r => r.id === 'NO_SUCH_WEAPON').string); }
// Determining Both Attack and Ranged Attack Values.
const CombatTechnique = globals.CombatTechniques.find(technique => technique.id === Weapon.combattechnique)
let PlayerCombatTechnique = Player.combattechniques.find(technique => technique.id === CombatTechnique.id)
let CombatTechniqueValue = null
if (PlayerCombatTechnique) { CombatTechniqueValue = PlayerCombatTechnique.level }
if(!CombatTechniqueValue) { CombatTechniqueValue = 6 }
let Attribute
let AttackValue = CombatTechniqueValue
const CombatTechnique = globals.CombatTechniques.find(technique => technique.id === Weapon.combattechnique);
let PlayerCombatTechnique = Player.combattechniques.find(technique => technique.id === CombatTechnique.id);
let CombatTechniqueValue = null;
if (PlayerCombatTechnique) { CombatTechniqueValue = PlayerCombatTechnique.level; }
if(!CombatTechniqueValue) { CombatTechniqueValue = 6; }
let Attribute;
let AttackValue = CombatTechniqueValue;
if (globals.MeleeWeapons.find(MeleeWeapon => MeleeWeapon.id === Weapon.id)) {
// For melee combat, MU is used for determining the Attack Value. Also, any weapon-based attack modifiers apply.
Attribute = Player.attributes.find(a => a.id === 'mut').level
AttackValue += Weapon.at_mod
Attribute = Player.attributes.find(a => a.id === 'mut').level;
AttackValue += Weapon.at_mod;
}
else {
// For ranged combat, FF is used for determining Attack Value
Attribute = Player.attributes.find(a => a.id === 'fingerfertigkeit').level
Attribute = Player.attributes.find(a => a.id === 'fingerfertigkeit').level;
}
AttackValue += Math.floor((Attribute - 8)/3)
AttackValue += Math.floor((Attribute - 8)/3);
let dice = []
let Bonus = 0
if(args[1] && !isNaN(parseInt(args[1]))) { Bonus = parseInt(args[1]) }
let Comparison = Math.floor(AttackValue + Bonus)
let CriticalHit = false
let Patzer = false
let Ok = false
let DoubleDamage = false
let dice = [];
let Bonus = 0;
if(args[1] && !isNaN(parseInt(args[1]))) { Bonus = parseInt(args[1]); }
let Comparison = Math.floor(AttackValue + Bonus);
let CriticalHit = false;
let Patzer = false;
let Ok = false;
let DoubleDamage = false;
for (let i = 0; i < 2; i++) {
dice.push(Random.int(1,20))
dice.push(Random.int(1,20));
}
// If there is a cleaner way to do these checks, I'm all into it.
if((dice[0] == 1) && dice[1] <= Comparison) { CriticalHit = true; DoubleDamage = true; Ok = true }
else if((dice[0] == 1) && dice[1] > Comparison) { CriticalHit = true; Ok = true }
else if((dice[0] == 20) && dice[1] > Comparison) { Patzer = true }
if((dice[0] == 1) && dice[1] <= Comparison) { CriticalHit = true; DoubleDamage = true; Ok = true; }
else if((dice[0] == 1) && dice[1] > Comparison) { CriticalHit = true; Ok = true; }
else if((dice[0] == 20) && dice[1] > Comparison) { Patzer = true; }
else if(dice[0] <= Comparison && !CriticalHit) { Ok = true; dice.pop(); }
else if(dice[0] > Comparison ) { dice.pop(); }
let Reply = 'Du greifst mit ' + globals.Declination[Weapon.article] + ' ' + Weapon.name + ' an.\n'
Reply += 'Dein Angriffswert für ' + CombatTechnique.name + ' ist ' + Math.floor(((Attribute - 8)/3) + CombatTechniqueValue) + '. (KtW: ' + CombatTechniqueValue + ')\n'
Reply += 'Deine 🎲: ` ' + dice.join(', ') + ' `.\n\n'
let Reply = 'Du greifst mit ' + globals.Declination[Weapon.article] + ' ' + Weapon.name + ' an.\n';
Reply += 'Dein Angriffswert für ' + CombatTechnique.name + ' ist ' + Math.floor(((Attribute - 8)/3) + CombatTechniqueValue) + '. (KtW: ' + CombatTechniqueValue + ')\n';
Reply += 'Deine 🎲: ` ' + dice.join(', ') + ' `.\n\n';
if(!Ok) {
Reply += globals.Replies.find(reply => reply.id === 'COMBAT_FAIL').string
if(Patzer) { Reply += globals.Replies.find(reply => reply.id === 'COMBAT_CRIT_FAIL').string }
Reply += globals.Replies.find(reply => reply.id === 'COMBAT_FAIL').string;
if(Patzer) { Reply += globals.Replies.find(reply => reply.id === 'COMBAT_CRIT_FAIL').string; }
}
else {
if(CriticalHit) { Reply += globals.Replies.find(reply => reply.id === 'COMBAT_CRIT_SUCCESS').string }
if(DoubleDamage) { Reply += globals.Replies.find(reply => reply.id === 'COMBAT_DOUBLEDAMAGE').string }
if(!CriticalHit) { Reply += globals.Replies.find(reply => reply.id === 'COMBAT_SUCCESS').string }
if(CriticalHit) { Reply += globals.Replies.find(reply => reply.id === 'COMBAT_CRIT_SUCCESS').string; }
if(DoubleDamage) { Reply += globals.Replies.find(reply => reply.id === 'COMBAT_DOUBLEDAMAGE').string; }
if(!CriticalHit) { Reply += globals.Replies.find(reply => reply.id === 'COMBAT_SUCCESS').string; }
// adding 1 to damage for every point above weapon's "Leiteigenschaft"
// applies only to Melee Weapons.
let AttackBonus = 0
let AttackBonus = 0;
if (globals.MeleeWeapons.find(MeleeWeapon => MeleeWeapon.id === Weapon.id))
{
if(Weapon.DmgThreshold) {
CombatTechnique.Leiteigenschaft.forEach(LEKuerzel => {
let Leiteigenschaft = globals.Werte.find(attribute => attribute.kuerzel === LEKuerzel)
let DmgThreshold = Weapon.DmgThreshold
let AttributeValue = Player.attributes.find(attribute => attribute.id === Leiteigenschaft.id).level
let Leiteigenschaft = globals.Werte.find(attribute => attribute.kuerzel === LEKuerzel);
let DmgThreshold = Weapon.DmgThreshold;
let AttributeValue = Player.attributes.find(attribute => attribute.id === Leiteigenschaft.id).level;
if(DmgThreshold<AttributeValue) {
AttackBonus += Math.floor(AttributeValue - DmgThreshold)
AttackBonus += Math.floor(AttributeValue - DmgThreshold);
}
})
});
}
}
const DieModificator = Weapon.diemodificator
let Damage = DieModificator + AttackBonus
let DamageDice = []
const DieModificator = Weapon.diemodificator;
let Damage = DieModificator + AttackBonus;
let DamageDice = [];
for (let i = 0; i < Weapon.dice; i++) {
DamageDice.push(Random.int(1,6))
DamageDice.push(Random.int(1,6));
}
DamageDice.forEach(result => {
Damage += result
})
if(DoubleDamage) { Damage *= 2 }
Damage += result;
});
if(DoubleDamage) { Damage *= 2; }
Reply += '\n\nHier aufklappen, wenn der Gegner nicht parieren/Ausweichen konnte:\n'
Reply += '||' + globals.Articles[Weapon.article] + ' ' + Weapon.name + ' (' + Weapon.dice + 'W6+' + Weapon.diemodificator +') erzielt ` ' + Damage + ' ` Schaden.'
Reply += '\nDeine 🎲: ` ' + DamageDice.join(',') + ' `.||\n'
Reply += '\n\nHier aufklappen, wenn der Gegner nicht parieren/Ausweichen konnte:\n';
Reply += '||' + globals.Articles[Weapon.article] + ' ' + Weapon.name + ' (' + Weapon.dice + 'W6+' + Weapon.diemodificator +') erzielt ` ' + Damage + ' ` Schaden.';
Reply += '\nDeine 🎲: ` ' + DamageDice.join(',') + ' `.||\n';
}
return message.reply( Reply )
return message.reply( Reply );
}
});

View File

@ -1,6 +1,6 @@
const globals = require('../globals');
const Random = require('random');
const db = globals.db
const db = globals.db;
module.exports = {
name: 'attribute',
@ -19,7 +19,7 @@ module.exports = {
// user calls with text. need to gather info from database
if (isNaN(args[0])) {
if (!docs.length > 0) {
if (docs.length === 0) {
message.reply(globals.Replies.find(r => r.id === 'NOENTRY').string);
return;
}

View File

@ -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 +')');
}
});

View File

@ -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');
module.exports = {
name: 'parry',
@ -14,66 +14,66 @@ 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);
const Player = docs[0].character
const Weapon = globals.Weapons.find(w => w.id === args[0].toLowerCase())
if(!Weapon) { return message.reply(globals.Replies.find(r => r.id === 'NO_SUCH_WEAPON').string)}
const Player = docs[0].character;
const Weapon = globals.Weapons.find(w => w.id === args[0].toLowerCase());
if(!Weapon) { return message.reply(globals.Replies.find(r => r.id === 'NO_SUCH_WEAPON').string);}
if(!globals.MeleeWeapons.find(MeleeWeapon => MeleeWeapon.id === Weapon.id)) {
return message.reply(globals.Replies.find(r => r.id === 'PARRY_WRONG_WEAPON').string)
return message.reply(globals.Replies.find(r => r.id === 'PARRY_WRONG_WEAPON').string);
}
const CombatTechnique = globals.CombatTechniques.find(technique => technique.id === Weapon.combattechnique)
let PlayerCombatTechnique = Player.combattechniques.find(technique => technique.id === CombatTechnique.id)
let CombatTechniqueValue = null
if (PlayerCombatTechnique) { CombatTechniqueValue = PlayerCombatTechnique.level }
if(!CombatTechniqueValue) { CombatTechniqueValue = 6 }
const CombatTechnique = globals.CombatTechniques.find(technique => technique.id === Weapon.combattechnique);
let PlayerCombatTechnique = Player.combattechniques.find(technique => technique.id === CombatTechnique.id);
let CombatTechniqueValue = null;
if (PlayerCombatTechnique) { CombatTechniqueValue = PlayerCombatTechnique.level; }
if(!CombatTechniqueValue) { CombatTechniqueValue = 6; }
let ParryValue = Math.ceil(CombatTechniqueValue/2)
for (let i in CombatTechnique.Leiteigenschaft) {
let Attribute = globals.Werte.find(a => a.kuerzel === CombatTechnique.Leiteigenschaft[i]).id
ParryValue += Math.floor((Player.attributes.find(a => a.id === Attribute).level - 8)/3)
}
ParryValue += Weapon.pa_mod
let ParryValue = Math.ceil(CombatTechniqueValue/2);
CombatTechniqueValue.Leiteigenschaft.forEach( Property => {
let Attribute = globals.Werte.find(a => a.kuerzel === Property.id);
ParryValue += Math.floor((Player.attributes.find(a => a.id === Attribute).level - 8)/3);
});
ParryValue += Weapon.pa_mod;
let dice = []
let Bonus = 0
if(args[1] && !isNaN(parseInt(args[1]))) { Bonus = parseInt(args[1]) }
let Comparison = Math.floor(ParryValue + Bonus)
let Patzer = false
let Critical = false
let Ok = false
let dice = [];
let Bonus = 0;
if(args[1] && !isNaN(parseInt(args[1]))) { Bonus = parseInt(args[1]); }
let Comparison = Math.floor(ParryValue + Bonus);
let Patzer = false;
let Critical = false;
let Ok = false;
for (let i = 0; i < 2; i++) {
dice.push(Random.int(1,20))
dice.push(Random.int(1,20));
}
// If there is a cleaner way to do these checks, I'm all into it.
if((dice[0] == 1) && dice[1] <= Comparison) { Critical = true; Ok = true }
if((dice[0] == 1) && dice[1] <= Comparison) { Critical = true; Ok = true; }
else if(dice[0] <= Comparison && !Critical) { Ok = true; dice.pop(); }
else if((dice[0] == 20) && dice[1] > Comparison) { Patzer = true }
else if((dice[0] == 20) && dice[1] > Comparison) { Patzer = true; }
else if(dice[0] > Comparison ) { dice.pop(); }
let Reply = 'Du versuchst, mit ' + globals.Declination[Weapon.article] + ' ' + Weapon.name + ' zu parieren.\n'
Reply += 'Dein Paradewert für ' + CombatTechnique.name + ' ist ' + Math.floor(ParryValue - Weapon.pa_mod) + '. (Waffe: ' + Weapon.pa_mod + ')\n'
Reply += 'Deine 🎲: ` ' + dice.join(', ') + ' `.\n\n'
let Reply = 'Du versuchst, mit ' + globals.Declination[Weapon.article] + ' ' + Weapon.name + ' zu parieren.\n';
Reply += 'Dein Paradewert für ' + CombatTechnique.name + ' ist ' + Math.floor(ParryValue - Weapon.pa_mod) + '. (Waffe: ' + Weapon.pa_mod + ')\n';
Reply += 'Deine 🎲: ` ' + dice.join(', ') + ' `.\n\n';
if(!Ok) {
Reply += globals.Replies.find(reply => reply.id === 'PARRY_FAIL').string
if(Patzer) { Reply += globals.Replies.find(reply => reply.id === 'PARRY_CRIT_FAIL').string }
Reply += globals.Replies.find(reply => reply.id === 'PARRY_FAIL').string;
if(Patzer) { Reply += globals.Replies.find(reply => reply.id === 'PARRY_CRIT_FAIL').string; }
}
else {
if(Critical) { Reply += globals.Replies.find(reply => reply.id === 'PARRY_CRIT_SUCCESS').string }
if(!Critical) { Reply += globals.Replies.find(reply => reply.id === 'PARRY_SUCCESS').string }
if(Critical) { Reply += globals.Replies.find(reply => reply.id === 'PARRY_CRIT_SUCCESS').string; }
if(!Critical) { Reply += globals.Replies.find(reply => reply.id === 'PARRY_SUCCESS').string; }
}
return message.reply( Reply )
return message.reply( Reply );
}
});

View File

@ -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,27 @@ 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 = []
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
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('Du schlägst mit ' + Weapon.name + ' zu. (' + Weapon.dice + 'W6+' + Weapon.diemodificator +')\nDeine 🎲: ' + dice.join(',') + '.\n' + 'Dein Angriff macht **' + sum + '** Schaden.');
}
});

View File

@ -1,5 +1,5 @@
const globals = require('../globals')
const db = globals.db
const globals = require('../globals');
const db = globals.db;
module.exports = {
name: 'remove',
description: 'Löscht deinen Charakter aus der Datenbank. Sinnvoll, wenn du mir eine neue zusenden möchtest.',

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})`);
}
},
};

View File

@ -1,7 +1,7 @@
// eslint-disable-next-line no-unused-vars
const globals = require('../globals')
const Discord = require('discord.js')
const db = globals.db
const globals = require('../globals');
const Discord = require('discord.js');
const db = globals.db;
module.exports = {
name: 'show',
@ -15,18 +15,18 @@ 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 {
let gender
if (docs[0].character.sex == 'female') { gender = '♀️' }
else { gender = '♂️' }
const Reply = new Discord.MessageEmbed()
Reply.setColor('#0099ff')
Reply.setTitle(gender + ' ' + docs[0].character.name)
Reply.setDescription(docs[0].character.age + ' Jahre, ' + docs[0].character.race + '/' + docs[0].character.culture)
Reply.addField(docs[0].character.professionname, docs[0].character.xp.startinglevel)
let gender;
if (docs[0].character.sex == 'female') { gender = '♀️'; }
else { gender = '♂️'; }
const Reply = new Discord.MessageEmbed();
Reply.setColor('#0099ff');
Reply.setTitle(gender + ' ' + docs[0].character.name);
Reply.setDescription(docs[0].character.age + ' Jahre, ' + docs[0].character.race + '/' + docs[0].character.culture);
Reply.addField(docs[0].character.professionname, docs[0].character.xp.startinglevel);
message.reply( Reply );
}

View File

@ -1,5 +1,5 @@
const globals = require('../globals')
const db = globals.db
const globals = require('../globals');
const db = globals.db;
module.exports = {
name: 'skill',
description: 'Zeigt dir deinen Fertigkeitswert im jeweiligen Talent.',
@ -12,12 +12,12 @@ 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 {
let level = 0;
for (i in docs[0].character.skills) {
for (let i in docs[0].character.skills) {
if (docs[0].character.skills[i].id == args[0]) level = docs[0].character.skills[i].level;
}
message.reply('Du hast folgenden Talentwert in ' + args[0] + ': ' + level);

View File

@ -1,7 +1,7 @@
const globals = require('../globals');
const Random = require('random');
const Discord = require('discord.js')
const db = globals.db
const Discord = require('discord.js');
const db = globals.db;
module.exports = {
name: 'talent',
@ -16,11 +16,11 @@ 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);
}
if(!isNaN(args[0])) {
return message.reply(globals.Replies.find(x => x.id === 'WRONG_ARGUMENTS').string)
return message.reply(globals.Replies.find(x => x.id === 'WRONG_ARGUMENTS').string);
}
else {
Random.use(message.author.tag);
@ -32,7 +32,7 @@ module.exports = {
let ok = 0;
let patzer = 0;
let crit = 0;
let erschwernis = 0
let erschwernis = 0;
if (args[1]) {
erschwernis = parseInt(args[1]);
@ -59,12 +59,12 @@ module.exports = {
const bonus_orig = bonus;
const result = globals.Talente.find(t => t.id === talent);
for (i in result.values) {
const kuerzel = globals.Werte.find(wert => wert.kuerzel === result.values[i]);
for (val in docs[0].character.attributes) {
if (docs[0].character.attributes[val].id == kuerzel.id) values.push(docs[0].character.attributes[val].level);
}
}
result.values.forEach(value => {
let kuerzel = globals.Werte.find(wert => wert.kuerzel === value);
docs[0].character.attributes.forEach(attr => {
if (attr == kuerzel.id) { values.push(attr.level);}
});
});
for (let i = 1; i <= 3; i++) {
roll.push(Random.int(1, 20));
@ -81,25 +81,25 @@ module.exports = {
if (roll[i] == 1) crit++;
if (roll[i] == 20) patzer++;
}
const Reply = new Discord.MessageEmbed()
Reply.setTitle('Du würfelst auf das Talent ' + result.name + '.')
Reply.setDescription('Deine Werte für ' + result.values.join(', ') + ' sind ' + values.join(', ') + '. (Bonus: ' + bonus_orig + ')')
const Reply = new Discord.MessageEmbed();
Reply.setTitle('Du würfelst auf das Talent ' + result.name + '.');
Reply.setDescription('Deine Werte für ' + result.values.join(', ') + ' sind ' + values.join(', ') + '. (Bonus: ' + bonus_orig + ')');
Reply.addFields({
name: 'Deine 🎲: ' + roll.join(', ') + '.',
value: '\u200B', inline: false})
value: '\u200B', inline: false});
if (patzer >= 2) {
Reply.setColor('#900c3f')
Reply.setColor('#900c3f');
Reply.addFields({
name: globals.Replies.find(x => x.id === 'TITLE_CRIT_FAILURE').string,
value: globals.Replies.find(x => x.id === 'MSG_CRIT_FAILURE').string,
inline: false})
inline: false});
}
else if (crit >= 2) {
Reply.setColor('#1E8449')
Reply.setColor('#1E8449');
Reply.addFields({
name: globals.Replies.find(x => x.id === 'TITLE_CRIT_SUCCESS').string,
value:globals.Replies.find(x => x.id === 'MSG_CRIT_SUCCESS').string,
inline: false})
inline: false});
}
else if (ok < 3) {
Reply.addFields({name: globals.Replies.find(x => x.id === 'TITLE_FAILURE').string,
@ -109,10 +109,10 @@ module.exports = {
else {
Reply.addFields({name: globals.Replies.find(x => x.id === 'TITLE_SUCCESS').string,
value: ok + '/3 Proben erfolgreich. Dein Bonus: ' + bonus + '/' + bonus_orig + '.',
inline: false})
inline: false});
}
message.reply(Reply)
message.reply(Reply);
}
});
}

View File

@ -1,7 +1,7 @@
// eslint-disable-next-line no-unused-vars
const Random = require('random');
const globals = require('../globals')
const Discord = require('discord.js')
const globals = require('../globals');
const Discord = require('discord.js');
module.exports = {
name: 'tp',
@ -15,17 +15,17 @@ module.exports = {
async exec(message, args) {
if(isNaN(args[0])) {
return message.reply(globals.Replies.find(x => x.id === 'WRONG_ARGUMENTS').string)
return message.reply(globals.Replies.find(x => x.id === 'WRONG_ARGUMENTS').string);
}
Random.use(message.author.tag);
const roll = [];
let bonus = 0
let bonus_orig = 0
let erschwernis = 0
let bonus = 0;
let bonus_orig = 0;
let erschwernis = 0;
if (args[3]) {
bonus_orig = parseInt(args[3]);
bonus = bonus_orig
bonus = bonus_orig;
}
if (args[4]) {
erschwernis = parseInt(args[4]);
@ -48,36 +48,36 @@ module.exports = {
if (roll[i] == 20) patzer++;
}
const Reply = new Discord.MessageEmbed()
const Reply = new Discord.MessageEmbed();
//Reply.setTitle('Du würfelst auf ' + args[0] + ' ' + args[1] + ' ' + args[2] + ' (Bonus: ' + bonus_orig + ')')
Reply.setTitle('Deine 🎲: ' + roll.join(', ') + '.')
Reply.setTitle('Deine 🎲: ' + roll.join(', ') + '.');
if (patzer >= 2) {
Reply.setColor('#900c3f')
Reply.setColor('#900c3f');
Reply.addFields({
name: globals.Replies.find(x => x.id === 'TITLE_CRIT_FAILURE').string,
value: globals.Replies.find(x => x.id === 'MSG_CRIT_FAILURE').string,
inline: false
})
});
} else if (crit >= 2) {
Reply.setColor('#1E8449')
Reply.setColor('#1E8449');
Reply.addFields({
name: globals.Replies.find(x => x.id === 'TITLE_CRIT_SUCCESS').string,
value: globals.Replies.find(x => x.id === 'MSG_CRIT_SUCCESS').string,
inline: false
})
});
} else if (ok < 3) {
Reply.addFields({
name: globals.Replies.find(x => x.id === 'TITLE_FAILURE').string,
value: 'Nur ' + ok + '/3 Proben erfolgreich. 😪',
inline: false
})
});
} else {
Reply.addFields({
name: globals.Replies.find(x => x.id === 'TITLE_SUCCESS').string,
value: ok + '/3 Proben erfolgreich. Dein Bonus: ' + bonus + '/' + bonus_orig + '.',
inline: false
})
});
}
message.reply(Reply)
message.reply(Reply);
}
}
};

View File

@ -1,15 +1,15 @@
const Discord = require('discord.js')
const Discord = require('discord.js');
const Datastore = require('nedb'),
db = new Datastore({
filename: 'data/dsabot.db',
autoload: true,
});
const MessageEmbed = new Discord.MessageEmbed()
const MessageEmbed = new Discord.MessageEmbed();
const money = [{
'GD': 'Golddukaten',
'ST': 'Silbertaler',
}];
const DiceRegex = /\s?[DdWw]\s?/;
const DiceRegex = /\s?[DdWw]\s?|(?=\-|\+)/;
const Coin = ['Kopf', 'Zahl'];
const Werte = [
{ id: 'mut', kuerzel: 'MU', name: 'Mut' },
@ -21,7 +21,7 @@ const Werte = [
{ id: 'konstitution', kuerzel: 'KO', name: 'Konstitution' },
{ id: 'koerperkraft', kuerzel: 'KK', name: 'Körperkraft' },
];
const TalentKategorien = ['Körpertalente','Gesellschaftstalente','Naturtalente','Wissenstalente','Handwerkstalente']
const TalentKategorien = ['Körpertalente','Gesellschaftstalente','Naturtalente','Wissenstalente','Handwerkstalente'];
const Talente = [
// Körpertalente
@ -140,8 +140,8 @@ const Replies = [
{ id: 'PARRY_SUCCESS', string: 'Parade erfolgreich.'},
{ id: 'PARRY_CRIT_SUCCESS', string: 'Kritischer Erfolg! Du darfst einen Passierschlag ausführen!'}
];
const Declination = ['dem', 'der', 'dem', ''] // Maskulinum, Feminimum, Neutrum, None
const Articles = ['Der','Die','Das','']
const Declination = ['dem', 'der', 'dem', '']; // Maskulinum, Feminimum, Neutrum, None
const Articles = ['Der','Die','Das',''];
const MeleeWeapons = [
{ id: 'basiliskenzunge', name: 'Basiliskenzunge', dice: 1, diemodificator: 2, at_mod: 0, pa_mod: -1, article: 1, DmgThreshold: 14, combattechnique: 'dolche' },
{ id: 'dolch', name: 'Dolch', dice: 1, diemodificator: 1, at_mod: 0, pa_mod: 0, article: 0, DmgThreshold: 14, combattechnique: 'dolche' },
@ -200,7 +200,7 @@ const MeleeWeapons = [
{ id: 'felsspalter', name: 'Felsspalter', dice: 2, diemodificator: 2, at_mod: 0, pa_mod: -2, article: 0, DmgThreshold: 13, combattechnique: 'zweihandhiebwaffen'},
{ id: 'kriegshammer', name: 'Kriegshammer', dice: 2, diemodificator: 3, at_mod: 0, pa_mod: -3, article: 0, DmgThreshold: 13, combattechnique: 'zweihandhiebwaffen'},
{ id: 'zwergenschlaegel', name: 'Zwergenschlägel', dice: 1, diemodificator: 6, at_mod: 0, pa_mod: -1, article: 0, DmgThreshold: 13, combattechnique: 'zweihandhiebwaffen'},
]
];
const RangedWeapons = [
{ id: 'balestrina', name: 'Balestrina', dice: 1, diemodificator: 4, article: 1, combattechnique: 'armbrueste'},
@ -221,15 +221,14 @@ const RangedWeapons = [
{ id: 'wurfscheibe', name: 'Wurfscheibe', dice: 1, diemodificator: 1, article: 1, combattechnique: 'wurfwaffen'},
{ id: 'wurfstern', name: 'Wurfstern', dice: 1, diemodificator: 1, article: 0, combattechnique: 'wurfwaffen'},
{ id: 'wurfspeer', name: 'Wurfspeer', dice: 1, diemodificator: 2, article: 0, combattechnique: 'wurfwaffen'}
]
const Weapons = MeleeWeapons.concat(RangedWeapons)
];
const Weapons = MeleeWeapons.concat(RangedWeapons);
const Advantages = [
{}
]
];
const Disadvantages = [
{}
]
];
module.exports = { Werte, Talente, Coin, TalentKategorien, DiceRegex, Discord, MessageEmbed, db, Replies, MeleeWeapons, Weapons, RangedWeapons, CombatTechniques, Articles, Declination };

View File

@ -1,8 +1,8 @@
require('dotenv').config();
const fs = require('fs')
const fs = require('fs');
const fetch = require('node-fetch');
const globals = require('./globals')
const db = globals.db
const globals = require('./globals');
const db = globals.db;
const cmdprefix = process.env.CMDPREFIX || '!';
const Discord = require('discord.js');
const client = new Discord.Client();
@ -28,7 +28,7 @@ async function commandHandler(message) {
const data = await validateJSON(response);
if (data) await CreateFromFile(message, data);
} catch (e) {
console.log(e)
console.log(e);
return message.reply(globals.Replies.find(x => x.id === 'ERROR').string);
}
} else {
@ -50,10 +50,10 @@ async function commandHandler(message) {
command.exec(message, args);
}
} catch (e) {
message.reply(globals.Replies.find(x => x.id === 'ERROR').string)
message.reply(globals.Replies.find(x => x.id === 'ERROR').string);
}
}
};
}
function validateJSON(body) {
try {
@ -69,7 +69,7 @@ async function CreateFromFile(message, data) {
db.find({
user: message.author.tag,
}, function(err, docs) {
if (!docs.length > 0) {
if (docs.length === 0) {
db.insert({
user: message.author.tag,
character: data,