refactored Skillcheck Command
This commit is contained in:
14
functions/getAttributeLevels.js
Normal file
14
functions/getAttributeLevels.js
Normal file
@ -0,0 +1,14 @@
|
||||
const globals = require('../globals');
|
||||
|
||||
const getAttributeLevels = (Attributes = [], Character = {}) => {
|
||||
let AttributeId;
|
||||
let AttributeLevel;
|
||||
let AttributeList = [];
|
||||
for (let Attribute of Attributes) {
|
||||
AttributeId = globals.Werte.find((attribute) => attribute.kuerzel === Attribute).id;
|
||||
AttributeLevel = Character.attributes.find((att) => att.id === AttributeId).level;
|
||||
AttributeList.push({ Name: Attribute, Level: AttributeLevel });
|
||||
}
|
||||
return AttributeList;
|
||||
};
|
||||
module.exports = { getAttributeLevels};
|
@ -1,20 +1,24 @@
|
||||
const globals = require('../globals');
|
||||
const { getAttributeLevels } = require("@dsabot/getAttributeLevels");
|
||||
|
||||
const getSkill = ({ Character: Character = [], args: args = [] } = {}) => {
|
||||
let skill_entry = globals.Talente.find(skill => skill.id.toLowerCase() === args[0].toLowerCase()) ||
|
||||
globals.Talente.find(skill => skill.name.toLowerCase() === args[0].toLowerCase());
|
||||
let skill_entry = globals.Talente.find(skill => skill.id.toLowerCase() === args[0].toLowerCase()) ||
|
||||
globals.Talente.find(skill => skill.name.toLowerCase() === args[0].toLowerCase());
|
||||
|
||||
if (!skill_entry) { return; }
|
||||
|
||||
let Level = 0; // This is the minimum attributes value.
|
||||
let cSkill = Character.skills.find(skill => skill.id === skill_entry.id) || {};
|
||||
if (cSkill) {
|
||||
Level = cSkill.level || 0;
|
||||
}
|
||||
let Name = globals.Talente.find(skill => skill.id === skill_entry.id).name;
|
||||
let Attributes = getAttributeLevels(skill_entry.values, Character);
|
||||
|
||||
return {
|
||||
Name: Name,
|
||||
Level: Level
|
||||
Level: Level,
|
||||
Attributes: Attributes
|
||||
};
|
||||
};
|
||||
module.exports = { getSkill };
|
||||
|
Reference in New Issue
Block a user