diff --git a/module/applications/sheets/items/ancestry.mjs b/module/applications/sheets/items/ancestry.mjs index 577cc7cd..bd9e3792 100644 --- a/module/applications/sheets/items/ancestry.mjs +++ b/module/applications/sheets/items/ancestry.mjs @@ -32,7 +32,7 @@ export default class AncestrySheet extends DHHeritageSheet { type: 'feature', name: game.i18n.format('DOCUMENT.New', { type: game.i18n.localize('TYPES.Item.feature') }), system: { - primary: button.dataset.type === 'primary' + subType: button.dataset.type } }); await this.document.update({ @@ -100,9 +100,8 @@ export default class AncestrySheet extends DHHeritageSheet { const item = await fromUuid(data.uuid); if (item?.type === 'feature') { - if (event.target.closest('.primary-feature')) { - await item.update({ 'system.primary': true }); - } + const subType = event.target.closest('.primary-feature') ? 'primary' : 'secondary'; + await item.update({ 'system.subType': subType }); await this.document.update({ 'system.features': [...this.document.system.features.map(x => x.uuid), item.uuid] diff --git a/module/config/itemConfig.mjs b/module/config/itemConfig.mjs index cdc8a235..1d791b46 100644 --- a/module/config/itemConfig.mjs +++ b/module/config/itemConfig.mjs @@ -1320,6 +1320,11 @@ export const featureTypes = { } }; +export const featureSubTypes = { + primary: 'primary', + secondary: 'secondary' +}; + export const actionTypes = { passive: { id: 'passive', diff --git a/module/data/item/ancestry.mjs b/module/data/item/ancestry.mjs index fdc67a97..71b7683d 100644 --- a/module/data/item/ancestry.mjs +++ b/module/data/item/ancestry.mjs @@ -20,10 +20,18 @@ export default class DHAncestry extends BaseDataItem { } get primaryFeature() { - return this.features.find(x => x?.system?.primary) ?? (this.features.length > 0 ? {} : null); + return ( + this.features.find(x => x?.system?.subType === CONFIG.DH.ITEM.featureSubTypes.primary) ?? + (this.features.filter(x => !x).length > 0 ? {} : null) + ); } get secondaryFeature() { - return this.features.find(x => !x?.system?.primary); + return ( + this.features.find(x => x?.system?.subType === CONFIG.DH.ITEM.featureSubTypes.secondary) ?? + (this.features.filter(x => !x || x.system.subType === CONFIG.DH.ITEM.featureSubTypes.primary).length > 1 + ? {} + : null) + ); } } diff --git a/module/data/item/feature.mjs b/module/data/item/feature.mjs index 6a9b4010..40ec616c 100644 --- a/module/data/item/feature.mjs +++ b/module/data/item/feature.mjs @@ -17,10 +17,10 @@ export default class DHFeature extends BaseDataItem { return { ...super.defineSchema(), type: new fields.StringField({ choices: CONFIG.DH.ITEM.featureTypes, nullable: true, initial: null }), + subType: new fields.StringField({ choices: CONFIG.DH.ITEM.featureSubTypes, nullable: true, initial: null }), originId: new fields.StringField({ nullable: true, initial: null }), identifier: new fields.StringField(), - actions: new fields.ArrayField(new ActionField()), - primary: new fields.BooleanField({ nullable: true, initial: null }) + actions: new fields.ArrayField(new ActionField()) }; } } diff --git a/templates/sheets/items/ancestry/features.hbs b/templates/sheets/items/ancestry/features.hbs index 9f1694b6..6bc108b1 100644 --- a/templates/sheets/items/ancestry/features.hbs +++ b/templates/sheets/items/ancestry/features.hbs @@ -4,7 +4,10 @@ data-group='{{tabs.features.group}}' >