Implemented skill and attribute summary dialogs

This commit is contained in:
Thaum
2015-04-21 11:30:34 +00:00
parent b1e23eba9a
commit 6926693e9d
9 changed files with 349 additions and 109 deletions

View File

@@ -1,81 +1,101 @@
<!-- needs name, char, and skillName -->
<template name="skillDialog">
{{#baseDialog title=name class=colorClass hideColor="true" hideDelete="true"}}
<!--proficiency-->
<div>
<core-icon icon="{{profIcon}}"></core-icon>
{{#if profSource}}
{{#with profSource}}
{{statValue}} - {{sourceName}}
{{/with}}
{{else}}
Not Proficient
{{/if}}
</div>
<!--numerical value-->
<div>
<!--Ability Mod-->
<div horizontal center-justified layout>
<div flex>{{abilityName}}</div>
<div class="summaryNumber">{{char.abilityMod ability}}</div>
{{#baseDialog title=name class=colorClass hideEdit=true}}
{{> skillDialogView}}
{{/baseDialog}}
</template>
<template name="skillDialogView">
<div layout vertical center>
<div class="display2">
{{char.skillMod skillName}}
</div>
<!--Prof bonus-->
<div class="subhead">
<core-icon icon="{{profIcon}}" class="black54"></core-icon>
{{#if profSource}}
{{proficiencyValue}} - {{#with profSource}}{{sourceName}}{{/with}}
{{else}}
Not Proficient
{{/if}}
</div>
</div>
<hr class="vertMargin">
<table class="summaryTable">
<tr>
<td>{{abilityName}}</td>
<td>{{char.abilityMod ability}}</td>
</tr>
{{#if char.proficiency skillName}}
<div horizontal center-justified layout>
<div flex>{{#with profSource}}{{statValue}}{{/with}}</div>
<div class="summaryNumber">{{signedString profBonus}}</div>
</div>
<tr>
<td>{{proficiencyValue}}</td>
<td>{{signedString profBonus}}</td>
</tr>
{{/if}}
<!--numerical effects-->
{{#each addEffects}}
<div horizontal center-justified layout>
<div flex>{{sourceName}}</div>
<div class="summaryNumber">{{signedString statValue}}</div>
</div>
<tr>
<td>{{sourceName}}</td>
<td>{{signedString statValue}}</td>
</tr>
{{/each}}
{{#each mulEffects}}
<div horizontal center-justified layout>
<div flex>{{sourceName}}</div>
<div class="summaryNumber">&times;{{statValue}}</div>
</div>
<tr>
<td>{{sourceName}}</td>
<td>&times;{{statValue}}</td>
</tr>
{{/each}}
{{#each minEffects}}
<div horizontal center-justified layout>
<div flex>{{sourceName}}</div>
<div class="summaryNumber">Min: {{statValue}}</div>
</div>
<tr>
<td>{{sourceName}}</td>
<td>Min: {{statValue}}</td>
</tr>
{{/each}}
{{#each maxEffects}}
<div horizontal center-justified layout>
<div flex>{{sourceName}}</div>
<div class="summaryNumber">Max: {{statValue}}</div>
<tr>
<td>{{sourceName}}</td>
<td>Max: {{statValue}}</td>
</tr>
{{/each}}
<tr class="body2">
<td>Total</td>
<td>{{char.skillMod skillName}}</td>
</tr>
</table>
{{#if or advEffects.count dadvEffects.count conditionalEffects.count}}
<hr class="vertMargin">
{{/if}}
<div class="spaceAfter" horizontal center layout>
{{#if advEffects.count}}
<div class="body2" style="width: 100px;">
Advantage
</div>
{{/each}}
<!--Total-->
<div horizontal center-justified layout>
<div flex>Total</div>
<div class="summaryNumber">{{char.skillMod skillName}}</div>
</div>
<div flex>
{{#each advEffects}}
<div>{{sourceName}}</div>
{{/each}}
</div>
{{/if}}
</div>
<div class="spaceAfter" horizontal center layout>
{{#if dadvEffects.count}}
<div class="body2" style="width: 100px;">
Disadvantage
</div>
<div flex>
{{#each dadvEffects}}
<div>{{sourceName}}</div>
{{/each}}
</div>
{{/if}}
</div>
<!--Advantage effects-->
{{#if advEffects.count}}
Advantage:
{{#each advEffects}}
<div>{{sourceName}}</div>
{{/each}}
{{/if}}
{{#if dadvEffects.count}}
Disadvantage:
{{#each dadvEffects}}
<div>{{sourceName}}</div>
{{/each}}
{{/if}}
<!--Conditional Benefits-->
{{#each conditionalEffects}}
<div>
<div>{{sourceName}}</div>
<div class="spaceAfter">
<div class="body2">{{sourceName}}</div>
<div>*{{statValue}}</div>
</div>
{{/each}}
{{/baseDialog}}
</template>

View File

@@ -33,8 +33,8 @@ var stats = {
"initiative":{"name":"Initiative",},
"hitPoints":{"name":"Hit Points"},
"armor":{"name":"Armor"},
"dexterityArmor":{"name":"Dexterity Armor Bonus"}
,"speed":{"name":"Speed"},
"dexterityArmor":{"name":"Dexterity Armor Bonus"},
"speed":{"name":"Speed"},
"proficiencyBonus":{"name":"Proficiency Bonus"},
"ki":{"name":"Ki Points"},
"sorceryPoints":{"name":"Sorcery Points"},
@@ -90,14 +90,17 @@ var abilities = {
constitution: {name: "Constitution"},
intelligence: {name: "Intelligence"},
wisdom: {name: "Wisdom"},
charisma: {name: "Charisma"},
}
charisma: {name: "Charisma"},
};
Template.skillDialog.created = function(){
Template.skillDialogView.created = function(){
this.data.char = Characters.findOne(this.data.charId, {fields: {_id : 1}});
};
Template.skillDialog.helpers({
Template.skillDialogView.helpers({
or: function(a, b, c){
return a || b || c;
},
profIcon: function(){
var prof = this.char.proficiency(this.skillName);
if(prof > 0 && prof < 1) return "image:brightness-2";
@@ -106,12 +109,18 @@ Template.skillDialog.helpers({
return "radio-button-off";
},
profSource: function(){
var effs = Effects.find({charId: this.char._id, stat: this.skillName, operation: "proficiency"}, {sort: {value: -1}}).fetch();
return effs && effs[0];
return Proficiencies.findOne({charId: this.char._id, name: this.skillName}, {sort: {value: -1}});
},
profBonus: function(){
return this.char.proficiency(this.skillName) * this.char.attributeValue("proficiencyBonus");
},
proficiencyValue: function(){
var prof = this.char.proficiency(this.skillName);
if(prof == 0.5) return "Half Proficiency";
if(prof == 1) return "Proficient";
if(prof == 2) return "Double Proficiency";
return prof + "x Proficiency";
},
addEffects: function(){
return Effects.find({charId: this.char._id, stat: this.skillName, operation: "add"});
},
@@ -153,30 +162,28 @@ Template.skillDialog.helpers({
},
sourceName: function(){
if (this.parent.collection === "Characters") return "inate";
var parent = this.getParent();
return parent && parent.name;
return this.getParent().name;
},
operationName: function(){
if(this.operation === "proficiency") return null;
if(stats[this.stat].group === "Weakness/Resistance") return null;
return operations[this.operation] && operations[this.operation].name || "No Operation";
return operations[this.operation] &&
operations[this.operation].name ||
"No Operation";
},
statValue: function(){
if(this.operation === "advantage" ||
this.operation === "disadvantage" ||
this.operation === "fail"){
if(
this.operation === "advantage" ||
this.operation === "disadvantage" ||
this.operation === "fail"
){
return null;
}
if(this.operation === "proficiency"){
if(this.value == 0.5 || this.calculation == 0.5) return "Half Proficiency";
if(this.value == 1 || this.calculation == 1) return "Proficiency";
if(this.value == 2 || this.calculation == 2) return "Double Proficiency";
}
if(stats[this.stat].group === "Weakness/Resistance"){
if(this.value == 0.5 || this.calculation == 0.5) return "Resistance";
if(this.value == 2 || this.calculation == 2) return "Vulnerability";
if(this.value == 0 || this.calculation == 0) return "Immunity";
if(this.value === 0.5) return "Resistance";
if(this.value === 2) return "Vulnerability";
if(this.value === 0) return "Immunity";
return " Damage x"+ this.value;
}
return this.calculation || this.value;
}
return evaluate(this.charId, this.calculation) || this.value;
},
});