Added proficiencies to printed sheet; some fixes

This commit is contained in:
Stefan Zermatten
2017-12-12 15:54:21 +02:00
parent 8349f7da9b
commit 64b3ca6066
8 changed files with 142 additions and 34 deletions

View 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;
};

View File

@@ -23,6 +23,10 @@
<iron-icon icon="social:share" item-icon></iron-icon>
Share
</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">
<iron-icon icon="settings" item-icon></iron-icon>
Settings

View File

@@ -238,4 +238,7 @@ Template.characterSheet.events({
element: event.currentTarget.parentElement.parentElement,
});
},
"click #printButton": function(event, instance){
print();
},
});

View File

@@ -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}});

View File

@@ -15,7 +15,7 @@
{{/each}}
</div>
<div>
{{alignment}} {{gender}} {{race}}
{{character.alignment}} {{character.gender}} {{character.race}}
</div>
</div>
</div>
@@ -23,12 +23,12 @@
<div class="col1 padded flex layout vertical">
<div class="layout horizontal">
<div class="abilities padded layout vertical justified">
{{> 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"}}
</div>
<div class="padded flex layout vertical">
<div class="proficiencyBonus">
@@ -75,20 +75,42 @@
</div>
</div>
<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 class="col2 padded flex">
<div class="layout vertical">
<div class="layout horizontal justified">
<div class="armor">
{{> printedSquareStat stat="armor" name="Armor Class" color="teal"}}
{{> printedSquareStat stat="armor" name="Armor Class"}}
</div>
<div class="inititive">
{{> printedSquareStat stat="initiative" name="Initiative" color="teal"}}
{{> printedSquareStat stat="initiative" name="Initiative" isSkill="true"}}
</div>
<div class="speed">
{{> printedSquareStat stat="speed" name="Speed" color="teal"}}
{{> printedSquareStat stat="speed" name="Speed"}}
</div>
</div>
<div class="hitpoints padded layout vertical">
@@ -97,13 +119,35 @@
<!-- Space for writing-->
</div>
<div class="layout horizontal end-justified">
/{{characterCalculate "attributeValue" _id "hitPoints"}}
/{{characterCalculate "attributeBase" _id "hitPoints"}}
</div>
</div>
<div class="tempHitpoints"></div>
<div class="layout horizontal">
<div class="hitDice"></div>
<div class="deathSaves"></div>
<div class="tempHitpoints padded layout vertical">
<div>Temporary Hit Points</div>
<div style="width: 3cm; height: 2cm;">
<!-- 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 class="attacks"></div>

View File

@@ -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);
},
});

View File

@@ -0,0 +1,6 @@
<template name="printedProficiency">
<div class="printedProficiency layout horizontal center">
<iron-icon icon="{{profIcon}}"></iron-icon>
<div>{{getName}}</div>
</div>
</template>

View File

@@ -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,
});
}
});