- Fix on self item dropped in own sheet: do not add qty

This commit is contained in:
Vlyan
2021-05-29 13:34:47 +02:00
parent a051bf281b
commit 64ca1abd8b

View File

@@ -175,15 +175,8 @@ export class BaseSheetL5r5e extends ActorSheet {
// Dropped a item with same "id" as one owned // Dropped a item with same "id" as one owned
if (this.actor.data.items) { if (this.actor.data.items) {
if (item.data.data.quantity) { // Exit if we already owned exactly this id (drag a personal item on our own sheet)
// Add quantity instead if they have (id is different so use type and name) if (
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 (
this.actor.data.items.some((embedItem) => { this.actor.data.items.some((embedItem) => {
// Search in children // Search in children
if (embedItem.items?.has(item.data._id)) { if (embedItem.items?.has(item.data._id)) {
@@ -192,9 +185,18 @@ export class BaseSheetL5r5e extends ActorSheet {
return embedItem.data._id === item.data._id; return embedItem.data._id === item.data._id;
}) })
) { ) {
// Exit if we already owned exactly this id (drag a personal item on our own sheet)
return; 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 // Item subtype specific