Fixed attacks not being added to spells added with multi-add

Fixes #145
This commit is contained in:
Stefan Zermatten
2017-11-01 15:55:07 +02:00
parent 1d2de197a4
commit face6387a0

View File

@@ -279,23 +279,23 @@ Template.spells.events({
collection: "SpellLists", collection: "SpellLists",
}; };
spell.prepared = "prepared"; spell.prepared = "prepared";
Spells.insert(spell); let insertedSpellId = Spells.insert(spell);
// Copy over attacks and effects // Copy over attacks and effects
_.each(rawSpell.attacks, (attack) => { _.each(rawSpell.attacks, (attack) => {
if (!("attackBonus" in attack)) {attack.attackBonus = "attackBonus"} //if no attack bonus provided, use spell list's if (!("attackBonus" in attack)) {attack.attackBonus = "attackBonus"} //if no attack bonus provided, use spell list's
attack.charId = charId; attack.charId = charId;
attack.parent = {id: spellId, collection: "Spells"}; attack.parent = {id: insertedSpellId, collection: "Spells"};
Attacks.insert(attack); Attacks.insert(attack);
}); });
_.each(rawSpell.effects, (effect) => { _.each(rawSpell.effects, (effect) => {
effect.charId = charId; effect.charId = charId;
effect.parent = {id: spellId, collection: "Spells"}; effect.parent = {id: insertedSpellId, collection: "Spells"};
Effects.insert(effect); Effects.insert(effect);
}); });
_.each(rawSpell.buffs, (buff) => { _.each(rawSpell.buffs, (buff) => {
buff.charId = charId; buff.charId = charId;
buff.parent = {id: spellId, collection: "Spells"}; buff.parent = {id: insertedSpellId, collection: "Spells"};
buffId = Buffs.insert(buff); buffId = Buffs.insert(buff);
_.each(buff.attacks, (attack) => { _.each(buff.attacks, (attack) => {