diff --git a/rpg-docs/Model/Inventory/Containers.js b/rpg-docs/Model/Inventory/Containers.js index 11a66f34..cde2994d 100644 --- a/rpg-docs/Model/Inventory/Containers.js +++ b/rpg-docs/Model/Inventory/Containers.js @@ -4,4 +4,4 @@ Container = function(name, owner){ this.name = name; this.owner = owner; this.isCarried = true; -} \ No newline at end of file +}; \ No newline at end of file diff --git a/rpg-docs/Model/Inventory/Items.js b/rpg-docs/Model/Inventory/Items.js index c6835d88..b2a310e7 100644 --- a/rpg-docs/Model/Inventory/Items.js +++ b/rpg-docs/Model/Inventory/Items.js @@ -5,7 +5,51 @@ Item = function(name, container){ this.container = container; this.quantity = 1; this.weight = 0.0; - this.value = 0;//value in gold pieces + //value in gold pieces + this.value = 0; this.description = ""; + //is this item a coin, letter of credit, ect. + this.tradeGood = false; + this.stakcable = false; this.effects = []; +} + +Items.helpers({ + totalValue: function(){ + return this.value * this.quantity; + }, + pluralName: function(){ + if(this.stackable && this.plural && this.quantity > 1){ + return this.plural; + } else{ + return this.name; + } + } +}); + +if(Meteor.isClient){ + Template.registerHelper("valueString", function(value){ + var resultArray = []; + //sp + var gp = Math.floor(value); + if(gp > 0) resultArray.push(gp + "gp"); + //sp + var sp = Math.floor(10 * (value % 1)); + if(sp > 0) resultArray.push(sp + "sp"); + //cp + var cp = 10 * ((value * 10) % 1); + cp = Math.round(cp * 1000) / 1000; + if(cp > 0) resultArray.push(cp + "cp"); + + //build string with correct spacing + var result = ""; + for(var i = 0; i < resultArray.length; i++){ + //add a space between values + if(i !== 0){ + result += " "; + } + result += resultArray[i]; + } + return result; + }); } \ No newline at end of file diff --git a/rpg-docs/client/views/character/character.html b/rpg-docs/client/views/character/character.html index 8e757dfc..6e2bbc66 100644 --- a/rpg-docs/client/views/character/character.html +++ b/rpg-docs/client/views/character/character.html @@ -4,13 +4,14 @@
-
- Proficiency Bonus {{proficiencyBonus}} -
{{> skills}}
+
+

Inventory

+ {{> inventoryTables}} +

Description

{{> textField character=this field="description"}} diff --git a/rpg-docs/client/views/inventory/containerTable/containerTable.html b/rpg-docs/client/views/inventory/containerTable/containerTable.html new file mode 100644 index 00000000..2ae1ab0d --- /dev/null +++ b/rpg-docs/client/views/inventory/containerTable/containerTable.html @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/rpg-docs/client/views/inventory/containerTable/containerTable.js b/rpg-docs/client/views/inventory/containerTable/containerTable.js new file mode 100644 index 00000000..0edf1c42 --- /dev/null +++ b/rpg-docs/client/views/inventory/containerTable/containerTable.js @@ -0,0 +1,5 @@ +Template.containerTable.helpers({ + items: function(){ + return Items.find({container: this._id}); + } +}); \ No newline at end of file diff --git a/rpg-docs/client/views/inventory/inventoryTables/inventoryTables.html b/rpg-docs/client/views/inventory/inventoryTables/inventoryTables.html new file mode 100644 index 00000000..0d0560da --- /dev/null +++ b/rpg-docs/client/views/inventory/inventoryTables/inventoryTables.html @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/rpg-docs/client/views/inventory/inventoryTables/inventoryTables.js b/rpg-docs/client/views/inventory/inventoryTables/inventoryTables.js new file mode 100644 index 00000000..84f36e4c --- /dev/null +++ b/rpg-docs/client/views/inventory/inventoryTables/inventoryTables.js @@ -0,0 +1,5 @@ +Template.inventoryTables.helpers({ + containers: function(){ + return Containers.find({owner: this._id}); + } +}); \ No newline at end of file diff --git a/rpg-docs/client/views/inventory/itemRow/itemRow.css b/rpg-docs/client/views/inventory/itemRow/itemRow.css new file mode 100644 index 00000000..e9201f42 --- /dev/null +++ b/rpg-docs/client/views/inventory/itemRow/itemRow.css @@ -0,0 +1,3 @@ +tr.selected{ + background-color: #4182BC; +} \ No newline at end of file diff --git a/rpg-docs/client/views/inventory/itemRow/itemRow.html b/rpg-docs/client/views/inventory/itemRow/itemRow.html new file mode 100644 index 00000000..33f38a87 --- /dev/null +++ b/rpg-docs/client/views/inventory/itemRow/itemRow.html @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/rpg-docs/client/views/inventory/itemRow/itemRow.js b/rpg-docs/client/views/inventory/itemRow/itemRow.js new file mode 100644 index 00000000..af8df0eb --- /dev/null +++ b/rpg-docs/client/views/inventory/itemRow/itemRow.js @@ -0,0 +1,15 @@ +Template.itemRow.helpers({ + isSelected: function(){ + return Session.get('selectedItemRow')=== this._id; + } +}); + +Template.itemRow.events({ + "click": function(e){ + if(Session.get('selectedItemRow')=== this._id){ + Session.set('selectedItemRow', null); + } else{ + Session.set('selectedItemRow', this._id); + } + } +}); \ No newline at end of file