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

@@ -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;
},
});