Skip to content

Commit 668b48c

Browse files
Worked on #86. Added edge cases for stacking.
1 parent 534f642 commit 668b48c

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

app/scripts/services/dimBungieService.factory.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@
442442
membershipType: membershipType,
443443
itemId: item.id,
444444
itemReferenceHash: item.hash,
445-
stackSize: item.amount,
445+
stackSize: (_.has(item, 'moveAmount') && item.moveAmount > 0) ? item.moveAmount : item.amount,
446446
transferToVault: (store.id === 'vault')
447447
},
448448
dataType: 'json',

app/scripts/services/dimItemService.factory.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@
2222
return (item.index === i.index);
2323
});
2424

25-
if (item.maxStackSize > 1) {
26-
// Balance the stacks.
27-
28-
if (item.moveAmount && item.moveAmount > 0) {
25+
if (item.maxStackSize > 1 && item.amount < item.maxStackSize) { // Balance the stacks.
26+
if (_.has(item, 'moveAmount') && (item.moveAmount > 0)) {
2927
matchingItem = _.reduce(source.items, function(memo, i) {
3028
if (item.hash === i.hash) {
3129
if (!(_.has(i, 'moveAmount')) || ((_.has(i, 'moveAmount') && i.moveAmount === 0))) {
@@ -41,9 +39,12 @@
4139
}, null);
4240

4341
if (!_.isNull(matchingItem)) {
44-
matchingItem.amount = matchingItem.amount - item.amount;
42+
if (item.moveAmount > item.amount) {
43+
matchingItem.amount = matchingItem.amount + (item.amount - item.moveAmount);
44+
}
4545
}
4646

47+
item.amount = item.moveAmount;
4748
item.moveAmount = 0;
4849
}
4950

@@ -250,9 +251,9 @@
250251
.then(function(source) {
251252
scope.source = source;
252253

253-
if (item.moveAmount && item.amount === 0) {
254-
item.amount = item.moveAmount;
255-
}
254+
// if (_.has(item, 'moveAmount') && (item.moveAmount > 0)) {
255+
// item.amount = item.moveAmount;
256+
// }
256257

257258
return dimBungieService.transfer(item, scope.target);
258259
})

0 commit comments

Comments
 (0)