From 64ca1abd8b1d7702a6c6062b250a14fafb72b952 Mon Sep 17 00:00:00 2001 From: Vlyan Date: Sat, 29 May 2021 13:34:47 +0200 Subject: [PATCH] - Fix on self item dropped in own sheet: do not add qty --- system/scripts/actors/base-sheet.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/system/scripts/actors/base-sheet.js b/system/scripts/actors/base-sheet.js index f6054f3..f0d291d 100644 --- a/system/scripts/actors/base-sheet.js +++ b/system/scripts/actors/base-sheet.js @@ -175,15 +175,8 @@ export class BaseSheetL5r5e extends ActorSheet { // Dropped a item with same "id" as one owned if (this.actor.data.items) { - if (item.data.data.quantity) { - // Add quantity instead if they have (id is different so use type and name) - const tmpItem = this.actor.data.items.find( - (embedItem) => embedItem.name === item.data.name && embedItem.type === item.data.type - ); - if (tmpItem && this._modifyQuantity(tmpItem.id, 1)) { - return; - } - } else if ( + // Exit if we already owned exactly this id (drag a personal item on our own sheet) + if ( this.actor.data.items.some((embedItem) => { // Search in children if (embedItem.items?.has(item.data._id)) { @@ -192,9 +185,18 @@ export class BaseSheetL5r5e extends ActorSheet { return embedItem.data._id === item.data._id; }) ) { - // Exit if we already owned exactly this id (drag a personal item on our own sheet) return; } + + // Add quantity instead if they have (id is different so use type and name) + if (item.data.data.quantity) { + const tmpItem = this.actor.data.items.find( + (embedItem) => embedItem.name === item.data.name && embedItem.type === item.data.type + ); + if (tmpItem && this._modifyQuantity(tmpItem.id, 1)) { + return; + } + } } // Item subtype specific