Add Skillchecks for Magical Talents (#25)
* initial implementation of spells * added return list of spells. Moved them into seperate json * added _some_ chants, restructuring data from spells * added more chants, added command for getting info * added related messages, added skillcheck for spells (cast) * better error handling, added chant command * (fix) Chants were referring to spells * cleanup testing variables and code * updated README * fixed storage location issues and minor bugs * removed db storage location * rc1 * (fix) chants_title * (fix) Uncaught ReferenceError: Discord is not defined * (fix) more reference errors Co-authored-by: Marcus Netz <marcus.netz@godyo.com>
This commit is contained in:
28
functions/getChant.js
Normal file
28
functions/getChant.js
Normal file
@ -0,0 +1,28 @@
|
||||
const { getAttributeLevels } = require('@dsabot/getAttributeLevels');
|
||||
const Chants = require('@Lib/Chants.json');
|
||||
|
||||
const getChant = ({ Character: Character = [], chant_name: chant_name = '' } = {}) => {
|
||||
//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());
|
||||
|
||||
if (!chant_entry) {
|
||||
console.log(`getChant() Did not find entry for ${chant_name}`);
|
||||
return;
|
||||
}
|
||||
|
||||
let Level = 0; // This is the minimum attributes value.
|
||||
let Chant = Character.chants.find(chant => chant.id === chant_entry.id) || {};
|
||||
if (Chant && Chant.hasOwnProperty('level')) {
|
||||
Level = Chant.level || 0;
|
||||
}
|
||||
let Attributes = getAttributeLevels(chant_entry.attributes, Character);
|
||||
|
||||
return {
|
||||
Name: chant_entry.name,
|
||||
Level: Level,
|
||||
Attributes: Attributes,
|
||||
};
|
||||
};
|
||||
module.exports = { getChant };
|
Reference in New Issue
Block a user