diff --git a/rpg-docs/Model/Character/Characters.js b/rpg-docs/Model/Character/Characters.js index 7358cf6b..ffe65ae9 100644 --- a/rpg-docs/Model/Character/Characters.js +++ b/rpg-docs/Model/Character/Characters.js @@ -433,8 +433,8 @@ Characters.helpers({ var mod = +getMod(this.attributeValue(attribute)); return 10 + mod; }, - - level: function(){ + + xpLevel: function(){ var xp = this.experience(); var xpTable = [0, 300, 900, 2700, 6500, 14000, 23000, 34000, 48000, 64000, 85000, 100000, 120000, 140000, 165000, 195000, 225000, 265000, @@ -447,6 +447,14 @@ Characters.helpers({ if(xp > 355000) return 20; return 0; }, + + level: function(){ + var level = 0; + Classes.find({charId: this._id}).forEach(function(cls){ + level += cls.level; + }) + return level; + }, experience: function(){ var xp = 0; diff --git a/rpg-docs/Model/Character/Levels/Classes.js b/rpg-docs/Model/Character/Classes.js similarity index 78% rename from rpg-docs/Model/Character/Levels/Classes.js rename to rpg-docs/Model/Character/Classes.js index c06c9aae..e7b3e37c 100644 --- a/rpg-docs/Model/Character/Levels/Classes.js +++ b/rpg-docs/Model/Character/Classes.js @@ -3,6 +3,7 @@ Classes = new Meteor.Collection("classes"); Schemas.Class = new SimpleSchema({ charId: {type: String, regEx: SimpleSchema.RegEx.Id}, name: {type: String, trim: false}, + level: {type: Number}, createdAt: { type: Date, autoValue: function() { @@ -15,6 +16,7 @@ Schemas.Class = new SimpleSchema({ } } }, + color: {type: String, allowedValues: _.pluck(colorOptions, "key"), defaultValue: "q"} }); Classes.attachSchema(Schemas.Class); diff --git a/rpg-docs/Model/Character/Effects.js b/rpg-docs/Model/Character/Effects.js index 00a08798..160bd963 100644 --- a/rpg-docs/Model/Character/Effects.js +++ b/rpg-docs/Model/Character/Effects.js @@ -33,7 +33,7 @@ Schemas.Effect = new SimpleSchema({ type: { type: String, defaultValue: "editable", - allowedValues: ["editable", "feature", "level", "buff", "equipment", "racial", "inate"] + allowedValues: ["editable", "feature", "class", "buff", "equipment", "racial", "inate"] }, //the id of the feature, buff or item that created this effect sourceId: { diff --git a/rpg-docs/Model/Character/Levels/Levels.js b/rpg-docs/Model/Character/Levels/Levels.js deleted file mode 100644 index 22d2f75d..00000000 --- a/rpg-docs/Model/Character/Levels/Levels.js +++ /dev/null @@ -1,9 +0,0 @@ -Levels = new Meteor.Collection("levels"); - -Schemas.Level = new SimpleSchema({ - charId: {type: String, regEx: SimpleSchema.RegEx.Id}, - classId: {type: String, regEx: SimpleSchema.RegEx.Id}, - value: {type: Number} -}); - -Levels.attachSchema(Schemas.Level); diff --git a/rpg-docs/client/views/character/features/features.html b/rpg-docs/client/views/character/features/features.html index 8e3abaed..b62aabfd 100644 --- a/rpg-docs/client/views/character/features/features.html +++ b/rpg-docs/client/views/character/features/features.html @@ -45,7 +45,7 @@
diff --git a/rpg-docs/client/views/character/journal/classDialog/classDialog.html b/rpg-docs/client/views/character/journal/classDialog/classDialog.html new file mode 100644 index 00000000..ee2b6d68 --- /dev/null +++ b/rpg-docs/client/views/character/journal/classDialog/classDialog.html @@ -0,0 +1,12 @@ + \ No newline at end of file diff --git a/rpg-docs/client/views/character/journal/classDialog/classDialog.js b/rpg-docs/client/views/character/journal/classDialog/classDialog.js new file mode 100644 index 00000000..0a43b849 --- /dev/null +++ b/rpg-docs/client/views/character/journal/classDialog/classDialog.js @@ -0,0 +1,20 @@ +Template.classDialog.events({ + "tap #deleteButton": function(event, instance){ + Classes.remove(instance.data.classId); + GlobalUI.closeDetail() + }, + "change #classNameInput": function(event){ + var value = event.currentTarget.value; + Classes.update(this._id, {$set: {name: value}}); + }, + "change #levelValueInput": function(event){ + var value = event.currentTarget.value; + Classes.update(this._id, {$set: {level: value}}); + } +}); + +Template.classDialog.helpers({ + class: function(){ + return Classes.findOne(this.classId); + } +}); \ No newline at end of file diff --git a/rpg-docs/client/views/character/journal/journal.html b/rpg-docs/client/views/character/journal/journal.html index 51995a3a..bcb98405 100644 --- a/rpg-docs/client/views/character/journal/journal.html +++ b/rpg-docs/client/views/character/journal/journal.html @@ -2,10 +2,12 @@
+ -
+
Experience
{{experience}} XP
+
{{#each experiences}} @@ -23,35 +25,35 @@
{{/if}} + -
+
-
Levels
+
Level {{level}}
+ {{#if nextLevelXP}} +
+ Next Level: {{nextLevelXP}}XP +
+ {{/if}}
+
-
- Race -
{{race}}
{{#each classes}} -
- {{name}} +
+ + {{name}} {{level}} +
- {{#each levels ../_id}} -
- - Level {{value}} - -
- {{/each}} {{/each}}
+ {{#each notes}}
@@ -66,8 +68,11 @@
- - - - + \ No newline at end of file diff --git a/rpg-docs/client/views/character/journal/journal.js b/rpg-docs/client/views/character/journal/journal.js index 49b1844c..85499986 100644 --- a/rpg-docs/client/views/character/journal/journal.js +++ b/rpg-docs/client/views/character/journal/journal.js @@ -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)); diff --git a/rpg-docs/client/views/character/journal/levelDialog/levelDialog.html b/rpg-docs/client/views/character/journal/levelDialog/levelDialog.html deleted file mode 100644 index ddb6280f..00000000 --- a/rpg-docs/client/views/character/journal/levelDialog/levelDialog.html +++ /dev/null @@ -1,10 +0,0 @@ - \ No newline at end of file diff --git a/rpg-docs/client/views/character/journal/levelDialog/levelDialog.js b/rpg-docs/client/views/character/journal/levelDialog/levelDialog.js deleted file mode 100644 index c24fdc62..00000000 --- a/rpg-docs/client/views/character/journal/levelDialog/levelDialog.js +++ /dev/null @@ -1,16 +0,0 @@ -Template.levelDialog.events({ - "tap #deleteButton": function(event, instance){ - Levels.remove(instance.data.levelId); - GlobalUI.closeDetail() - }, - "change #levelValueInput": function(event){ - var value = event.currentTarget.value; - Levels.update(this._id, {$set: {value: value}}); - } -}); - -Template.levelDialog.helpers({ - level: function(){ - return Levels.findOne(this.levelId); - } -}); \ No newline at end of file diff --git a/rpg-docs/lib/constants/xpTable.js b/rpg-docs/lib/constants/xpTable.js new file mode 100644 index 00000000..adaca2f1 --- /dev/null +++ b/rpg-docs/lib/constants/xpTable.js @@ -0,0 +1,3 @@ +xpTable = [0, 300, 900, 2700, 6500, 14000, 23000, 34000, 48000, 64000, + 85000, 100000, 120000, 140000, 165000, 195000, 225000, 265000, + 305000, 355000]; diff --git a/rpg-docs/lib/functions/evaluate.js b/rpg-docs/lib/functions/evaluate.js index e936345d..26b39b1c 100644 --- a/rpg-docs/lib/functions/evaluate.js +++ b/rpg-docs/lib/functions/evaluate.js @@ -2,18 +2,26 @@ evaluate = function(charId, string){ if(!string) return string; var char = Characters.findOne(charId, {fields: {_id: 1}}); - string = string.replace(/\b[a-zA-Z]+\b/g, function(sub){ + string = string.replace(/\b[a-z]+\b/gi, function(sub){ //fields if(Schemas.Character.schema(sub)){ return char.fieldValue(sub) } //ability modifiers - var abilityMods = ["strengthMod", "dexterityMod", "constitutionMod", "intelligenceMod", "wisdomMod", "charismaMod"] - if( _.contains(abilityMods, sub) ){ + var abilityMods = ["STRENGTHMOD", "DEXTERITYMOD", "CONSTITUTIONMOD", "INTELLIGENCEMOD", "WISDOMMOD", "CHARISMAMOD"] + if( _.contains(abilityMods, sub.toUpperCase()) ){ var slice = sub.slice(0, - 3); return char.abilityMod(slice); } - if(sub === "level"){ + //class levels + if(/\w+levels?\b/gi.test(sub)){ + //strip out "level" + var className = sub.replace(/levels?\b/gi, ""); + var cls = Classes.findOne({charId: charId, name: className}); + return cls && cls.level; + } + //character level + if(sub.toUpperCase() === "LEVEL"){ return char.level(); } return sub; diff --git a/rpg-docs/server/publications/singleCharacter.js b/rpg-docs/server/publications/singleCharacter.js index 85969e89..4a94538d 100644 --- a/rpg-docs/server/publications/singleCharacter.js +++ b/rpg-docs/server/publications/singleCharacter.js @@ -11,7 +11,6 @@ Meteor.publish("singleCharacter", function(characterId, userId){ Experiences.find({charId: characterId}), Features.find({charId: characterId}), Items.find({charId: characterId}), - Levels.find({charId: characterId}), Notes.find({charId: characterId}), Spells.find({charId: characterId}), SpellLists.find({charId: characterId}),