From 62d030adb7312dcbcc97c7752b15d481feb22f3a Mon Sep 17 00:00:00 2001 From: Thaum Date: Wed, 25 Mar 2015 08:22:43 +0000 Subject: [PATCH] Removed Equipment Slots --- rpg-docs/Model/Inventory/Items.js | 7 +--- .../inventory/itemDialog/itemDialog.html | 42 +++++++------------ .../inventory/itemDialog/itemDialog.js | 38 +++++------------ 3 files changed, 25 insertions(+), 62 deletions(-) diff --git a/rpg-docs/Model/Inventory/Items.js b/rpg-docs/Model/Inventory/Items.js index 0675621a..44407b5e 100644 --- a/rpg-docs/Model/Inventory/Items.js +++ b/rpg-docs/Model/Inventory/Items.js @@ -1,18 +1,13 @@ Items = new Mongo.Collection('items'); Schemas.Item = new SimpleSchema({ - name: {type: String, defaultValue: "New Item", trim: false}, + name: {type: String, defaultValue: "New Item", trim: false}, plural: {type: String, optional: true, trim: false}, description:{type: String, optional: true, trim: false}, charId: {type: String, regEx: SimpleSchema.RegEx.Id}, //id of owner quantity: {type: Number, min: 0, defaultValue: 1}, weight: {type: Number, min: 0, defaultValue: 0, decimal: true}, value: {type: Number, min: 0, defaultValue: 0, decimal: true}, - equipmentSlot: { - type: String, - defaultValue: "none", - allowedValues: ["none", "head", "armor", "arms", "hands", "held", "feet"] - }, enabled: {type: Boolean, defaultValue: false}, color: {type: String, allowedValues: _.pluck(colorOptions, "key"), defaultValue: "q"} }); diff --git a/rpg-docs/client/views/character/inventory/itemDialog/itemDialog.html b/rpg-docs/client/views/character/inventory/itemDialog/itemDialog.html index 0db13ed4..d51170a9 100644 --- a/rpg-docs/client/views/character/inventory/itemDialog/itemDialog.html +++ b/rpg-docs/client/views/character/inventory/itemDialog/itemDialog.html @@ -14,29 +14,17 @@ - - - - - {{#each equipmentSlots}} - {{name}} - {{/each}} - - - - {{#if canEquip}} -
-
Equipped
- - -
- {{/if}} +
+
Equipped
+ + +
@@ -55,12 +43,10 @@ - {{#if canEquip}} - - {{> effectsEditList parentId=_id parentCollection="Items" charId=charId type="equipment" enabled=equipped name=name}} - - {{> attackEditList parentId=_id parentCollection="Items" charId=charId type="equipment" enabled=equipped name=name}} - {{/if}} + + {{> effectsEditList parentId=_id parentCollection="Items" charId=charId type="equipment" enabled=equipped name=name}} + + {{> attackEditList parentId=_id parentCollection="Items" charId=charId type="equipment" enabled=equipped name=name}} {{/baseDialog}} {{/with}} \ No newline at end of file diff --git a/rpg-docs/client/views/character/inventory/itemDialog/itemDialog.js b/rpg-docs/client/views/character/inventory/itemDialog/itemDialog.js index 1290a3a9..7cbf10d1 100644 --- a/rpg-docs/client/views/character/inventory/itemDialog/itemDialog.js +++ b/rpg-docs/client/views/character/inventory/itemDialog/itemDialog.js @@ -2,16 +2,6 @@ var getContainers = function(charId){ return Containers.find({charId: charId}, {sort: {name: 1, _id: 1}, fields: {name: 1}}).fetch(); }; -var equipmentSlots = [ - {name: "None", value: "none"}, - {name: "Held", value: "held"}, - {name: "Armor", value: "armor"}, - {name: "Head", value: "head"}, - {name: "Arms", value: "arms"}, - {name: "Hands", value: "hands"}, - {name: "Feet", value: "feet"} -]; - Template.itemDialog.helpers({ item: function(){ return Items.findOne(this.itemId); @@ -19,15 +9,6 @@ Template.itemDialog.helpers({ containers: function(){ return getContainers(this.charId); }, - equipmentSlots: function(){ - return equipmentSlots; - }, - equipmentSlotIndex: function(){ - return _.indexOf(_.pluck(equipmentSlots, "value"), this.equipmentSlot); - }, - canEquip: function(){ - return this.equipmentSlot !== "none"; - }, ne1: function(num){ return num != 1; } @@ -40,11 +21,11 @@ Template.itemDialog.events({ "tap #deleteButton": function(event, instance){ Items.softRemove(instance.data.itemId); GlobalUI.deletedToast(instance.data.itemId, "Items", "Item"); - GlobalUI.closeDetail() + GlobalUI.closeDetail(); }, //TODO validate input (integer, non-negative, etc) for these inputs and give validation errors "change #itemNameInput, input #itemNameInput": function(event){ - console.log("changed Nameinput") + console.log("changed Nameinput"); var name = Template.instance().find("#itemNameInput").value; Items.update(this._id, {$set: {name: name}}); }, @@ -70,7 +51,14 @@ Template.itemDialog.events({ }, "change #equippedInput": function(event){ var equipped = Template.instance().find("#equippedInput").checked; - Items.update(this._id, {$set: {equipped: equipped}}); + var item = Items.findOne(this._id); + if(item){ + if(equipped){ + item.equip(); + } else { + item.unequip(); + } + } }, "core-select #containerDropDown": function(event){ var detail = event.originalEvent.detail; @@ -78,11 +66,5 @@ Template.itemDialog.events({ var containerId = detail.item.getAttribute("name"); var item = Items.findOne(Template.currentData().itemId); item.moveToContainer(containerId); - }, - "core-select #slotDropDown": function(event){ - var detail = event.originalEvent.detail; - if(!detail.isSelected) return; - var value = detail.item.getAttribute("value"); - Items.update(Template.currentData().itemId, {$set: {equipmentSlot: value}}); } });