From 789658cfe716a76ca60a7c5b1b482a70c9078b2e Mon Sep 17 00:00:00 2001 From: Jacob Date: Wed, 19 Jul 2017 12:31:50 +0100 Subject: [PATCH] Spells imported from SRD now have attack bonus set by default --- .../client/views/character/spells/spells.js | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/rpg-docs/client/views/character/spells/spells.js b/rpg-docs/client/views/character/spells/spells.js index 301d5fee..f943c276 100644 --- a/rpg-docs/client/views/character/spells/spells.js +++ b/rpg-docs/client/views/character/spells/spells.js @@ -275,6 +275,7 @@ Template.spells.events({ Spells.insert(spell); // Copy over attacks and effects _.each(result.attacks, (attack) => { + if (!(attackBonus in attack)) {attack.attackBonus = "attackBonus"} //if no attack bonus provided, use spell list's attack.charId = charId; attack.parent = {id: spellId, collection: "Spells"}; Attacks.insert(attack); @@ -284,6 +285,31 @@ Template.spells.events({ effect.parent = {id: spellId, collection: "Spells"}; Effects.insert(effect); }); + + /******[UNCOMMENT ONCE BUFFS ARE ADDED]******* + _.each(result.buffs, (buff) => { + buff.charId = charId; + buff.parent = {id: spellId, collection: "Spells"}; + buffId = Buffs.insert(buff); + + _.each(buff.attacks, (attack) => { + if (!(attackBonus in attack)) {attack.attackBonus = "attackBonus"} //if no attack bonus provided, use spell list's + attack.charId = charId; + attack.parent = {id: buffId, collection: "Buffs"}; + Attacks.insert(attack); + }); + _.each(buff.effects, (effect) => { + effect.charId = charId; + effect.parent = {id: buffId, collection: "Buffs"}; + Effects.insert(effect); + }); + _.each(buff.proficiencies, (prof) => { + prof.charId = charId; + prof.parent = {id: buffId, collection: "Buffs"}; + Proficiencies.insert(prof); + }); + }); + *******[UNCOMMENT ONCE BUFFS ARE ADDED]******/ }, returnElement: () => $(`[data-id='${spellId}']`).get(0), })