38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
Template.hitDice.helpers({
|
|
cantIncrement: function(){
|
|
var valueSmallerThanBase = this.char.attributeValue(this.name) <
|
|
this.char.attributeBase(this.name);
|
|
return !valueSmallerThanBase;
|
|
},
|
|
cantDecrement: function(){
|
|
var valuePositive = this.char.attributeValue(this.name) > 0;
|
|
return !valuePositive;
|
|
},
|
|
});
|
|
|
|
Template.hitDice.events({
|
|
"tap .resourceUp": function(event){
|
|
if (this.char.attributeValue(this.name) < this.char.attributeBase(this.name)){
|
|
var modifier = {$inc: {}};
|
|
modifier.$inc[this.name + ".adjustment"] = 1;
|
|
Characters.update(this.char._id, modifier, {validate: false});
|
|
}
|
|
},
|
|
"tap .resourceDown": function(event){
|
|
if (this.char.attributeValue(this.name) > 0){
|
|
var modifier = {$inc: {}};
|
|
modifier.$inc[this.name + ".adjustment"] = -1;
|
|
Characters.update(this.char._id, modifier, {validate: false});
|
|
}
|
|
},
|
|
"tap .containerRight": function() {
|
|
var charId = Template.parentData()._id;
|
|
var title = "d" + this.diceNum + " Hit Dice";
|
|
GlobalUI.setDetail({
|
|
template: "attributeDialog",
|
|
data: {name: title, statName: this.name, charId: charId},
|
|
heroId: charId + this.name,
|
|
});
|
|
},
|
|
});
|