From 5fdbb8398f6f1e593f2f5df90dbba7274b26ffad Mon Sep 17 00:00:00 2001 From: Thaum Date: Tue, 4 Nov 2014 06:56:27 +0000 Subject: [PATCH] Fixed incorrectly defined helpers, added item routes --- rpg-docs/Model/Inventory/Items.js | 1 + rpg-docs/Routes/Routes.js | 28 +++++++++++++++++++ .../client/views/character/characterName.html | 5 +++- .../views/character/characterStats.html | 2 +- rpg-docs/client/views/character/features.js | 8 +++--- 5 files changed, 38 insertions(+), 6 deletions(-) diff --git a/rpg-docs/Model/Inventory/Items.js b/rpg-docs/Model/Inventory/Items.js index ecce01c3..c6835d88 100644 --- a/rpg-docs/Model/Inventory/Items.js +++ b/rpg-docs/Model/Inventory/Items.js @@ -7,4 +7,5 @@ Item = function(name, container){ this.weight = 0.0; this.value = 0;//value in gold pieces this.description = ""; + this.effects = []; } \ No newline at end of file diff --git a/rpg-docs/Routes/Routes.js b/rpg-docs/Routes/Routes.js index 52fd9867..8179364c 100644 --- a/rpg-docs/Routes/Routes.js +++ b/rpg-docs/Routes/Routes.js @@ -15,9 +15,37 @@ Router.map( function () { data: function() { var data = Characters.findOne({_id: this.params._id}); data.features = Features.find({character: data._id}); + data.containers = Containers.find({owner: data._id}); + data.containers.forEach(function(container){ + container.items = Items.find({container: container._id}); + }); var newInstance = Object.create(protoCharacter); data = _.extend(newInstance, data); return data; } }); + + this.route('inventory', { + path: '/inventory/:_id', + notFoundTemplate: 'characterNotFound', + data: { + containers: function() { + var containers = Containers.find({owner: data._id}); + containers.forEach(function(container){ + container.items = Items.find({container: container._id}); + }); + return containers; + }, + + } + }); + + this.route('item', { + path: '/item/:_id', + notFoundTemplate: 'itemNotFound', + data: function() { + var data = Items.findOne({_id: this.params._id}); + return data; + } + }); }); \ No newline at end of file diff --git a/rpg-docs/client/views/character/characterName.html b/rpg-docs/client/views/character/characterName.html index 553e4903..fbfb2c13 100644 --- a/rpg-docs/client/views/character/characterName.html +++ b/rpg-docs/client/views/character/characterName.html @@ -6,6 +6,9 @@ {{name}}
- {{alignment}} {{gender}} {{race}} {{#each class}} {{this}} {{/each}} + {{alignment}} {{gender}} {{race}} +
+
+ {{> healthBar}}
\ No newline at end of file diff --git a/rpg-docs/client/views/character/characterStats.html b/rpg-docs/client/views/character/characterStats.html index ca3091c2..7c7c35f6 100644 --- a/rpg-docs/client/views/character/characterStats.html +++ b/rpg-docs/client/views/character/characterStats.html @@ -2,7 +2,7 @@
Hit Points
- +
{{attributeValue attributes.maxHitPoints}} diff --git a/rpg-docs/client/views/character/features.js b/rpg-docs/client/views/character/features.js index 99651b64..7a36110a 100644 --- a/rpg-docs/client/views/character/features.js +++ b/rpg-docs/client/views/character/features.js @@ -1,12 +1,12 @@ -Template.features.helpers = { +Template.features.helpers({ features: function(){ var features = Features.find({character: this._id}); console.log('found: ', features); return features; } -} +}); -Template.features.events = { +Template.features.events({ // Fires when any element is clicked 'change .enabled': function (event) { var enable = event.target.checked @@ -17,4 +17,4 @@ Template.features.events = { Template.parentData(1).pullEffects(this.effects); } } -} \ No newline at end of file +}); \ No newline at end of file