From 92d3b086fa2c090a076e3cb285343bd568facf66 Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Thu, 23 Jul 2015 09:14:55 +0200 Subject: [PATCH 1/4] net worth calculations now take into account your containers' values --- rpg-docs/client/views/character/inventory/inventory.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rpg-docs/client/views/character/inventory/inventory.js b/rpg-docs/client/views/character/inventory/inventory.js index 58e70ea2..cde203fa 100644 --- a/rpg-docs/client/views/character/inventory/inventory.js +++ b/rpg-docs/client/views/character/inventory/inventory.js @@ -44,6 +44,12 @@ Template.inventory.helpers({ ).forEach(function(item){ worth += item.totalValue(); }); + Containers.find( + {charId: this._id}, + {fields: {value : 1}} + ).forEach(function(container) { + if(container.value) worth += container.value; + }) return worth; }, weightCarried: function(){ From ba7ccfdfa077325a3f5a83b43661e7ac15358d7a Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Thu, 23 Jul 2015 15:04:43 +0200 Subject: [PATCH 2/4] Added support for character profile pictures --- rpg-docs/Model/Character/Characters.js | 1 + .../personaDetailsDialog.html | 38 ++++++++++++++----- .../personaDetailsDialog.js | 21 ++++++++-- .../views/character/persona/persona.html | 30 ++++++++++++++- .../client/views/character/persona/persona.js | 7 ++-- 5 files changed, 79 insertions(+), 18 deletions(-) diff --git a/rpg-docs/Model/Character/Characters.js b/rpg-docs/Model/Character/Characters.js index 65295462..3003dc16 100644 --- a/rpg-docs/Model/Character/Characters.js +++ b/rpg-docs/Model/Character/Characters.js @@ -7,6 +7,7 @@ Schemas.Character = new SimpleSchema({ alignment: {type: String, defaultValue: "", trim: false, optional: true}, gender: {type: String, defaultValue: "", trim: false, optional: true}, race: {type: String, defaultValue: "", trim: false, optional: true}, + picture: {type: String, defaultValue: "", trim: true, optional: true}, description: {type: String, defaultValue: "", trim: false, optional: true}, personality: {type: String, defaultValue: "", trim: false, optional: true}, ideals: {type: String, defaultValue: "", trim: false, optional: true}, diff --git a/rpg-docs/client/views/character/persona/peronaDetailsDialog/personaDetailsDialog.html b/rpg-docs/client/views/character/persona/peronaDetailsDialog/personaDetailsDialog.html index 372528e8..93900df5 100644 --- a/rpg-docs/client/views/character/persona/peronaDetailsDialog/personaDetailsDialog.html +++ b/rpg-docs/client/views/character/persona/peronaDetailsDialog/personaDetailsDialog.html @@ -1,18 +1,36 @@ diff --git a/rpg-docs/client/views/character/persona/peronaDetailsDialog/personaDetailsDialog.js b/rpg-docs/client/views/character/persona/peronaDetailsDialog/personaDetailsDialog.js index 11407540..063eaea6 100644 --- a/rpg-docs/client/views/character/persona/peronaDetailsDialog/personaDetailsDialog.js +++ b/rpg-docs/client/views/character/persona/peronaDetailsDialog/personaDetailsDialog.js @@ -2,21 +2,34 @@ Template.personaDetailsEdit.onRendered(function(){ updatePolymerInputs(this); }); +Template.personaDetailsDialog.helpers({ + char: function() { + return Characters.findOne( + this._id, + {fields: {name: 1, alignment: 1, gender: 1, race: 1, picture: 1}} + ); + } +}); + Template.personaDetailsEdit.events({ "change #nameInput": function(event){ var input = event.currentTarget.value; - Characters.update(this.charId, {$set: {name: input}}); + Characters.update(this._id, {$set: {name: input}}); }, "change #alignmentInput": function(event){ var input = event.currentTarget.value; - Characters.update(this.charId, {$set: {alignment: input}}); + Characters.update(this._id, {$set: {alignment: input}}); }, "change #genderInput": function(event){ var input = event.currentTarget.value; - Characters.update(this.charId, {$set: {gender: input}}); + Characters.update(this._id, {$set: {gender: input}}); }, "change #raceInput": function(event){ var input = event.currentTarget.value; - Characters.update(this.charId, {$set: {race: input}}); + Characters.update(this._id, {$set: {race: input}}); + }, + "change #pictureInput": function(event){ + var input = event.currentTarget.value; + Characters.update(this._id, {$set: {picture: input}}); }, }); diff --git a/rpg-docs/client/views/character/persona/persona.html b/rpg-docs/client/views/character/persona/persona.html index e23e1bcc..b8a8cb52 100644 --- a/rpg-docs/client/views/character/persona/persona.html +++ b/rpg-docs/client/views/character/persona/persona.html @@ -3,7 +3,35 @@
{{#with characterDetails}} - {{#containerCardHelper this}}{{alignment}} {{gender}} {{race}}{{/containerCardHelper}} + + {{#unless picture}} +
+
+ {{name}} +
+
+ {{else}} + + {{/unless}} +
+ {{#if picture}} +
+ {{name}} +
+ {{/if}} +
+ {{alignment}} {{gender}} {{race}} +
+
+
{{/with}} {{> containerCard characterField "description" "Description"}} {{> containerCard characterField "personality" "Personality Traits"}} diff --git a/rpg-docs/client/views/character/persona/persona.js b/rpg-docs/client/views/character/persona/persona.js index 46063f25..6ef1e6a3 100644 --- a/rpg-docs/client/views/character/persona/persona.js +++ b/rpg-docs/client/views/character/persona/persona.js @@ -11,12 +11,12 @@ Template.persona.helpers({ characterDetails: function(){ var char = Characters.findOne( this._id, - {fields: {name: 1, gender: 1, alignment: 1, race:1}} + {fields: {name: 1, gender: 1, alignment: 1, race:1, picture: 1}} ); char.field = "details"; char.title = char.name; char.color = "d"; - char.topClass = "characterField"; + char.startEditing = true; return char; }, characterField: function(field, title){ @@ -40,7 +40,7 @@ Template.persona.helpers({ Template.persona.events({ "tap .characterField": function(event){ - if (this.field === "details"){ + if (this.field == "details"){ this.charId = Template.parentData()._id; GlobalUI.setDetail({ template: "personaDetailsDialog", @@ -58,6 +58,7 @@ Template.persona.events({ field: this.field, title: this.title, color: this.color, + startEditing: true, }, heroId: this._id + this.field, }); From 52198d024965c75e41475dd617d1d4255a806329 Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Thu, 23 Jul 2015 15:07:39 +0200 Subject: [PATCH 3/4] Disabled edit buttons for read-only viewers --- rpg-docs/Model/Character/TemporaryHitPoints.js | 2 +- rpg-docs/client/globalHelpers/canEditCharacter.js | 6 +++++- .../client/views/character/features/features.html | 5 +++-- .../client/views/character/features/features.js | 13 +++++++++---- .../client/views/character/inventory/inventory.html | 10 +++++----- .../client/views/character/inventory/inventory.js | 4 ++-- .../client/views/character/journal/journal.html | 6 ++++-- .../persona/backgroundDialog/backgroundDialog.html | 2 +- rpg-docs/client/views/character/spells/spells.html | 1 + rpg-docs/client/views/character/spells/spells.js | 4 ++-- .../character/stats/healthCard/healthCard.html | 7 ++++++- .../client/views/character/stats/hitDice/hitDice.js | 4 ++-- .../views/paperTemplates/baseDialog/baseDialog.js | 13 ++----------- 13 files changed, 43 insertions(+), 34 deletions(-) diff --git a/rpg-docs/Model/Character/TemporaryHitPoints.js b/rpg-docs/Model/Character/TemporaryHitPoints.js index 96752d4c..02b6e45d 100644 --- a/rpg-docs/Model/Character/TemporaryHitPoints.js +++ b/rpg-docs/Model/Character/TemporaryHitPoints.js @@ -5,7 +5,7 @@ Schemas.TemporaryHitPoints = new SimpleSchema({ name: {type: String, optional: true}, maximum: {type: Number, defaultValue: 0}, used: {type: Number, defaultValue: 0}, - deleteOnZero:{type: Boolean, defaultValue: true}, + deleteOnZero:{type: Boolean, defaultValue: false}, dateAdded: { type: Date, autoValue: function() { diff --git a/rpg-docs/client/globalHelpers/canEditCharacter.js b/rpg-docs/client/globalHelpers/canEditCharacter.js index 95ba2ec6..2de1b6d6 100644 --- a/rpg-docs/client/globalHelpers/canEditCharacter.js +++ b/rpg-docs/client/globalHelpers/canEditCharacter.js @@ -1,6 +1,10 @@ Template.registerHelper("canEditCharacter", function(charId) { + return canEditCharacter(charId); +}); + +canEditCharacter = function(charId) { var char = Characters.findOne(charId) var userId = Meteor.userId(); return char.owner === userId || _.contains(char.writers, userId); -}); +}; diff --git a/rpg-docs/client/views/character/features/features.html b/rpg-docs/client/views/character/features/features.html index e39dd965..5726c166 100644 --- a/rpg-docs/client/views/character/features/features.html +++ b/rpg-docs/client/views/character/features/features.html @@ -95,14 +95,15 @@ + checked={{enabled}} + disabled={{#unless canEditCharacter charId}}true{{/unless}}> {{/if}}
{{#if description}}
{{evaluateString charId description}}
+ >{{evaluateString charId shortDescription}}
{{/if}} {{#if hasUses}}
diff --git a/rpg-docs/client/views/character/features/features.js b/rpg-docs/client/views/character/features/features.js index 3f68a6af..a0b1f329 100644 --- a/rpg-docs/client/views/character/features/features.js +++ b/rpg-docs/client/views/character/features/features.js @@ -3,14 +3,19 @@ Template.features.helpers({ var features = Features.find({charId: this._id}, {sort: {color: 1, name: 1}}); return features; }, + shortDescription: function() { + if (_.isString(this.description)){ + return this.description.split(/[\n\r]{3,}/)[0]; + } + }, hasUses: function(){ return this.usesValue() > 0; }, noUsesLeft: function(){ - return this.usesLeft() <= 0; + return this.usesLeft() <= 0 || !canEditCharacter(this.charId); }, usesFull: function(){ - return this.usesLeft() >= this.usesValue(); + return this.usesLeft() >= this.usesValue() || !canEditCharacter(this.charId); }, colorClass: function(){ return getColorClass(this.color); @@ -99,12 +104,12 @@ Template.resource.helpers({ var value = Characters.calculate.attributeValue(this.char._id, this.name); var base = Characters.calculate.attributeBase(this.char._id, this.name); var baseBigger = value < base; - return !baseBigger; + return !baseBigger || !canEditCharacter(this.char._id); }, cantDecrement: function(){ var value = Characters.calculate.attributeValue(this.char._id, this.name); var valuePositive = value > 0; - return !valuePositive; + return !valuePositive || !canEditCharacter(this.char._id); }, getColor: function(){ var value = Characters.calculate.attributeValue(this.char._id, this.name); diff --git a/rpg-docs/client/views/character/inventory/inventory.html b/rpg-docs/client/views/character/inventory/inventory.html index fcab2eb0..ff90d82c 100644 --- a/rpg-docs/client/views/character/inventory/inventory.html +++ b/rpg-docs/client/views/character/inventory/inventory.html @@ -35,8 +35,7 @@
+ layout horizontal center>
@@ -114,6 +113,7 @@
@@ -152,11 +152,11 @@
+ draggable={{canEditCharacter charId}}>
{{#if ne1 quantity}}{{quantity}} {{/if}}{{pluralName}}
- {{#if settings.showIncrement}} + {{#if settings.showIncrement}}{{#if canEditCharacter charId}}
- {{/if}} + {{/if}}{{/if}}
diff --git a/rpg-docs/client/views/character/inventory/inventory.js b/rpg-docs/client/views/character/inventory/inventory.js index cde203fa..aaca5e8f 100644 --- a/rpg-docs/client/views/character/inventory/inventory.js +++ b/rpg-docs/client/views/character/inventory/inventory.js @@ -48,8 +48,8 @@ Template.inventory.helpers({ {charId: this._id}, {fields: {value : 1}} ).forEach(function(container) { - if(container.value) worth += container.value; - }) + if (container.value) worth += container.value; + }); return worth; }, weightCarried: function(){ diff --git a/rpg-docs/client/views/character/journal/journal.html b/rpg-docs/client/views/character/journal/journal.html index 1ab6a6ab..6d2a048a 100644 --- a/rpg-docs/client/views/character/journal/journal.html +++ b/rpg-docs/client/views/character/journal/journal.html @@ -10,7 +10,8 @@ layout horizontal center>
Experience
{{characterCalculate "experience" _id}} XP
- +
{{#each experiences}} @@ -55,7 +56,8 @@
+ icon="add" + disabled={{#unless canEditCharacter _id}}true{{/unless}}>
diff --git a/rpg-docs/client/views/character/persona/backgroundDialog/backgroundDialog.html b/rpg-docs/client/views/character/persona/backgroundDialog/backgroundDialog.html index 4d31f38e..8bbf52ff 100644 --- a/rpg-docs/client/views/character/persona/backgroundDialog/backgroundDialog.html +++ b/rpg-docs/client/views/character/persona/backgroundDialog/backgroundDialog.html @@ -1,5 +1,5 @@