Skip to content

Commit

Permalink
Fixed swapping in same inventory checking total weight.
Browse files Browse the repository at this point in the history
  • Loading branch information
adhershmnair committed Aug 30, 2024
1 parent 404338f commit d5111cf
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions html/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,21 +447,21 @@ const InventoryContainer = Vue.createApp({
if (sourceItem.amount < amountToTransfer) {
throw new Error("Insufficient amount of item in source inventory");
}
if (targetInventoryType == "other")
{

if (targetInventoryType !== this.dragStartInventoryType) {
if (targetInventoryType == "other") {
const totalWeightAfterTransfer = this.otherInventoryWeight + sourceItem.weight * amountToTransfer;
if (totalWeightAfterTransfer > this.otherInventoryMaxWeight) {
throw new Error("Insufficient weight capacity in target inventory");
}
}
else if (targetInventoryType == "player")
{
else if (targetInventoryType == "player") {
const totalWeightAfterTransfer = this.playerWeight + sourceItem.weight * amountToTransfer;
if (totalWeightAfterTransfer > this.maxWeight) {
throw new Error("Insufficient weight capacity in player inventory");
}
}
}

const targetItem = targetInventory[targetSlotNumber];

Expand Down

0 comments on commit d5111cf

Please sign in to comment.