From 64b3ca6066cae3a9fdf169a09481dfc421c91383 Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Tue, 12 Dec 2017 15:54:21 +0200 Subject: [PATCH] Added proficiencies to printed sheet; some fixes --- .../lib/removeDuplicateProficiencies.js | 17 +++++ .../views/character/characterSheet.html | 4 + .../client/views/character/characterSheet.js | 3 + .../views/character/features/features.js | 18 ----- .../printedCharacterSheet.html | 76 +++++++++++++++---- .../printedCharacterSheet.js | 12 +++ .../printedProficiency.html | 6 ++ .../printedProficiency/printedProficiency.js | 40 ++++++++++ 8 files changed, 142 insertions(+), 34 deletions(-) create mode 100644 rpg-docs/client/lib/removeDuplicateProficiencies.js create mode 100644 rpg-docs/client/views/character/printedCharacterSheet/printedProficiency/printedProficiency.html create mode 100644 rpg-docs/client/views/character/printedCharacterSheet/printedProficiency/printedProficiency.js diff --git a/rpg-docs/client/lib/removeDuplicateProficiencies.js b/rpg-docs/client/lib/removeDuplicateProficiencies.js new file mode 100644 index 00000000..1f315e70 --- /dev/null +++ b/rpg-docs/client/lib/removeDuplicateProficiencies.js @@ -0,0 +1,17 @@ +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; +}; diff --git a/rpg-docs/client/views/character/characterSheet.html b/rpg-docs/client/views/character/characterSheet.html index 5048856f..65b4b13a 100644 --- a/rpg-docs/client/views/character/characterSheet.html +++ b/rpg-docs/client/views/character/characterSheet.html @@ -23,6 +23,10 @@ Share + + + Print + Settings diff --git a/rpg-docs/client/views/character/characterSheet.js b/rpg-docs/client/views/character/characterSheet.js index f2984779..a480b696 100644 --- a/rpg-docs/client/views/character/characterSheet.js +++ b/rpg-docs/client/views/character/characterSheet.js @@ -238,4 +238,7 @@ Template.characterSheet.events({ element: event.currentTarget.parentElement.parentElement, }); }, + "click #printButton": function(event, instance){ + print(); + }, }); diff --git a/rpg-docs/client/views/character/features/features.js b/rpg-docs/client/views/character/features/features.js index 17873a2f..778f6cc1 100644 --- a/rpg-docs/client/views/character/features/features.js +++ b/rpg-docs/client/views/character/features/features.js @@ -1,21 +1,3 @@ -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}}); diff --git a/rpg-docs/client/views/character/printedCharacterSheet/printedCharacterSheet.html b/rpg-docs/client/views/character/printedCharacterSheet/printedCharacterSheet.html index 44cddd5f..4e5e2d8c 100644 --- a/rpg-docs/client/views/character/printedCharacterSheet/printedCharacterSheet.html +++ b/rpg-docs/client/views/character/printedCharacterSheet/printedCharacterSheet.html @@ -15,7 +15,7 @@ {{/each}}
- {{alignment}} {{gender}} {{race}} + {{character.alignment}} {{character.gender}} {{character.race}}
@@ -23,12 +23,12 @@
- {{> printedAbility ability="strength" title="Strength" color="red"}} - {{> printedAbility ability="dexterity" title="Dexterity" color="indigo"}} - {{> printedAbility ability="constitution" title="Constitution" color="green"}} - {{> printedAbility ability="intelligence" title="Intelligence" color="deep-orange"}} - {{> printedAbility ability="wisdom" title="Wisdom" color="purple"}} - {{> printedAbility ability="charisma" title="Charisma" color="pink"}} + {{> printedAbility ability="strength" title="Strength"}} + {{> printedAbility ability="dexterity" title="Dexterity"}} + {{> printedAbility ability="constitution" title="Constitution"}} + {{> printedAbility ability="intelligence" title="Intelligence"}} + {{> printedAbility ability="wisdom" title="Wisdom"}} + {{> printedAbility ability="charisma" title="Charisma"}}
@@ -75,20 +75,42 @@
- +
+ Proficiencies +
+
+ {{#if weaponProfs.length}} +
Weapons
+ {{/if}} + {{#each weaponProfs}} + {{> printedProficiency}} + {{/each}} + {{#if armorProfs.length}} +
Armor
+ {{/if}} + {{#each armorProfs}} + {{> printedProficiency}} + {{/each}} + {{#if toolProfs.length}} +
Tools
+ {{/if}} + {{#each toolProfs}} + {{> printedProficiency}} + {{/each}} +
- {{> printedSquareStat stat="armor" name="Armor Class" color="teal"}} + {{> printedSquareStat stat="armor" name="Armor Class"}}
- {{> printedSquareStat stat="initiative" name="Initiative" color="teal"}} + {{> printedSquareStat stat="initiative" name="Initiative" isSkill="true"}}
- {{> printedSquareStat stat="speed" name="Speed" color="teal"}} + {{> printedSquareStat stat="speed" name="Speed"}}
@@ -97,13 +119,35 @@
- /{{characterCalculate "attributeValue" _id "hitPoints"}} + /{{characterCalculate "attributeBase" _id "hitPoints"}}
-
-
-
-
+
+
Temporary Hit Points
+
+ +
+
+
+ Hit Dice +
+
+
+
+ Successes +
+ + + +
+
+
+ Failures +
+ + + +
diff --git a/rpg-docs/client/views/character/printedCharacterSheet/printedCharacterSheet.js b/rpg-docs/client/views/character/printedCharacterSheet/printedCharacterSheet.js index 1a2b9da4..638b89e7 100644 --- a/rpg-docs/client/views/character/printedCharacterSheet/printedCharacterSheet.js +++ b/rpg-docs/client/views/character/printedCharacterSheet/printedCharacterSheet.js @@ -14,4 +14,16 @@ Template.printedCharacterSheet.helpers({ classes: function(){ return Classes.find({charId: this._id}, {sort: {createdAt: 1}}); }, + weaponProfs: function(){ + var profs = Proficiencies.find({charId: this._id, type: "weapon"}); + return removeDuplicateProficiencies(profs); + }, + armorProfs: function(){ + var profs = Proficiencies.find({charId: this._id, type: "armor"}); + return removeDuplicateProficiencies(profs); + }, + toolProfs: function(){ + var profs = Proficiencies.find({charId: this._id, type: "tool"}); + return removeDuplicateProficiencies(profs); + }, }); diff --git a/rpg-docs/client/views/character/printedCharacterSheet/printedProficiency/printedProficiency.html b/rpg-docs/client/views/character/printedCharacterSheet/printedProficiency/printedProficiency.html new file mode 100644 index 00000000..276f5856 --- /dev/null +++ b/rpg-docs/client/views/character/printedCharacterSheet/printedProficiency/printedProficiency.html @@ -0,0 +1,6 @@ + diff --git a/rpg-docs/client/views/character/printedCharacterSheet/printedProficiency/printedProficiency.js b/rpg-docs/client/views/character/printedCharacterSheet/printedProficiency/printedProficiency.js new file mode 100644 index 00000000..1c3d1d69 --- /dev/null +++ b/rpg-docs/client/views/character/printedCharacterSheet/printedProficiency/printedProficiency.js @@ -0,0 +1,40 @@ +Template.printedProficiency.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; + }, +}); + +Template.printedProficiency.events({ + "click .proficiency": function(event, instance){ + if (this.parent.collection == "Characters") { + if (this.parent.group == "background") { + pushDialogStack({ + template: "backgroundDialog", + data: { + "charId": this.charId, + "field":"background", + "title":"Background", + "color":"j", + }, + element: event.currentTarget, + }) + return; + } + } + + openParentDialog({ + parent: this.parent, + charId: this.charId, + element: event.currentTarget, + }); + } +});