Made passive scores show up for all skills with bonuses to passive score

closes #56
This commit is contained in:
Stefan Zermatten
2017-07-13 13:42:04 +02:00
parent 3227cd0934
commit 6a84c83644
5 changed files with 61 additions and 20 deletions

View File

@@ -61,6 +61,18 @@
<td>Total</td>
<td>{{characterCalculate "skillMod" charId skillName}}</td>
</tr>
{{#each passiveEffects}}
<tr>
<td>{{sourceName}}</td>
<td>Passive Bonus: {{statValue}}</td>
</tr>
{{/each}}
{{#if showPassiveTotal}}
<tr class="paper-font-body2">
<td>Passive Score</td>
<td>{{characterCalculate "passiveSkill" charId skillName}}</td>
</tr>
{{/if}}
</table>
</div>

View File

@@ -122,7 +122,7 @@ Template.skillDialogView.helpers({
var char = Characters.findOne(this.charId);
if (!char) return;
var prof = Characters.calculate.proficiency(this.charId, this.skillName);
var proficiencyBonus =
var proficiencyBonus =
Characters.calculate.attributeValue(this.charId, "proficiencyBonus");
return prof * proficiencyBonus;
},
@@ -189,6 +189,23 @@ Template.skillDialogView.helpers({
enabled: true,
});
},
passiveEffects: function(){
return Effects.find({
charId: this.charId,
stat: this.skillName,
operation: "passiveAdd",
enabled: true,
});
},
showPassiveTotal: function(){
if (this.skillName === "perception") return true;
return Effects.find({
charId: this.charId,
stat: this.skillName,
operation: "passiveAdd",
enabled: true,
}).count();
},
ability: function(){
var opts = {fields: {}};
opts.fields[this.skillName] = 1;

View File

@@ -14,7 +14,7 @@
{{#if conditionalCount}}
*
{{/if}}
{{#if showPassive}}
{{#if isPassiveShown}}
({{characterCalculate "passiveSkill" ../_id skill}})
{{/if}}
</div>

View File

@@ -38,4 +38,16 @@ Template.skillRow.helpers({
operation: "conditional",
}).count();
},
isPassiveShown: function(){
if (this.showPassive === "forced") return true;
if (this.showPassive === "ifNeeded"){
var charId = Template.parentData()._id;
return Effects.find({
charId,
stat: this.skill,
operation: "passiveAdd",
enabled: true,
}).count();
}
},
});

View File

@@ -49,24 +49,24 @@
Skills
</div>
<div flex class="bottom list">
{{> skillRow name="Acrobatics" skill="acrobatics"}}
{{> skillRow name="Animal Handling" skill="animalHandling"}}
{{> skillRow name="Arcana" skill="arcana"}}
{{> skillRow name="Athletics" skill="athletics"}}
{{> skillRow name="Deception" skill="deception"}}
{{> skillRow name="History" skill="history"}}
{{> skillRow name="Insight" skill="insight"}}
{{> skillRow name="Intimidation" skill="intimidation"}}
{{> skillRow name="Investigation" skill="investigation"}}
{{> skillRow name="Medicine" skill="medicine"}}
{{> skillRow name="Nature" skill="nature"}}
{{> skillRow name="Perception" skill="perception" showPassive="true"}}
{{> skillRow name="Performance" skill="performance"}}
{{> skillRow name="Persuasion" skill="persuasion"}}
{{> skillRow name="Religion" skill="religion"}}
{{> skillRow name="Sleight of Hand" skill="sleightOfHand"}}
{{> skillRow name="Stealth" skill="stealth"}}
{{> skillRow name="Survival" skill="survival"}}
{{> skillRow name="Acrobatics" skill="acrobatics" showPassive="ifNeeded"}}
{{> skillRow name="Animal Handling" skill="animalHandling" showPassive="ifNeeded"}}
{{> skillRow name="Arcana" skill="arcana" showPassive="ifNeeded"}}
{{> skillRow name="Athletics" skill="athletics" showPassive="ifNeeded"}}
{{> skillRow name="Deception" skill="deception" showPassive="ifNeeded"}}
{{> skillRow name="History" skill="history" showPassive="ifNeeded"}}
{{> skillRow name="Insight" skill="insight" showPassive="ifNeeded"}}
{{> skillRow name="Intimidation" skill="intimidation" showPassive="ifNeeded"}}
{{> skillRow name="Investigation" skill="investigation" showPassive="ifNeeded"}}
{{> skillRow name="Medicine" skill="medicine" showPassive="ifNeeded"}}
{{> skillRow name="Nature" skill="nature" showPassive="ifNeeded"}}
{{> skillRow name="Perception" skill="perception" showPassive="forced"}}
{{> skillRow name="Performance" skill="performance" showPassive="ifNeeded"}}
{{> skillRow name="Persuasion" skill="persuasion" showPassive="ifNeeded"}}
{{> skillRow name="Religion" skill="religion" showPassive="ifNeeded"}}
{{> skillRow name="Sleight of Hand" skill="sleightOfHand" showPassive="ifNeeded"}}
{{> skillRow name="Stealth" skill="stealth" showPassive="ifNeeded"}}
{{> skillRow name="Survival" skill="survival" showPassive="ifNeeded"}}
</div>
</paper-material>
</div>