Harden the preCreate quantity increase to use source IDs in finding the item
This commit is contained in:
parent
55a64afe02
commit
b3e699bc32
3 changed files with 9 additions and 7 deletions
|
|
@ -15,9 +15,11 @@ export class DotDungeonActor extends Actor {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
async preItemEmbed(data) {
|
async preItemEmbed(item) {
|
||||||
let embedded = this.itemTypes[data.type].find(i => {
|
|
||||||
return i.name === data.name
|
// 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) {
|
if (embedded) {
|
||||||
await embedded.update({"system.quantity": embedded.system.quantity + 1});
|
await embedded.update({"system.quantity": embedded.system.quantity + 1});
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { DotDungeonItem } from "./GenericItem.mjs";
|
import { DotDungeonItem } from "./GenericItem.mjs";
|
||||||
|
|
||||||
export class Aspect extends DotDungeonItem {
|
export class Aspect extends DotDungeonItem {
|
||||||
async _preCreate(...args) {
|
async _preCreate() {
|
||||||
if (this.isEmbedded) {
|
if (this.isEmbedded) {
|
||||||
if (this.actor.atAspectLimit) {
|
if (this.actor.atAspectLimit) {
|
||||||
ui.notifications.error(
|
ui.notifications.error(
|
||||||
|
|
@ -14,7 +14,7 @@ export class Aspect extends DotDungeonItem {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
return await this.actor?.preItemEmbed(...args);
|
return await this.actor?.preItemEmbed(this);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
export class DotDungeonItem extends Item {
|
export class DotDungeonItem extends Item {
|
||||||
async _preCreate(...args) {
|
async _preCreate() {
|
||||||
if (this.isEmbedded) {
|
if (this.isEmbedded) {
|
||||||
return await this.actor?.preItemEmbed(...args);
|
return await this.actor?.preItemEmbed(this);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue