Compare commits

...

3 commits

Author SHA1 Message Date
Carlos Fernandez
43805331ad Use compendium source over actual uuid in search 2026-05-03 19:22:50 -04:00
Carlos Fernandez
210978fd87 Rerender class sheets when subclass link is changed 2026-05-03 18:44:48 -04:00
WBHarry
533421abba Fixed character creation 2026-05-03 21:47:15 +02:00
4 changed files with 14 additions and 5 deletions

View file

@ -439,10 +439,13 @@ export default class DhCharacterCreation extends HandlebarsApplicationMixin(Appl
'system.domain': { key: 'system.domain', value: this.setup.class?.system.domains ?? null } 'system.domain': { key: 'system.domain', value: this.setup.class?.system.domains ?? null }
}; };
if (type === 'subclasses') if (type === 'subclasses') {
const classItem = this.setup.class;
const uuid = classItem?._stats.compendiumSource ?? classItem?.uuid;
presets.filter = { presets.filter = {
'system.linkedClass.uuid': { key: 'system.linkedClass.uuid', value: this.setup.class?.uuid } 'system.linkedClass': { key: 'system.linkedClass', value: uuid }
}; };
}
if (equipment.includes(type)) if (equipment.includes(type))
presets.filter = { presets.filter = {
@ -610,7 +613,8 @@ export default class DhCharacterCreation extends HandlebarsApplicationMixin(Appl
[foundry.utils.randomID()]: {} [foundry.utils.randomID()]: {}
}; };
} else if (item.type === 'subclass' && event.target.closest('.subclass-card')) { } else if (item.type === 'subclass' && event.target.closest('.subclass-card')) {
if (this.setup.class.system.subclasses.every(subclass => subclass.uuid !== item.uuid)) { const classSubclasses = await this.setup.class.system.fetchSubclasses();
if (classSubclasses.every(subclass => subclass.uuid !== item.uuid)) {
ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.subclassNotInClass')); ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.subclassNotInClass'));
return; return;
} }

View file

@ -62,6 +62,10 @@ export default class SubclassSheet extends DHBaseItemSheet {
const uuid = item._stats.compendiumSource ?? item.uuid; const uuid = item._stats.compendiumSource ?? item.uuid;
if (this.document.system.linkedClass !== uuid) { if (this.document.system.linkedClass !== uuid) {
await this.document.update({ 'system.linkedClass': uuid }); await this.document.update({ 'system.linkedClass': uuid });
// Re-render all class sheets for instant feedback
for (const app of foundry.applications.instances.values()) {
if (app.document?.type === 'class') app.render();
}
} }
return; return;
} }

View file

@ -200,7 +200,7 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
const features = []; const features = [];
for (let f of this.features) { for (let f of this.features) {
const fBase = f.item ?? f; const fBase = f.item ?? f;
const feature = fBase.system ? fBase : await foundry.utils.fromUuid(fBase.uuid); const feature = fBase.pack ? await foundry.utils.fromUuid(fBase.uuid) : fBase;
features.push( features.push(
foundry.utils.mergeObject( foundry.utils.mergeObject(
feature.toObject(), feature.toObject(),

View file

@ -83,7 +83,8 @@ export default class DHSubclass extends BaseDataItem {
ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.missingClass')); ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.missingClass'));
return false; return false;
} }
if (actorClass.system.subclasses.every(x => x.uuid !== dataUuid)) {
if ((await actorClass.system.fetchSubclasses()).every(x => x.uuid !== dataUuid)) {
ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.subclassNotInClass')); ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.subclassNotInClass'));
return false; return false;
} }