diff --git a/rpg-docs/Model/Character/Characters.js b/rpg-docs/Model/Character/Characters.js index 21a28350..c95532cc 100644 --- a/rpg-docs/Model/Character/Characters.js +++ b/rpg-docs/Model/Character/Characters.js @@ -13,7 +13,6 @@ Schemas.Character = new SimpleSchema({ bonds: { type: String, defaultValue: "", trim: false}, flaws: { type: String, defaultValue: "", trim: false}, backstory: { type: String, defaultValue: "", trim: false}, - languages: { type: String, defaultValue: "", trim: false}, //attributes //ability scores @@ -269,7 +268,7 @@ Characters.helpers({ var ability = this.attributeValue(skill.ability); //base modifier - var mod = +getMod(ability) + var mod = +getMod(ability); //multiply proficiency bonus by largest value in proficiency array var prof = this.proficiency(skillName); diff --git a/rpg-docs/client/globalHelpers/colorClass.js b/rpg-docs/client/globalHelpers/colorClass.js index 1dcb4765..2588e2ea 100644 --- a/rpg-docs/client/globalHelpers/colorClass.js +++ b/rpg-docs/client/globalHelpers/colorClass.js @@ -1,5 +1,6 @@ Template.registerHelper("colorClass", function(color){ - return color? getColorClass(color) : getColorClass(this.color); + if(color) return getColorClass(color); + else if(this.color) return getColorClass(this.color); }); Template.registerHelper("hexColor", function(color){ diff --git a/rpg-docs/client/views/character/effects/effectsEditList/effectsEditList.js b/rpg-docs/client/views/character/effects/effectsEditList/effectsEditList.js index 1d7a5efa..2f63462d 100644 --- a/rpg-docs/client/views/character/effects/effectsEditList/effectsEditList.js +++ b/rpg-docs/client/views/character/effects/effectsEditList/effectsEditList.js @@ -1,6 +1,14 @@ Template.effectsEditList.helpers({ effects: function(){ - var cursor = Effects.find({"parent.id": this.parentId, "parent.collection": this.parentCollection}); + var selector = { + "parent.id": this.parentId, + "parent.collection": this.parentCollection, + "charId": this.charId + }; + if(this.parentGroup){ + selector["parent.group"] = this.parentGroup; + } + var cursor = Effects.find(selector); return cursor; } }); diff --git a/rpg-docs/client/views/character/effects/effectsViewList/effectsViewList.js b/rpg-docs/client/views/character/effects/effectsViewList/effectsViewList.js index 343944f3..f75f055e 100644 --- a/rpg-docs/client/views/character/effects/effectsViewList/effectsViewList.js +++ b/rpg-docs/client/views/character/effects/effectsViewList/effectsViewList.js @@ -1,5 +1,12 @@ Template.effectsViewList.helpers({ effects: function(){ - return Effects.find({"parent.id": this.parentId, charId: this.charId}, {fields: {parent: 0}}); + var selector = { + "parent.id": this.parentId, + "charId": this.charId + }; + if(this.parentGroup){ + selector["parent.group"] = this.parentGroup; + } + return Effects.find(selector, {fields: {parent: 0}}); } }); diff --git a/rpg-docs/client/views/character/features/features.html b/rpg-docs/client/views/character/features/features.html index 3427acee..cde38383 100644 --- a/rpg-docs/client/views/character/features/features.html +++ b/rpg-docs/client/views/character/features/features.html @@ -48,19 +48,36 @@ {{/each}} - + -
+
Proficiencies
-
{{characterProficiencies}}
+
+ {{#if weaponProfs.count}} +
Weapons
+ {{/if}} + {{#each weaponProfs}} + {{> proficiencyListItem}} + {{/each}} + {{#if armorProfs.count}} +
Armor
+ {{/if}} + {{#each armorProfs}} + {{> proficiencyListItem}} + {{/each}} + {{#if toolProfs.count}} +
Tools
+ {{/if}} + {{#each toolProfs}} + {{> proficiencyListItem}} + {{/each}} +
- + {{#each features}} diff --git a/rpg-docs/client/views/character/features/features.js b/rpg-docs/client/views/character/features/features.js index 15f295a4..3dc8f907 100644 --- a/rpg-docs/client/views/character/features/features.js +++ b/rpg-docs/client/views/character/features/features.js @@ -13,7 +13,7 @@ Template.features.helpers({ return this.usesLeft() >= this.usesValue(); }, colorClass: function(){ - return getColorClass(this.color) + return getColorClass(this.color); }, featureOrder: function(){ return _.indexOf(_.keys(colorOptions), this.color); @@ -21,13 +21,18 @@ Template.features.helpers({ attacks: function(){ return Attacks.find({charId: this._id, enabled: true}, {sort: {color: 1, name: 1}}); }, - characterProficiencies: function(){ - var char = Characters.findOne(this._id); - return char && char.proficiencies; - }, canEnable: function(){ return !this.alwaysEnabled; - } + }, + weaponProfs: function(){ + return Proficiencies.find({charId: this._id, type: "weapon"}); + }, + armorProfs: function(){ + return Proficiencies.find({charId: this._id, type: "armor"}); + }, + toolProfs: function(){ + return Proficiencies.find({charId: this._id, type: "tool"}); + }, }); Template.features.events({ diff --git a/rpg-docs/client/views/character/journal/classDialog/classDialog.html b/rpg-docs/client/views/character/journal/classDialog/classDialog.html index e83e5dcb..5352781b 100644 --- a/rpg-docs/client/views/character/journal/classDialog/classDialog.html +++ b/rpg-docs/client/views/character/journal/classDialog/classDialog.html @@ -7,7 +7,7 @@ {{> effectsEditList parentId=_id parentCollection="Classes" charId=charId}} - {{> proficiencyEditList parentId=_id parentCollection="Characters" charId=charId}} + {{> proficiencyEditList parentId=_id parentCollection="Classes" charId=charId}} {{/baseDialog}} {{/with}} \ No newline at end of file diff --git a/rpg-docs/client/views/character/journal/raceDialog/raceDialog.html b/rpg-docs/client/views/character/journal/raceDialog/raceDialog.html index 1c2c18c5..c2578049 100644 --- a/rpg-docs/client/views/character/journal/raceDialog/raceDialog.html +++ b/rpg-docs/client/views/character/journal/raceDialog/raceDialog.html @@ -1,7 +1,7 @@ \ No newline at end of file diff --git a/rpg-docs/client/views/character/persona/persona.css b/rpg-docs/client/views/character/persona/persona.css deleted file mode 100644 index 5c51cda2..00000000 --- a/rpg-docs/client/views/character/persona/persona.css +++ /dev/null @@ -1,3 +0,0 @@ -#persona .containerMain{ - white-space: pre-line; -} \ No newline at end of file diff --git a/rpg-docs/client/views/character/persona/persona.html b/rpg-docs/client/views/character/persona/persona.html index 85f69e82..edadc00d 100644 --- a/rpg-docs/client/views/character/persona/persona.html +++ b/rpg-docs/client/views/character/persona/persona.html @@ -11,7 +11,16 @@ {{> containerCard characterField "bonds" "Bonds"}} {{> containerCard characterField "flaws" "Flaws"}} {{> containerCard characterField "backstory" "Background"}} - {{> containerCard characterField "languages" "Languages"}} + +
+
Languages
+
+
+ {{#each languages}} + {{> proficiencyListItem}} + {{/each}} +
+
@@ -23,9 +32,9 @@ \ No newline at end of file diff --git a/rpg-docs/client/views/character/persona/persona.js b/rpg-docs/client/views/character/persona/persona.js index 0e2b41c6..7c8127d9 100644 --- a/rpg-docs/client/views/character/persona/persona.js +++ b/rpg-docs/client/views/character/persona/persona.js @@ -4,13 +4,12 @@ var colorMap = { ideals: "g", bonds: "h", flaws: "i", - backstory: "j", - languages: "k" -} + backstory: "j" +}; Template.persona.helpers({ characterDetails: function(){ - var char = Characters.findOne(this._id, {fields: {name: 1, gender: 1, alignment: 1, race:1}}) + var char = Characters.findOne(this._id, {fields: {name: 1, gender: 1, alignment: 1, race:1}}); char.field = "details"; char.title = char.name; char.color = "d"; @@ -21,12 +20,22 @@ Template.persona.helpers({ fieldSelector.fields[field] = 1; var char = Characters.findOne(this._id, fieldSelector); var color = colorMap[field]; - return {_id: char._id, title: title, field: field, color: color, body: char[field]}; - } + return { + _id: char._id, + title: title, + field: field, + color: color, + body: char[field], + topClass: "characterField" + }; + }, + languages: function(){ + return Proficiencies.find({charId: this._id, type: "language"}); + }, }); Template.persona.events({ - "tap .containerTop": function(event){ + "tap .characterField": function(event){ if(this.field !== "details"){ var charId = Template.parentData()._id; GlobalUI.setDetail({ @@ -41,6 +50,6 @@ Template.persona.events({ data: this, heroId: this._id + "details" }); - } + } } }); \ No newline at end of file diff --git a/rpg-docs/client/views/character/proficiencies/proficiencyEdit/proficiencyEdit.html b/rpg-docs/client/views/character/proficiencies/proficiencyEdit/proficiencyEdit.html index c41e1dfe..69eca3ed 100644 --- a/rpg-docs/client/views/character/proficiencies/proficiencyEdit/proficiencyEdit.html +++ b/rpg-docs/client/views/character/proficiencies/proficiencyEdit/proficiencyEdit.html @@ -19,6 +19,9 @@ + + @@ -34,8 +37,8 @@ - \ No newline at end of file diff --git a/rpg-docs/client/views/character/proficiencies/proficiencyListItem/proficiencyListItem.js b/rpg-docs/client/views/character/proficiencies/proficiencyListItem/proficiencyListItem.js new file mode 100644 index 00000000..0728c378 --- /dev/null +++ b/rpg-docs/client/views/character/proficiencies/proficiencyListItem/proficiencyListItem.js @@ -0,0 +1,14 @@ +Template.proficiencyListItem.helpers({ + profIcon: function(){ + var prof = this.value; + if(prof > 0 && prof < 1) return "image:brightness-2"; + if(prof === 1) return "image:brightness-1"; + if(prof > 1) return "av:album"; + return "radio-button-off"; + }, + getName: function(){ + if(this.type === "skill") return skills[this.name]; + if(this.type === "save") return saves[this.name]; + return this.name; + } +}); diff --git a/rpg-docs/lib/functions/parenting.js b/rpg-docs/lib/functions/parenting.js index fad540d3..356bc6af 100644 --- a/rpg-docs/lib/functions/parenting.js +++ b/rpg-docs/lib/functions/parenting.js @@ -2,6 +2,7 @@ var childSchema = new SimpleSchema({ parent: { type: Object }, 'parent.collection': { type: String }, 'parent.id': { type: String, regEx: SimpleSchema.RegEx.Id }, + 'parent.group': { type: String, optional: true}, 'removedWith': { optional: true, type: String, regEx: SimpleSchema.RegEx.Id }, }); diff --git a/rpg-docs/server/migrations/migrations.js b/rpg-docs/server/migrations/migrations.js index 36f1f0cf..8f600ced 100644 --- a/rpg-docs/server/migrations/migrations.js +++ b/rpg-docs/server/migrations/migrations.js @@ -1,31 +1,37 @@ Migrations.add({ version: 1, + name: "converts effect proficiencies to proficiency objects, removes types from assets", up: function() { - return; - } -}); - -Migrations.add({ - version: 2, - name: "converts effect proficiencies to proficiency objects", - up: function() { + //convert proficiency effects to proficiency objects Effects.find({operation: "proficiency"}).forEach(function(effect){ - var type; - if(_.contains(SKILLS, effect.stat)) type = "skill"; + var type = "skill"; if(_.contains(SAVES, effect.stat)) type = "save"; - if(!type) throw "stat not a skill or a save"; Proficiencies.insert({ charId: effect.charId, name: effect.stat, value: effect.value, - parent: effect.parent, + parent: _.clone(effect.parent), type: type, enabled: effect.enabled + }, function(err){ + if(!err) Effects.remove(effect._id); }); - Effects.remove(effect._id); }); + //store type as a parent group if it's needed + Effects.find({"parent.collection": "Characters"}).forEach(function(e){ + Effects.update(e._id, {$set: {"parent.group": e.type}}); + }); + Attacks.find({"parent.collection": "Characters"}).forEach(function(a){ + Attacks.update(a._id, {$set: {"parent.group": a.type}}); + }); + //remove type + Effects.update({}, {$unset: {type: ""}}, {validate: false, multi: true}); + Attacks.update({}, {$unset: {type: ""}}, {validate: false, multi: true}); + //remove languages and proficiencies + Characters.update( + {}, + {$unset: {languages: "", proficiencies: ""}}, + {validate: false, multi: true} + ); }, - down: function(){ - return; - } });