added _some_ chants, restructuring data from spells

This commit is contained in:
2021-04-26 07:54:58 +02:00
parent e65715cce6
commit cee6fee5a3
11 changed files with 1854 additions and 555 deletions

View File

@ -1,10 +1,27 @@
const globals = require('../globals');
const { getAttributeLevels } = require('@dsabot/getAttributeLevels');
const Spells = require('../data/Spells');
/* definition of attributes in spell database
{
id: 'adlerauge', // the id of the spell inside characters database.
name: 'Adlerauge', // the well-known name of the spell.
attributes: [ 'KL', 'IN', 'FF' ], // needed attribute checks when casting the spell
spellduration: 2, // the player needs this many actions to cast the spell.
modified_by: [], // the spell is modified by this character's attribute
cost: null, // how many units does the spell cost? (when activated)
cost_type: 'asp', // what kind of points does the character need?
// AsP = Astral Points, KaP = Karmal Points
effect: '', // What is the desired effect of this spell?
effectduration: '' // How long does the effect last?
talent: null //
},
*/
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());
const spell_entry =
Spells.find(spell => spell.id.toLowerCase() === spell_name.toLowerCase()) ||
Spells.find(spell => spell.name.toLowerCase() === spell_name.toLowerCase());
if (!spell_entry) {
console.log(`getSpell did not find entry for ${spell_name}`);
@ -12,12 +29,12 @@ const getSpell = ({ Character: Character = [], spell_name: spell_name = '' } = {
}
let Level = 0; // This is the minimum attributes value.
let Spell = Character.spells.find(spell => spell.id === spell_entry.id) || {};
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 Name = spell_entry.name;
let ModifiedBy = spell_entry.modified_by;
let Attributes = getAttributeLevels(spell_entry.attributes, Character);
return {