Changed how levels are handled

This commit is contained in:
Thaum
2015-03-02 19:38:53 +00:00
parent 80d44ff310
commit 88dbaccfc5
14 changed files with 110 additions and 66 deletions

View File

@@ -26,6 +26,12 @@ Template.journal.helpers({
levels: function(charId){
return Levels.find({charId: charId, classId: this._id}, {sort: {value: 1}});
},
nextLevelXP: function(){
var currentLevel = this.level();
if (currentLevel < 20){
return xpTable[currentLevel];
}
},
race: function(){
var char = Characters.findOne(this._id, {fields: {race: 1}});
return char && char.race;
@@ -47,10 +53,10 @@ Template.journal.events({
heroId: this._id
});
},
"tap .level": function(event){
"tap .class": function(event){
GlobalUI.setDetail({
template: "levelDialog",
data: {levelId: this._id, charId: this.charId},
template: "classDialog",
data: {classId: this._id, charId: this.charId},
heroId: this._id
});
},
@@ -90,6 +96,22 @@ Template.journal.events({
}
})
},
"tap #addClassButton":function(event){
var charId = this._id;
Classes.insert({
charId: charId,
name: "new Class",
level: 1
}, function(error, id){
if(!error){
GlobalUI.setDetail({
template: "classDialog",
data: {classId: id, charId: charId},
heroId: id
});
}
})
},
"tap #moreExperiences": function(event){
var inst = Template.instance();
inst.experiencesLimit.set(inst.experiencesLimit.get() + (this.settings && this.settings.experiencesInc || 10));