Merge pull request #14 from TobenderZephyr/cleanup

Cleanup
This commit is contained in:
2021-04-18 16:04:11 +02:00
committed by GitHub
5 changed files with 48 additions and 35 deletions

View File

@ -1,5 +1,4 @@
const globals = require('../globals');
//const Random = require('random');
const { roll } = require('@dsabot/Roll');
const { findMessage }= require('@dsabot/findMessage');
@ -11,9 +10,7 @@ module.exports = {
needs_args: false,
async exec(message, args) {
//Random.use(message.author.tag);
const coin = roll(1,2,message.author.tag).dice; //Random.int(0, 1);
// message.reply('Die Münze bleibt auf **' + globals.Coin[coin] + '** liegen.');
const coin = roll(1,2,message.author.tag).dice;
message.reply(`${findMessage('HEADS_OR_TAILS')} **${globals.Coin[(coin-1)]}**.`);
},
};

View File

@ -1,6 +1,6 @@
const globals = require('../globals');
const Discord = require('discord.js');
const { Capitalize } = require('@dsabot/Capitalize');
module.exports = {
name: 'talents',
@ -10,27 +10,33 @@ module.exports = {
needs_args: false,
async exec(message, args) {
const fields = [];
for (const i in globals.TalentKategorien) {
const ability = [];
for (const a in globals.Talente) {
if (globals.Talente[a].categoryid == i) {
ability.push(globals.Talente[a].id.charAt(0).toUpperCase() + globals.Talente[a].id.slice(1));
}
}
ability.sort();
fields.push(ability);
}
const Embed = new Discord.MessageEmbed()
.setColor('#0099ff')
.setTitle('Talentübersicht')
.setDescription('Das sind die Talente, die ich kenne:');
for (const i in fields) {
Embed.addField(globals.TalentKategorien[i], fields[i].join('\n'), true);
for (let Talent of GenerateTalentList()) {
Embed.addField(Talent.Category, Talent.Talents.join('\n'), true);
}
message.author.send(
Embed,
);
},
};
const GenerateTalentList = () => {
const Categories = globals.TalentKategorien;
const Talents = globals.Talente;
const TalentList = [];
Categories.forEach(Category => {
TalentList.push({
Category: Category,
Talents: Talents.filter(Talent => Talent.categoryid === Categories.indexOf(Category))
.map(Talent => Capitalize(Talent.id))
.sort()
});
});
return TalentList.sort();
};

View File

@ -1,5 +1,6 @@
const globals = require('../globals');
const Discord = require('discord.js');
const { Capitalize } = require('@dsabot/Capitalize');
module.exports = {
@ -10,27 +11,31 @@ module.exports = {
needs_args: false,
async exec(message, args) {
let fields = [];
for (let CombatTechnique in globals.CombatTechniques) {
let Weapons = [];
for (let Weapon in globals.Weapons) {
if (globals.Weapons[Weapon].combattechnique == globals.CombatTechniques[CombatTechnique].id) {
Weapons.push(globals.Weapons[Weapon].id.charAt(0).toUpperCase() + globals.Weapons[Weapon].id.slice(1));
}
}
Weapons.sort();
fields.push(Weapons);
}
const Embed = new Discord.MessageEmbed()
.setColor('#0099ff')
.setTitle('Waffenübersicht')
.setDescription('Folgende Waffen können für einen Angriff genutzt werden:');
for (let i in fields) {
Embed.addField(globals.CombatTechniques[i].name, fields[i].join('\n'), true);
for (let Technique of GenerateWeaponList()) {
Embed.addField(Technique.Technique_Name, Technique.Weapons.join('\n'), true);
}
message.author.send(
Embed,
);
},
};
};
const GenerateWeaponList = () => {
let WeaponList = [];
const Techniques = globals.CombatTechniques;
const Weapons = globals.Weapons;
Techniques.forEach(Technique => {
WeaponList.push({
Technique_Name: Technique.name,
Weapons: Weapons.filter(Weapon => Weapon.combattechnique === Technique.id)
.map(Weapon => Capitalize(Weapon.id))
});
});
return WeaponList.sort();
};

5
functions/Capitalize.js Normal file
View File

@ -0,0 +1,5 @@
const Capitalize = (Word = 'none') => {
return Word[0].toUpperCase() + Word.substring(1);
};
module.exports = { Capitalize };

View File

@ -176,7 +176,7 @@ const MeleeWeapons = [
{ id: 'thorwalerschild', name: 'Thorwalerschild', dice: 1, diemodificator: 1, at_mod: -5, pa_mod: 2, article: 2, DmgThreshold: 16, combattechnique: 'schilde'},
{ id: 'grossschild', name: 'Großschild', dice: 1, diemodificator: 1, at_mod: -6, pa_mod: 3, article: 2, DmgThreshold: 16, combattechnique: 'schilde'},
{ id: 'barbarenschwert', name: 'Barbarenschwert', dice: 1, diemodificator: 5, at_mod: -1, pa_mod: -1, article: 2, DmgThreshold: 15, combattechnique: 'schwerter'},
{ id: 'entermesser', name: 'Entermesser', dice: 1, diemodificator: 3, at_mod: 0, pa_mod: -1, article: 2, DmgThreshold: 15, ombattechnique: 'schwerter'},
{ id: 'entermesser', name: 'Entermesser', dice: 1, diemodificator: 3, at_mod: 0, pa_mod: -1, article: 2, DmgThreshold: 15, combattechnique: 'schwerter'},
{ id: 'haumesser', name: 'Haumesser', dice: 1, diemodificator: 3, at_mod: 0, pa_mod: -1, article: 2, DmgThreshold: 15, combattechnique: 'schwerter'},
{ id: 'khunchomer', name: 'Khunchomer', dice: 1, diemodificator: 4, at_mod: 0, pa_mod: 0, article: 3, DmgThreshold: 15, combattechnique: 'schwerter'},
{ id: 'kurzschwert', name: 'Kurzschwert', dice: 1, diemodificator: 2, at_mod: 0, pa_mod: 0, article: 2, DmgThreshold: 15, combattechnique: 'schwerter'},
@ -191,7 +191,7 @@ const MeleeWeapons = [
{ id: 'kampfstab', name: 'Kampfstab', dice: 1, diemodificator: 2, at_mod: 0, pa_mod: 2, article: 0, DmgThreshold: 15, combattechnique: 'stangenwaffen'},
{ id: 'magierstablang', name: 'Magierstab: Lang', dice: 1, diemodificator: 2, at_mod: -1, pa_mod: 2, article: 0, DmgThreshold: 16, combattechnique: 'stangenwaffen'},
{ id: 'speer', name: 'Speer', dice: 1, diemodificator: 4, at_mod: 0, pa_mod: 0, article: 0, DmgThreshold: 15, combattechnique: 'stangenwaffen'},
{ id: 'zweililien', name: 'Zweililien', dice: 1, diemodificator: 4, at_mod: 0, pa_mod: 0, article: 3, DmgThreshold: 15, ombattechnique: 'stangenwaffen'},
{ id: 'zweililien', name: 'Zweililien', dice: 1, diemodificator: 4, at_mod: 0, pa_mod: 0, article: 3, DmgThreshold: 15, combattechnique: 'stangenwaffen'},
{ id: 'anderthalbhaender', name: 'Anderthalbhänder', dice: 1, diemodificator: 6, at_mod: 0, pa_mod: 0, article: 0, DmgThreshold: 14, combattechnique: 'zweihandschwerter'},
{ id: 'doppelkhunchomer', name: 'Doppelkhunchomer', dice: 2, diemodificator: 3, at_mod: 0, pa_mod: -2, article: 3, DmgThreshold: 14, combattechnique: 'zweihandschwerter'},
{ id: 'grossersklaventod', name: 'Großer Sklaventod', dice: 2, diemodificator: 6, at_mod: 0, pa_mod: -2, article: 3, DmgThreshold: 14, combattechnique: 'zweihandschwerter'},