mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-17 15:39:02 +01:00
Improved item-identicial check
This commit is contained in:
parent
5d0a59bd12
commit
3c9bbf770c
2 changed files with 10 additions and 3 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { itemIsIdentical } from '../../../helpers/utils.mjs';
|
||||||
import DHBaseActorSettings from './actor-setting.mjs';
|
import DHBaseActorSettings from './actor-setting.mjs';
|
||||||
import DHApplicationMixin from './application-mixin.mjs';
|
import DHApplicationMixin from './application-mixin.mjs';
|
||||||
|
|
||||||
|
|
@ -248,9 +249,7 @@ export default class DHBaseActorSheet extends DHApplicationMixin(ActorSheetV2) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const existingItem = this.document.items.find(
|
const existingItem = this.document.items.find(x => itemIsIdentical(x, dropDocument));
|
||||||
x => x._stats.compendiumSource === actorItem._stats.compendiumSource
|
|
||||||
);
|
|
||||||
if (existingItem) {
|
if (existingItem) {
|
||||||
cancel = true;
|
cancel = true;
|
||||||
await existingItem.update({
|
await existingItem.update({
|
||||||
|
|
|
||||||
|
|
@ -437,3 +437,11 @@ export function shuffleArray(array) {
|
||||||
|
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function itemIsIdentical(a, b) {
|
||||||
|
const compendiumSource = a._stats.compendiumSource === b._stats.compendiumSource;
|
||||||
|
const name = a.name === b.name;
|
||||||
|
const description = a.system.description === b.system.description;
|
||||||
|
|
||||||
|
return compendiumSource && name & description;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue