Harden the preCreate quantity increase to use source IDs in finding the item

This commit is contained in:
Oliver-Akins 2024-03-22 21:47:29 -06:00
parent 55a64afe02
commit b3e699bc32
3 changed files with 9 additions and 7 deletions

View file

@ -15,9 +15,11 @@ export class DotDungeonActor extends Actor {
};
};
async preItemEmbed(data) {
let embedded = this.itemTypes[data.type].find(i => {
return i.name === data.name
async preItemEmbed(item) {
// Increases the quantity of already present items if they match via source
let embedded = this.itemTypes[item.type].find(i => {
return i.getFlag(`core`, `sourceId`) === `Item.${item.id}`
});
if (embedded) {
await embedded.update({"system.quantity": embedded.system.quantity + 1});