Added PreCreate/Create/Delete logic for Class/Subclass and set it as foreignUUID fields in PC

This commit is contained in:
WBHarry 2025-06-07 15:17:16 +02:00
parent 53be047e12
commit a5aa2e914d
11 changed files with 177 additions and 167 deletions

View file

@ -198,15 +198,11 @@ export default class ClassSheet extends DaggerheartSheet(ItemSheetV2) {
const item = await fromUuid(data.uuid);
if (item.type === 'subclass') {
await this.document.update({
'system.subclasses': [
...this.document.system.subclasses, item.uuid
]
'system.subclasses': item.uuid
});
} else if (item.type === 'feature') {
await this.document.update({
'system.features': [
...this.document.system.features, item.uuid
]
'system.features': [...this.document.system.features, item.uuid]
});
} else if (item.type === 'weapon') {
if (event.currentTarget.classList.contains('primary-weapon-section')) {
@ -231,25 +227,19 @@ export default class ClassSheet extends DaggerheartSheet(ItemSheetV2) {
if (item.type === 'miscellaneous' || item.type === 'consumable') {
if (this.document.system.inventory.choiceA.length < 2)
await this.document.update({
'system.inventory.choiceA': [
...this.document.system.inventory.choiceA, item.uuid
]
'system.inventory.choiceA': [...this.document.system.inventory.choiceA, item.uuid]
});
}
} else if (item.type === 'miscellaneous') {
if (event.currentTarget.classList.contains('take-section')) {
if (this.document.system.inventory.take.length < 3)
await this.document.update({
'system.inventory.take': [
...this.document.system.inventory.take, item.uuid
]
'system.inventory.take': [...this.document.system.inventory.take, item.uuid]
});
} else if (event.currentTarget.classList.contains('choice-b-section')) {
if (this.document.system.inventory.choiceB.length < 2)
await this.document.update({
'system.inventory.choiceB': [
...this.document.system.inventory.choiceB, item.uuid
]
'system.inventory.choiceB': [...this.document.system.inventory.choiceB, item.uuid]
});
}
}