Skip to content

Commit

Permalink
Merge pull request #568 from adhershmnair/main
Browse files Browse the repository at this point in the history
Fixed swapping in same inventory checking total weight.
  • Loading branch information
GhzGarage authored Oct 17, 2024
2 parents 19197a2 + eb5eab4 commit ee02bf4
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 ee02bf4

Please sign in to comment.