diff --git a/rpg-docs/client/views/character/features/features.html b/rpg-docs/client/views/character/features/features.html
index cda72b1e..066ae33d 100644
--- a/rpg-docs/client/views/character/features/features.html
+++ b/rpg-docs/client/views/character/features/features.html
@@ -55,19 +55,19 @@
Proficiencies
- {{#if weaponProfs.count}}
+ {{#if weaponProfs.length}}
Weapons
{{/if}}
{{#each weaponProfs}}
{{> proficiencyListItem}}
{{/each}}
- {{#if armorProfs.count}}
+ {{#if armorProfs.length}}
Armor
{{/if}}
{{#each armorProfs}}
{{> proficiencyListItem}}
{{/each}}
- {{#if toolProfs.count}}
+ {{#if toolProfs.length}}
Tools
{{/if}}
{{#each toolProfs}}
diff --git a/rpg-docs/client/views/character/features/features.js b/rpg-docs/client/views/character/features/features.js
index ecf54782..33c0e459 100644
--- a/rpg-docs/client/views/character/features/features.js
+++ b/rpg-docs/client/views/character/features/features.js
@@ -1,3 +1,21 @@
+var removeDuplicateProficiencies = function(proficiencies) {
+ dict = {};
+ proficiencies.forEach(function(prof) {
+ if (prof.name in dict) { //if we have already gone over another proficiency for the same thing
+ if (dict[prof.name].value < prof.value) {
+ dict[prof.name] = prof; //then take the new one if it's higher, otherwise leave it
+ }
+ } else {
+ dict[prof.name] = prof; //if it wasn't already there, store it
+ }
+ });
+ profs = []
+ _.forEach(dict, function(prof) {
+ profs.push(prof);
+ })
+ return profs;
+};
+
Template.features.helpers({
features: function(){
var features = Features.find({charId: this._id}, {sort: {color: 1, name: 1}});
@@ -27,13 +45,16 @@ Template.features.helpers({
return !this.alwaysEnabled;
},
weaponProfs: function(){
- return Proficiencies.find({charId: this._id, type: "weapon"});
+ var profs = Proficiencies.find({charId: this._id, type: "weapon"});
+ return removeDuplicateProficiencies(profs);
},
armorProfs: function(){
- return Proficiencies.find({charId: this._id, type: "armor"});
+ var profs = Proficiencies.find({charId: this._id, type: "armor"});
+ return removeDuplicateProficiencies(profs);
},
toolProfs: function(){
- return Proficiencies.find({charId: this._id, type: "tool"});
+ var profs = Proficiencies.find({charId: this._id, type: "tool"});
+ return removeDuplicateProficiencies(profs);
},
});
diff --git a/rpg-docs/client/views/character/persona/persona.js b/rpg-docs/client/views/character/persona/persona.js
index e01c3c73..5a7fc10b 100644
--- a/rpg-docs/client/views/character/persona/persona.js
+++ b/rpg-docs/client/views/character/persona/persona.js
@@ -7,6 +7,24 @@ var colorMap = {
backstory: "j",
};
+var removeDuplicateProficiencies = function(proficiencies) {
+ dict = {};
+ proficiencies.forEach(function(prof) {
+ if (prof.name in dict) { //if we have already gone over another proficiency for the same thing
+ if (dict[prof.name].value < prof.value) {
+ dict[prof.name] = prof; //then take the new one if it's higher, otherwise leave it
+ }
+ } else {
+ dict[prof.name] = prof; //if it wasn't already there, store it
+ }
+ });
+ profs = []
+ _.forEach(dict, function(prof) {
+ profs.push(prof);
+ })
+ return profs;
+};
+
Template.persona.helpers({
characterDetails: function(){
var char = Characters.findOne(
@@ -33,7 +51,8 @@ Template.persona.helpers({
};
},
languages: function(){
- return Proficiencies.find({charId: this._id, type: "language"});
+ var profs = Proficiencies.find({charId: this._id, type: "language"});
+ return removeDuplicateProficiencies(profs);
},
});