diff --git a/html/app.js b/html/app.js index 1b885987..ae83097e 100644 --- a/html/app.js +++ b/html/app.js @@ -240,6 +240,8 @@ const InventoryContainer = Vue.createApp({ moveItemBetweenInventories(item, sourceInventoryType) { const sourceInventory = sourceInventoryType === "player" ? this.playerInventory : this.otherInventory; const targetInventory = sourceInventoryType === "player" ? this.otherInventory : this.playerInventory; + const targetWeight = sourceInventoryType === "player" ? this.otherInventoryWeight : this.playerWeight ; + const maxTargetWeight = sourceInventoryType === "player" ? this.otherInventoryMaxWeight : this.maxWeight ; const amountToTransfer = this.transferAmount !== null ? this.transferAmount : 1; let targetSlot = null; @@ -248,9 +250,10 @@ const InventoryContainer = Vue.createApp({ this.inventoryError(item.slot); return; } + + const totalWeightAfterTransfer = targetWeight + sourceItem.weight * amountToTransfer; - const totalWeightAfterTransfer = this.otherInventoryWeight + sourceItem.weight * amountToTransfer; - if (totalWeightAfterTransfer > this.otherInventoryMaxWeight) { + if (totalWeightAfterTransfer > maxTargetWeight) { this.inventoryError(item.slot); return; }