Effect view fixed for conditional benefits

This commit is contained in:
Thaum
2015-04-17 10:00:06 +00:00
parent e7f0bb5e05
commit 0536a6ab01

View File

@@ -71,7 +71,7 @@ var stats = {
}; };
var operations = { var operations = {
base: {name: "Base Value"}, base: {name: "Base Value: "},
proficiency: {name: "Proficiency"}, proficiency: {name: "Proficiency"},
add: {name: "+"}, add: {name: "+"},
mul: {name: "x"}, mul: {name: "x"},
@@ -81,7 +81,6 @@ var operations = {
disadvantage: {name: "Disadvantage"}, disadvantage: {name: "Disadvantage"},
passiveAdd: {name: "Passive Bonus: "}, passiveAdd: {name: "Passive Bonus: "},
fail: {name: "Automatically Fail"}, fail: {name: "Automatically Fail"},
conditional: {name: "Conditional Benefit"}
}; };
Template.effectView.helpers({ Template.effectView.helpers({
@@ -107,7 +106,8 @@ Template.effectView.helpers({
return stats[this.stat] && stats[this.stat].name || "No Stat"; return stats[this.stat] && stats[this.stat].name || "No Stat";
}, },
operationName: function(){ operationName: function(){
if(this.operation === "proficiency") return null; if(this.operation === "proficiency" ||
this.operation === "conditional") return null;
if(stats[this.stat].group === "Weakness/Resistance") return null; if(stats[this.stat].group === "Weakness/Resistance") return null;
if(this.operation === "add" && evaluateEffect(this.charId, this) < 0) return null; if(this.operation === "add" && evaluateEffect(this.charId, this) < 0) return null;
return operations[this.operation] && operations[this.operation].name || "No Operation"; return operations[this.operation] && operations[this.operation].name || "No Operation";
@@ -115,8 +115,7 @@ Template.effectView.helpers({
statValue: function(){ statValue: function(){
if(this.operation === "advantage" || if(this.operation === "advantage" ||
this.operation === "disadvantage" || this.operation === "disadvantage" ||
this.operation === "fail" || this.operation === "fail"){
this.operation === "conditional"){
return null; return null;
} }
if(this.operation === "proficiency"){ if(this.operation === "proficiency"){
@@ -124,11 +123,16 @@ Template.effectView.helpers({
if(this.value == 1 || this.calculation == 1) return "Proficiency"; if(this.value == 1 || this.calculation == 1) return "Proficiency";
if(this.value == 2 || this.calculation == 2) return "Double Proficiency"; if(this.value == 2 || this.calculation == 2) return "Double Proficiency";
} }
if(this.operation === "conditional"){
return this.calculation || this.value;
}
if(stats[this.stat].group === "Weakness/Resistance"){ if(stats[this.stat].group === "Weakness/Resistance"){
if(this.value == 0.5 || this.calculation == 0.5) return "Resistance"; if(this.value == 0.5 || this.calculation == 0.5) return "Resistance";
if(this.value == 2 || this.calculation == 2) return "Vulnerability"; if(this.value == 2 || this.calculation == 2) return "Vulnerability";
if(this.value == 0 || this.calculation == 0) return "Immunity"; if(this.value == 0 || this.calculation == 0) return "Immunity";
} }
return evaluateEffect(this.charId, this); var value = evaluateEffect(this.charId, this);
if(_.isNumber(value)) return value;
return this.calculation || this.value;
} }
}); });