This commit is contained in:
WBHarry 2026-01-12 20:52:50 +01:00
parent 23a497bab8
commit 2e4d3de379
5 changed files with 90 additions and 44 deletions

View file

@ -266,23 +266,24 @@ export default class CharacterSheet extends DHBaseActorSheet {
async _prepareSidebarContext(context, _options) {
context.isDeath = this.document.system.deathMoveViable;
context.sidebarFavoritesEmpty = this.document.system.sidebarFavorites.length === 0;
context.showfavorites = !context.sidebarFavoritesEmpty || this.document.system.usedUnarmed;
const initialFavorites = this.document.system.usedUnarmed
? {
equipment: {
label: 'DAGGERHEART.GENERAL.equipment',
items: [{ type: 'attack', value: this.document.system.usedUnarmed }]
}
}
: {};
context.sidebarFavorites = this.document.system.sidebarFavorites.reduce((acc, item) => {
const type = item.type === 'domainCard' ? item.type : 'equipment';
const label = type === 'domainCard' ? 'DAGGERHEART.GENERAL.loadout' : 'DAGGERHEART.GENERAL.equipment';
if (!acc[type]) acc[type] = { label, items: [] };
acc[type].items.push({ type: item.type, value: item });
// const initialFavorites = this.document.system.usedUnarmed
// ? {
// equipment: {
// label: 'DAGGERHEART.GENERAL.equipment',
// items: [{ type: 'attack', value: this.document.system.usedUnarmed }]
// }
// }
// : {};
// context.sidebarFavorites = this.document.system.sidebarFavorites.reduce((acc, item) => {
// const type = item.type === 'domainCard' ? item.type : 'equipment';
// const label = type === 'domainCard' ? 'DAGGERHEART.GENERAL.loadout' : 'DAGGERHEART.GENERAL.equipment';
// if (!acc[type]) acc[type] = { label, items: [] };
// acc[type].items.push({ type: item.type, value: item });
return acc;
}, initialFavorites);
// return acc;
// }, initialFavorites);
}
/**

View file

@ -45,6 +45,26 @@ export default class DHDomainCard extends BaseDataItem {
/* -------------------------------------------- */
/**@inheritdoc */
async _preUpdate(data, options, user) {
const allowed = await super._preUpdate(data, options, user);
if (allowed === false) return;
if (this.parent.parent?.type === 'character') {
if (
data.system?.inVault &&
!this.inVault &&
this.parent.parent.system.sidebarFavorites.find(x => x?.id === this.parent.id)
) {
this.parent.parent.update({
'system.sidebarFavorites': this.parent.parent.system.sidebarFavorites.filter(
x => x.id !== this.parent.id
)
});
}
}
}
/**@inheritdoc */
async _preCreate(data, options, user) {
const allowed = await super._preCreate(data, options, user);