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,27 +1,27 @@
const { getAttributeLevels } = require('@dsabot/getAttributeLevels');
const Spells = require('@Lib/Spells.json');
const getSpell = ({ Character: Character = [], spell_name: spell_name = '' } = {}) => {
const spell_entry =
Spells.find(spell => spell.id.toLowerCase() === spell_name.toLowerCase()) ||
Spells.find(spell => spell.name.toLowerCase() === spell_name.toLowerCase());
const getSpell = ({ Character: Character = [], spell_name: spellName = '' } = {}) => {
const spellEntry =
Spells.find(spell => spell.id.toLowerCase() === spellName.toLowerCase()) ||
Spells.find(spell => spell.name.toLowerCase() === spellName.toLowerCase());
if (!spell_entry) {
console.log(`getSpell() did not find entry for ${spell_name}`);
return;
if (!spellEntry) {
console.log(`getSpell() did not find entry for ${spellName}`);
return null;
}
let Level = 0; // This is the minimum attributes value.
if (!Character.hasOwnProperty('spells')) return;
let Spell = Character.spells.find(spell => spell.id === spell_entry.id) || {}; //?+
if (!Character.hasOwnProperty('spells')) return null;
const Spell = Character.spells.find(spell => spell.id === spellEntry.id) || null; //?+
if (Spell && Spell.hasOwnProperty('level')) {
Level = Spell.level || 0;
}
let ModifiedBy = spell_entry.modified_by;
let Attributes = getAttributeLevels(spell_entry.attributes, Character);
const ModifiedBy = spellEntry.modified_by;
const Attributes = getAttributeLevels(spellEntry.attributes, Character);
return {
Name: spell_entry.name,
Name: spellEntry.name,
Level: Level,
Attributes: Attributes,
ModifiedBy: ModifiedBy,