Skip to content

Commit

Permalink
Fixed stack dragging within the same container
Browse files Browse the repository at this point in the history
  • Loading branch information
ThaumRystra committed May 11, 2015
1 parent 3f4dcc1 commit 43c4122
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions rpg-docs/Model/Inventory/Items.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,14 @@ var moveItem = function(itemId, enable, parentCollection, parentId) {
item.parent.id !== parentId ||
item.enabled !== enable
){
var setter = {$set: {
"parent.collection": parentCollection,
"parent.id": parentId,
enabled: enable,
}};
if (parentCollection === "Characters"){
setter.$set.charId = parentId;
}
Items.update(itemId, setter);
Items.update(
itemId,
{$set: {
"parent.collection": parentCollection,
"parent.id": parentId,
enabled: enable,
}}
);
}
};

Expand Down Expand Up @@ -137,15 +136,13 @@ Meteor.methods({
//create a new item stack
var newStack = _.omit(EJSON.clone(item), "_id");
newStack.parent = parent;
if (newStack.parent.collection === "Characters"){
newStack.charId = newStack.parent.id;
}
newStack.quantity = moveQuantity;

//find out if we have an exact replica in the destination
var query = _.omit(newStack, ["parent", "quantity"]);
query["parent.collection"] = newStack.parent.collection;
query["parent.id"] = newStack.parent.id;
query._id = {$ne: itemId}; //make sure we don't join it to itself
var existingStack = Items.findOne(query);
if (existingStack){
//increase the existing stack's size
Expand Down

0 comments on commit 43c4122

Please sign in to comment.