added return list of spells. Moved them into seperate json

This commit is contained in:
2021-04-24 09:53:05 +02:00
parent 8e4f4eedb8
commit e65715cce6
10 changed files with 787 additions and 66 deletions

View File

@ -1,3 +1,12 @@
/**
* Compares each item inside an array Throws
* with corresponding AttributeLevels (With added bonus)
*
* @param {Array} Throws=[]
* @param {Array} AttributeLevels=[8,8,8]
* @param {BigInt} Bonus=0
* @param {BigInt} PointsRemaining=0
*/
const CompareResults = (Throws = [], AttributeLevels = [8, 8, 8], Bonus = 0, PointsRemaining = 0) => {
let Passed = 0;

View File

@ -1,24 +1,27 @@
const globals = require('../globals');
const { getAttributeLevels } = require("@dsabot/getAttributeLevels");
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; }
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);
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,
Attributes: Attributes
};
return {
Name: Name,
Level: Level,
Attributes: Attributes,
};
};
module.exports = { getSkill };

30
functions/getSpell.js Normal file
View File

@ -0,0 +1,30 @@
const globals = require('../globals');
const { getAttributeLevels } = require('@dsabot/getAttributeLevels');
const getSpell = ({ Character: Character = [], spell_name: spell_name = '' } = {}) => {
let spell_entry =
globals.Spells.find(spell => spell.id.toLowerCase() === spell_name.toLowerCase()) ||
globals.Spells.find(spell => spell.name.toLowerCase() === spell_name.toLowerCase());
if (!spell_entry) {
console.log(`getSpell did not find entry for ${spell_name}`);
return;
}
let Level = 0; // This is the minimum attributes value.
let Spell = Character.spells.find(spell => spell.id === spell_entry.id) || {};
if (Spell) {
Level = Spell.level || 0;
}
let Name = globals.Spells.find(spell => spell.id === spell_entry.id).name;
let ModifiedBy = globals.Spells.find(spell => spell.id === spell_entry.id).modified_by;
let Attributes = getAttributeLevels(spell_entry.attributes, Character);
return {
Name: Name,
Level: Level,
Attributes: Attributes,
ModifiedBy: ModifiedBy,
};
};
module.exports = { getSpell };