Spell attack bonus and DC are now available in spell attacks.

This commit is contained in:
Jacob
2017-07-19 12:13:49 +01:00
parent 24cc4fd2b1
commit 0e53f157d2
6 changed files with 107 additions and 37 deletions

View File

@@ -82,13 +82,6 @@ Template.features.events({
element: event.currentTarget.parentElement,
});
},
"click .attack": function(event){
openParentDialog({
parent: this.parent,
charId: this.charId,
element: event.currentTarget,
});
},
"click .useFeature": function(event){
var featureId = this._id;
Features.update(featureId, {$inc: {used: 1}});
@@ -154,3 +147,42 @@ Template.resource.events({
});
},
});
Template.attackListItem.helpers({
evaluateAttackBonus: function(charId, attack) {
if (attack.parent.collection == "Spells") {
var spell = Spells.findOne(attack.parent.id);
if (spell) {
bonus = evaluate(charId, attack.attackBonus, {"spellListId": spell.parent.id});
}
} else {
var bonus = evaluate(charId, attack.attackBonus);
}
if (_.isFinite(bonus)) {
return bonus > 0 ? "+" + bonus : "" + bonus;
} else {
return bonus;
}
},
evaluateDamage: function(charId, attack) {
if (attack.parent.collection == "Spells") {
var spell = Spells.findOne(attack.parent.id);
if (spell) {
return evaluateSpellString(charId, spell.parent.id, attack.damage);
}
} else {
return evaluateString(charId, attack.damage);
}
},
});
Template.attackListItem.events({
"click .attack": function(event, instance){
openParentDialog({
parent: instance.data.attack.parent,
charId: instance.data.charId,
element: event.currentTarget,
});
},
});