switched nedb to nedb-promises (#37)

* breaking change: switched to nedb-promises
* Linting
* some dev dependencies
* more tests
* updated package version
* bug fixing
* changed isNaN to isString
* (fix) args[0]
This commit is contained in:
2021-05-03 18:39:33 +02:00
committed by GitHub
parent dc746276ab
commit c6cacdae5e
41 changed files with 16168 additions and 13670 deletions

View File

@ -1,28 +1,24 @@
const { getAttributeLevels } = require('@dsabot/getAttributeLevels');
const Chants = require('@Lib/Chants.json');
const getChant = ({ Character: Character = [], chant_name: chant_name = '' } = {}) => {
const getChant = ({ Character: Character = [], chant_name: chantName = '' } = {}) => {
//if (!Character.hasOwnProperty('chants')) return;
let chant_entry =
Chants.find(chant => chant.id.toLowerCase() === chant_name.toLowerCase()) ||
Chants.find(chant => chant.name.toLowerCase() === chant_name.toLowerCase());
const chantEntry =
Chants.find(chant => chant.id.toLowerCase() === chantName.toLowerCase()) ||
Chants.find(chant => chant.name.toLowerCase() === chantName.toLowerCase());
if (!chant_entry) {
console.log(`getChant() Did not find entry for ${chant_name}`);
return;
if (!chantEntry) {
console.log(`getChant() Did not find entry for ${chantName}`);
return null;
}
let Level = 0; // This is the minimum attributes value.
let Chant = Character.chants.find(chant => chant.id === chant_entry.id) || {};
const Chant = Character.chants.find(chant => chant.id === chantEntry.id) || null;
if (Chant && Chant.hasOwnProperty('level')) {
Level = Chant.level || 0;
}
let Attributes = getAttributeLevels(chant_entry.attributes, Character);
const Attributes = getAttributeLevels(chantEntry.attributes, Character);
return {
Name: chant_entry.name,
Level: Level,
Attributes: Attributes,
};
return { Name: chantEntry.name, Level: Level, Attributes: Attributes };
};
module.exports = { getChant };