Added proficiencies to printed sheet; some fixes
This commit is contained in:
17
rpg-docs/client/lib/removeDuplicateProficiencies.js
Normal file
17
rpg-docs/client/lib/removeDuplicateProficiencies.js
Normal file
@@ -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;
|
||||||
|
};
|
||||||
@@ -23,6 +23,10 @@
|
|||||||
<iron-icon icon="social:share" item-icon></iron-icon>
|
<iron-icon icon="social:share" item-icon></iron-icon>
|
||||||
Share
|
Share
|
||||||
</paper-icon-item>
|
</paper-icon-item>
|
||||||
|
<paper-icon-item id="printButton">
|
||||||
|
<iron-icon icon="print" item-icon></iron-icon>
|
||||||
|
Print
|
||||||
|
</paper-icon-item>
|
||||||
<paper-icon-item id="characterSettings">
|
<paper-icon-item id="characterSettings">
|
||||||
<iron-icon icon="settings" item-icon></iron-icon>
|
<iron-icon icon="settings" item-icon></iron-icon>
|
||||||
Settings
|
Settings
|
||||||
|
|||||||
@@ -238,4 +238,7 @@ Template.characterSheet.events({
|
|||||||
element: event.currentTarget.parentElement.parentElement,
|
element: event.currentTarget.parentElement.parentElement,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
"click #printButton": function(event, instance){
|
||||||
|
print();
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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({
|
Template.features.helpers({
|
||||||
features: function(){
|
features: function(){
|
||||||
var features = Features.find({charId: this._id}, {sort: {color: 1, name: 1}});
|
var features = Features.find({charId: this._id}, {sort: {color: 1, name: 1}});
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
{{/each}}
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
{{alignment}} {{gender}} {{race}}
|
{{character.alignment}} {{character.gender}} {{character.race}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -23,12 +23,12 @@
|
|||||||
<div class="col1 padded flex layout vertical">
|
<div class="col1 padded flex layout vertical">
|
||||||
<div class="layout horizontal">
|
<div class="layout horizontal">
|
||||||
<div class="abilities padded layout vertical justified">
|
<div class="abilities padded layout vertical justified">
|
||||||
{{> printedAbility ability="strength" title="Strength" color="red"}}
|
{{> printedAbility ability="strength" title="Strength"}}
|
||||||
{{> printedAbility ability="dexterity" title="Dexterity" color="indigo"}}
|
{{> printedAbility ability="dexterity" title="Dexterity"}}
|
||||||
{{> printedAbility ability="constitution" title="Constitution" color="green"}}
|
{{> printedAbility ability="constitution" title="Constitution"}}
|
||||||
{{> printedAbility ability="intelligence" title="Intelligence" color="deep-orange"}}
|
{{> printedAbility ability="intelligence" title="Intelligence"}}
|
||||||
{{> printedAbility ability="wisdom" title="Wisdom" color="purple"}}
|
{{> printedAbility ability="wisdom" title="Wisdom"}}
|
||||||
{{> printedAbility ability="charisma" title="Charisma" color="pink"}}
|
{{> printedAbility ability="charisma" title="Charisma"}}
|
||||||
</div>
|
</div>
|
||||||
<div class="padded flex layout vertical">
|
<div class="padded flex layout vertical">
|
||||||
<div class="proficiencyBonus">
|
<div class="proficiencyBonus">
|
||||||
@@ -75,20 +75,42 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="proficiencies">
|
<div class="proficiencies">
|
||||||
|
<div class="paper-font-subhead">
|
||||||
|
Proficiencies
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
{{#if weaponProfs.length}}
|
||||||
|
<div class="paper-font-subhead">Weapons</div>
|
||||||
|
{{/if}}
|
||||||
|
{{#each weaponProfs}}
|
||||||
|
{{> printedProficiency}}
|
||||||
|
{{/each}}
|
||||||
|
{{#if armorProfs.length}}
|
||||||
|
<div class="paper-font-subhead">Armor</div>
|
||||||
|
{{/if}}
|
||||||
|
{{#each armorProfs}}
|
||||||
|
{{> printedProficiency}}
|
||||||
|
{{/each}}
|
||||||
|
{{#if toolProfs.length}}
|
||||||
|
<div class="paper-font-subhead">Tools</div>
|
||||||
|
{{/if}}
|
||||||
|
{{#each toolProfs}}
|
||||||
|
{{> printedProficiency}}
|
||||||
|
{{/each}}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col2 padded flex">
|
<div class="col2 padded flex">
|
||||||
<div class="layout vertical">
|
<div class="layout vertical">
|
||||||
<div class="layout horizontal justified">
|
<div class="layout horizontal justified">
|
||||||
<div class="armor">
|
<div class="armor">
|
||||||
{{> printedSquareStat stat="armor" name="Armor Class" color="teal"}}
|
{{> printedSquareStat stat="armor" name="Armor Class"}}
|
||||||
</div>
|
</div>
|
||||||
<div class="inititive">
|
<div class="inititive">
|
||||||
{{> printedSquareStat stat="initiative" name="Initiative" color="teal"}}
|
{{> printedSquareStat stat="initiative" name="Initiative" isSkill="true"}}
|
||||||
</div>
|
</div>
|
||||||
<div class="speed">
|
<div class="speed">
|
||||||
{{> printedSquareStat stat="speed" name="Speed" color="teal"}}
|
{{> printedSquareStat stat="speed" name="Speed"}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="hitpoints padded layout vertical">
|
<div class="hitpoints padded layout vertical">
|
||||||
@@ -97,13 +119,35 @@
|
|||||||
<!-- Space for writing-->
|
<!-- Space for writing-->
|
||||||
</div>
|
</div>
|
||||||
<div class="layout horizontal end-justified">
|
<div class="layout horizontal end-justified">
|
||||||
/{{characterCalculate "attributeValue" _id "hitPoints"}}
|
/{{characterCalculate "attributeBase" _id "hitPoints"}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="tempHitpoints"></div>
|
<div class="tempHitpoints padded layout vertical">
|
||||||
<div class="layout horizontal">
|
<div>Temporary Hit Points</div>
|
||||||
<div class="hitDice"></div>
|
<div style="width: 3cm; height: 2cm;">
|
||||||
<div class="deathSaves"></div>
|
<!-- Space for writing-->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="hitDice">
|
||||||
|
Hit Dice
|
||||||
|
</div>
|
||||||
|
<div class="deathSaves layout vertical">
|
||||||
|
<div class="layout horizontal center">
|
||||||
|
<div class="flex">
|
||||||
|
Successes
|
||||||
|
</div>
|
||||||
|
<iron-icon icon="radio-button-unchecked"></iron-icon>
|
||||||
|
<iron-icon icon="radio-button-unchecked"></iron-icon>
|
||||||
|
<iron-icon icon="radio-button-unchecked"></iron-icon>
|
||||||
|
</div>
|
||||||
|
<div class="layout horizontal center">
|
||||||
|
<div class="flex">
|
||||||
|
Failures
|
||||||
|
</div>
|
||||||
|
<iron-icon icon="radio-button-unchecked"></iron-icon>
|
||||||
|
<iron-icon icon="radio-button-unchecked"></iron-icon>
|
||||||
|
<iron-icon icon="radio-button-unchecked"></iron-icon>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="attacks"></div>
|
<div class="attacks"></div>
|
||||||
|
|||||||
@@ -14,4 +14,16 @@ Template.printedCharacterSheet.helpers({
|
|||||||
classes: function(){
|
classes: function(){
|
||||||
return Classes.find({charId: this._id}, {sort: {createdAt: 1}});
|
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);
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<template name="printedProficiency">
|
||||||
|
<div class="printedProficiency layout horizontal center">
|
||||||
|
<iron-icon icon="{{profIcon}}"></iron-icon>
|
||||||
|
<div>{{getName}}</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -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,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user