[Fix] Improve Class-Subclass Linkage (#1846)
Some checks failed
Project CI / build (24.x) (push) Has been cancelled

* Initial thoughts

* .

* Fixed linting

* Continue work on updating identifier

* Change to uuid approach

* Localization and minor fix

* Fixed CompendiumBrowser Class filter for Subclass view

* Fixed the class name display in the subclass view

* Improved missing class visual for subclass

* Fixed character creation

* Rerender class sheets when subclass link is changed

* Use compendium source over actual uuid in search

---------

Co-authored-by: Carlos Fernandez <cfern1990@gmail.com>
This commit is contained in:
WBHarry 2026-05-05 22:15:21 +02:00 committed by GitHub
parent fb5e3672dc
commit b7bc452bf5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 167 additions and 84 deletions

View file

@ -30,7 +30,6 @@ export default class DHClass extends BaseDataItem {
}),
evasion: new fields.NumberField({ initial: 0, integer: true, label: 'DAGGERHEART.GENERAL.evasion' }),
features: new ItemLinkFields(),
subclasses: new ForeignDocumentUUIDArrayField({ type: 'Item', required: false }),
inventory: new fields.SchemaField({
take: new ForeignDocumentUUIDArrayField({ type: 'Item', required: false }),
choiceA: new ForeignDocumentUUIDArrayField({ type: 'Item', required: false }),
@ -70,6 +69,24 @@ export default class DHClass extends BaseDataItem {
return this.features.filter(x => x.type === CONFIG.DH.ITEM.featureSubTypes.class).map(x => x.item);
}
async fetchSubclasses() {
const uuids = [this.parent.uuid, this.parent._stats?.compendiumSource].filter(u => !!u);
const subclasses = game.items.filter(x => x.type === 'subclass' && uuids.includes(x.system.linkedClass));
for (const pack of game.packs) {
const indexes = await pack.getIndex({ fields: ['system.linkedClass'] });
for (const index of indexes) {
if (index.type !== 'subclass') continue;
if (!uuids.includes(index.system?.linkedClass)) continue;
if (subclasses.find(x => x.uuid === index.uuid)) continue;
const subclass = await foundry.utils.fromUuid(index.uuid);
subclasses.push(subclass);
}
}
return subclasses;
}
async _preCreate(data, options, user) {
if (this.actor?.type === 'character') {
const levelupAuto = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Automation).levelupAuto;