mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-17 07:36:26 +01:00
Feature(Item) now has subtype instead of primary as a field
This commit is contained in:
parent
e9967a27ca
commit
e2ca4506cd
5 changed files with 28 additions and 10 deletions
|
|
@ -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]
|
||||
|
|
|
|||
|
|
@ -1320,6 +1320,11 @@ export const featureTypes = {
|
|||
}
|
||||
};
|
||||
|
||||
export const featureSubTypes = {
|
||||
primary: 'primary',
|
||||
secondary: 'secondary'
|
||||
};
|
||||
|
||||
export const actionTypes = {
|
||||
passive: {
|
||||
id: 'passive',
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,10 @@
|
|||
data-group='{{tabs.features.group}}'
|
||||
>
|
||||
<fieldset class="one-column drop-section primary-feature">
|
||||
<legend>{{localize "DAGGERHEART.ITEMS.Ancestry.primaryFeature"}} <a><i data-action="addFeature" data-type="primary" class="fa-solid fa-plus icon-button"></i></a></legend>
|
||||
<legend>
|
||||
{{localize "DAGGERHEART.ITEMS.Ancestry.primaryFeature"}}
|
||||
{{#unless document.system.primaryFeature}}<a><i data-action="addFeature" data-type="primary" class="fa-solid fa-plus icon-button"></i></a>{{/unless}}
|
||||
</legend>
|
||||
<div class="features-list">
|
||||
{{#if document.system.primaryFeature}}
|
||||
<div class="feature-item"
|
||||
|
|
@ -22,7 +25,10 @@
|
|||
</fieldset>
|
||||
|
||||
<fieldset class="one-column drop-section secondary-feature">
|
||||
<legend>{{localize "DAGGERHEART.ITEMS.Ancestry.secondaryFeature"}} <a><i data-action="addFeature" data-type="secondary" class="fa-solid fa-plus icon-button"></i></a></legend>
|
||||
<legend>
|
||||
{{localize "DAGGERHEART.ITEMS.Ancestry.secondaryFeature"}}
|
||||
{{#unless document.system.secondaryFeature}}<a><i data-action="addFeature" data-type="secondary" class="fa-solid fa-plus icon-button"></i></a>{{/unless}}
|
||||
</legend>
|
||||
<div class="features-list">
|
||||
{{#if document.system.secondaryFeature}}
|
||||
<div class="feature-item"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue