mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-17 15:39:02 +01:00
Subclass now uses a simple Features field
This commit is contained in:
parent
a370a97d8d
commit
9f9ed73bdf
10 changed files with 102 additions and 57 deletions
|
|
@ -1325,8 +1325,8 @@
|
||||||
},
|
},
|
||||||
"DomainCard": {
|
"DomainCard": {
|
||||||
"type": "Type",
|
"type": "Type",
|
||||||
"foundation": "Foundation",
|
|
||||||
"recallCost": "Recall Cost",
|
"recallCost": "Recall Cost",
|
||||||
|
"foundationTitle": "Foundation",
|
||||||
"specializationTitle": "Specialization",
|
"specializationTitle": "Specialization",
|
||||||
"masteryTitle": "Mastery"
|
"masteryTitle": "Mastery"
|
||||||
},
|
},
|
||||||
|
|
@ -1541,7 +1541,10 @@
|
||||||
"featureNotHope": "This feature is used as something else than a Hope feature and cannot be used here.",
|
"featureNotHope": "This feature is used as something else than a Hope feature and cannot be used here.",
|
||||||
"featureNotClass": "This feature is used as something else than a Class feature and cannot be used here.",
|
"featureNotClass": "This feature is used as something else than a Class feature and cannot be used here.",
|
||||||
"featureNotPrimary": "This feature is used as something else than a Primary feature and cannot be used here.",
|
"featureNotPrimary": "This feature is used as something else than a Primary feature and cannot be used here.",
|
||||||
"featureNotSecondary": "This feature is used as something else than a Secondary feature and cannot be used here."
|
"featureNotSecondary": "This feature is used as something else than a Secondary feature and cannot be used here.",
|
||||||
|
"featureNotFoundation": "This feature is used as something else than a Foundation feature and cannot be used here.",
|
||||||
|
"featureNotSpecialization": "This feature is used as something else than a Specialization feature and cannot be used here.",
|
||||||
|
"featureNotMastery": "This feature is used as something else than a Mastery feature and cannot be used here."
|
||||||
},
|
},
|
||||||
"Tooltip": {
|
"Tooltip": {
|
||||||
"openItemWorld": "Open Item World",
|
"openItemWorld": "Open Item World",
|
||||||
|
|
|
||||||
|
|
@ -506,9 +506,7 @@ export default class DhCharacterCreation extends HandlebarsApplicationMixin(Appl
|
||||||
name: this.setup.ancestryName ?? this.setup.primaryAncestry.name,
|
name: this.setup.ancestryName ?? this.setup.primaryAncestry.name,
|
||||||
system: {
|
system: {
|
||||||
...this.setup.primaryAncestry.system,
|
...this.setup.primaryAncestry.system,
|
||||||
features: [primaryAncestryFeature.uuid, secondaryAncestryFeature.uuid],
|
features: [primaryAncestryFeature.uuid, secondaryAncestryFeature.uuid]
|
||||||
primaryFeature: primaryAncestryFeature.uuid,
|
|
||||||
secondaryFeature: secondaryAncestryFeature.uuid
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,28 +40,46 @@ export default class SubclassSheet extends DHBaseItemSheet {
|
||||||
static async addFeature(_, target) {
|
static async addFeature(_, target) {
|
||||||
const feature = await game.items.documentClass.create({
|
const feature = await game.items.documentClass.create({
|
||||||
type: 'feature',
|
type: 'feature',
|
||||||
name: game.i18n.format('DOCUMENT.New', { type: game.i18n.localize('TYPES.Item.feature') })
|
name: game.i18n.format('DOCUMENT.New', { type: game.i18n.localize('TYPES.Item.feature') }),
|
||||||
|
system: {
|
||||||
|
subType:
|
||||||
|
target.dataset.type === 'foundation'
|
||||||
|
? CONFIG.DH.ITEM.featureSubTypes.foundation
|
||||||
|
: target.dataset.type === 'specialization'
|
||||||
|
? CONFIG.DH.ITEM.featureSubTypes.specialization
|
||||||
|
: CONFIG.DH.ITEM.featureSubTypes.mastery
|
||||||
|
}
|
||||||
});
|
});
|
||||||
await this.document.update({
|
await this.document.update({
|
||||||
[`system.${target.dataset.type}`]: feature.uuid
|
[`system.features`]: [...this.document.system.features.map(x => x.uuid), feature.uuid]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static async editFeature(_, button) {
|
static async editFeature(_, button) {
|
||||||
const feature = this.document.system[button.dataset.type];
|
const feature = this.document.system.features.find(x => x.id === button.dataset.feature);
|
||||||
if (!feature) {
|
if (!feature) {
|
||||||
ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.featureIsMissing'));
|
ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.featureIsMissing'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (feature) {
|
||||||
|
await feature.update({ 'system.subType': null });
|
||||||
|
}
|
||||||
|
|
||||||
feature.sheet.render(true);
|
feature.sheet.render(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static async deleteFeature(event, button) {
|
static async deleteFeature(event, target) {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
const feature = this.document.system.features.find(feature => feature.id === target.dataset.feature);
|
||||||
|
if (feature) {
|
||||||
|
await feature.update({ 'system.subType': null });
|
||||||
|
}
|
||||||
|
|
||||||
await this.document.update({
|
await this.document.update({
|
||||||
[`system.${button.dataset.type}`]: null
|
[`system.features`]: this.document.system.features
|
||||||
|
.filter(feature => feature && feature.id !== target.dataset.feature)
|
||||||
|
.map(x => x.uuid)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -82,18 +100,45 @@ export default class SubclassSheet extends DHBaseItemSheet {
|
||||||
}
|
}
|
||||||
|
|
||||||
async _onDrop(event) {
|
async _onDrop(event) {
|
||||||
|
event.stopPropagation();
|
||||||
|
|
||||||
const data = foundry.applications.ux.TextEditor.implementation.getDragEventData(event);
|
const data = foundry.applications.ux.TextEditor.implementation.getDragEventData(event);
|
||||||
if (data.fromInternal) return;
|
if (data.fromInternal) return;
|
||||||
|
|
||||||
const item = await fromUuid(data.uuid);
|
const item = await fromUuid(data.uuid);
|
||||||
if (item?.type === 'feature') {
|
const target = event.target.closest('fieldset.drop-section');
|
||||||
const dropSection = event.target.closest('.drop-section');
|
if (item.type === 'feature') {
|
||||||
if (this.document.system[dropSection.dataset.type]) {
|
if (target.dataset.type === 'foundation') {
|
||||||
ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.notifications.featureIsFull'));
|
if (item.system.subType && item.system.subType !== CONFIG.DH.ITEM.featureSubTypes.foundation) {
|
||||||
return;
|
ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.featureNotFoundation'));
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
await this.document.update({ [`system.${dropSection.dataset.type}`]: item.uuid });
|
await item.update({ 'system.subType': CONFIG.DH.ITEM.featureSubTypes.foundation });
|
||||||
|
await this.document.update({
|
||||||
|
'system.features': [...this.document.system.features.map(x => x.uuid), item.uuid]
|
||||||
|
});
|
||||||
|
} else if (target.dataset.type === 'specialization') {
|
||||||
|
if (item.system.subType && item.system.subType !== CONFIG.DH.ITEM.featureSubTypes.specialization) {
|
||||||
|
ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.featureNotSpecialization'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await item.update({ 'system.subType': CONFIG.DH.ITEM.featureSubTypes.specialization });
|
||||||
|
await this.document.update({
|
||||||
|
'system.features': [...this.document.system.features.map(x => x.uuid), item.uuid]
|
||||||
|
});
|
||||||
|
} else if (target.dataset.type === 'mastery') {
|
||||||
|
if (item.system.subType && item.system.subType !== CONFIG.DH.ITEM.featureSubTypes.mastery) {
|
||||||
|
ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.featureNotMastery'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await item.update({ 'system.subType': CONFIG.DH.ITEM.featureSubTypes.mastery });
|
||||||
|
await this.document.update({
|
||||||
|
'system.features': [...this.document.system.features.map(x => x.uuid), item.uuid]
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -411,7 +411,7 @@ export const levelupData = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const subclassFeatureLabels = {
|
export const subclassFeatureLabels = {
|
||||||
1: 'DAGGERHEART.ITEMS.DomainCard.foundation',
|
1: 'DAGGERHEART.ITEMS.DomainCard.foundationTitle',
|
||||||
2: 'DAGGERHEART.ITEMS.DomainCard.specializationTitle',
|
2: 'DAGGERHEART.ITEMS.DomainCard.specializationTitle',
|
||||||
3: 'DAGGERHEART.ITEMS.DomainCard.masteryTitle'
|
3: 'DAGGERHEART.ITEMS.DomainCard.masteryTitle'
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1324,7 +1324,10 @@ export const featureSubTypes = {
|
||||||
primary: 'primary',
|
primary: 'primary',
|
||||||
secondary: 'secondary',
|
secondary: 'secondary',
|
||||||
hope: 'hope',
|
hope: 'hope',
|
||||||
class: 'class'
|
class: 'class',
|
||||||
|
foundation: 'foundation',
|
||||||
|
specialization: 'specialization',
|
||||||
|
mastery: 'mastery'
|
||||||
};
|
};
|
||||||
|
|
||||||
export const actionTypes = {
|
export const actionTypes = {
|
||||||
|
|
|
||||||
|
|
@ -122,12 +122,9 @@ export default class DhCharacter extends BaseDataActor {
|
||||||
label: 'DAGGERHEART.GENERAL.Range.other'
|
label: 'DAGGERHEART.GENERAL.Range.other'
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
rally: new fields.ArrayField(
|
rally: new fields.ArrayField(new fields.StringField(), {
|
||||||
new fields.StringField(),
|
label: 'DAGGERHEART.CLASS.Feature.rallyDice'
|
||||||
{
|
})
|
||||||
label: 'DAGGERHEART.CLASS.Feature.rallyDice'
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}),
|
}),
|
||||||
companion: new ForeignDocumentUUIDField({ type: 'Actor', nullable: true, initial: null }),
|
companion: new ForeignDocumentUUIDField({ type: 'Actor', nullable: true, initial: null }),
|
||||||
rules: new fields.SchemaField({
|
rules: new fields.SchemaField({
|
||||||
|
|
@ -258,11 +255,11 @@ export default class DhCharacter extends BaseDataActor {
|
||||||
classFeatures.push(item);
|
classFeatures.push(item);
|
||||||
} else if (item.system.type === CONFIG.DH.ITEM.featureTypes.subclass.id) {
|
} else if (item.system.type === CONFIG.DH.ITEM.featureTypes.subclass.id) {
|
||||||
const subclassState = this.class.subclass.system.featureState;
|
const subclassState = this.class.subclass.system.featureState;
|
||||||
const identifier = item.system.identifier;
|
const subType = item.system.subType;
|
||||||
if (
|
if (
|
||||||
identifier === 'foundationFeature' ||
|
subType === CONFIG.DH.ITEM.featureSubTypes.foundation ||
|
||||||
(identifier === 'specializationFeature' && subclassState >= 2) ||
|
(subType === CONFIG.DH.ITEM.featureSubTypes.specialization && subclassState >= 2) ||
|
||||||
(identifier === 'masterFeature' && subclassState >= 3)
|
(subType === CONFIG.DH.ITEM.featureSubTypes.mastery && subclassState >= 3)
|
||||||
) {
|
) {
|
||||||
subclassFeatures.push(item);
|
subclassFeatures.push(item);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,6 @@ export default class DHDomainCard extends BaseDataItem {
|
||||||
required: true,
|
required: true,
|
||||||
initial: CONFIG.DH.DOMAIN.cardTypes.ability.id
|
initial: CONFIG.DH.DOMAIN.cardTypes.ability.id
|
||||||
}),
|
}),
|
||||||
foundation: new fields.BooleanField({ initial: false }),
|
|
||||||
inVault: new fields.BooleanField({ initial: false }),
|
inVault: new fields.BooleanField({ initial: false }),
|
||||||
actions: new fields.ArrayField(new ActionField())
|
actions: new fields.ArrayField(new ActionField())
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import ForeignDocumentUUIDField from '../fields/foreignDocumentUUIDField.mjs';
|
import ForeignDocumentUUIDArrayField from '../fields/foreignDocumentUUIDArrayField.mjs';
|
||||||
import BaseDataItem from './base.mjs';
|
import BaseDataItem from './base.mjs';
|
||||||
|
|
||||||
export default class DHSubclass extends BaseDataItem {
|
export default class DHSubclass extends BaseDataItem {
|
||||||
|
|
@ -22,20 +22,22 @@ export default class DHSubclass extends BaseDataItem {
|
||||||
nullable: true,
|
nullable: true,
|
||||||
initial: null
|
initial: null
|
||||||
}),
|
}),
|
||||||
foundationFeature: new ForeignDocumentUUIDField({ type: 'Item' }),
|
features: new ForeignDocumentUUIDArrayField({ type: 'Item' }),
|
||||||
specializationFeature: new ForeignDocumentUUIDField({ type: 'Item' }),
|
|
||||||
masteryFeature: new ForeignDocumentUUIDField({ type: 'Item' }),
|
|
||||||
featureState: new fields.NumberField({ required: true, initial: 1, min: 1 }),
|
featureState: new fields.NumberField({ required: true, initial: 1, min: 1 }),
|
||||||
isMulticlass: new fields.BooleanField({ initial: false })
|
isMulticlass: new fields.BooleanField({ initial: false })
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
get features() {
|
get foundationFeatures() {
|
||||||
return [
|
return this.features.filter(x => x.system.subType === CONFIG.DH.ITEM.featureSubTypes.foundation);
|
||||||
{ ...this.foundationFeature?.toObject(), identifier: 'foundationFeature' },
|
}
|
||||||
{ ...this.specializationFeature?.toObject(), identifier: 'specializationFeature' },
|
|
||||||
{ ...this.masteryFeature?.toObject(), identifier: 'masteryFeature' }
|
get specializationFeatures() {
|
||||||
];
|
return this.features.filter(x => x.system.subType === CONFIG.DH.ITEM.featureSubTypes.specialization);
|
||||||
|
}
|
||||||
|
|
||||||
|
get masteryFeatures() {
|
||||||
|
return this.features.filter(x => x.system.subType === CONFIG.DH.ITEM.featureSubTypes.mastery);
|
||||||
}
|
}
|
||||||
|
|
||||||
async _preCreate(data, options, user) {
|
async _preCreate(data, options, user) {
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,6 @@
|
||||||
|
|
||||||
<span>{{localize "DAGGERHEART.GENERAL.type"}}</span>
|
<span>{{localize "DAGGERHEART.GENERAL.type"}}</span>
|
||||||
{{formField systemFields.type value=source.system.type localize=true}}
|
{{formField systemFields.type value=source.system.type localize=true}}
|
||||||
<span>{{localize "DAGGERHEART.ITEMS.DomainCard.foundation"}}</span>
|
|
||||||
{{formField systemFields.foundation value=source.system.foundation }}
|
|
||||||
<span>{{localize "DAGGERHEART.GENERAL.Domain.single"}}</span>
|
<span>{{localize "DAGGERHEART.GENERAL.Domain.single"}}</span>
|
||||||
{{formField systemFields.domain value=source.system.domain localize=true}}
|
{{formField systemFields.domain value=source.system.domain localize=true}}
|
||||||
<span>{{localize "DAGGERHEART.GENERAL.level"}}</span>
|
<span>{{localize "DAGGERHEART.GENERAL.level"}}</span>
|
||||||
|
|
|
||||||
|
|
@ -3,42 +3,42 @@
|
||||||
data-tab='{{tabs.features.id}}'
|
data-tab='{{tabs.features.id}}'
|
||||||
data-group='{{tabs.features.group}}'
|
data-group='{{tabs.features.group}}'
|
||||||
>
|
>
|
||||||
<fieldset class="drop-section" data-type="foundationFeature">
|
<fieldset class="drop-section" data-type="foundation">
|
||||||
<legend>
|
<legend>
|
||||||
{{localize "DAGGERHEART.GENERAL.Tabs.foundation"}}
|
{{localize "DAGGERHEART.GENERAL.Tabs.foundation"}}
|
||||||
<a {{#if source.system.foundationFeature}}disabled{{/if}}><i data-action="addFeature" data-type="foundationFeature" class="fa-solid fa-plus icon-button {{#if source.system.foundationFeature}}disabled{{/if}}"></i></a>
|
<a><i data-action="addFeature" data-type="foundation" class="fa-solid fa-plus icon-button"></i></a>
|
||||||
</legend>
|
</legend>
|
||||||
|
|
||||||
<div class="feature-list">
|
<div class="feature-list">
|
||||||
{{#if source.system.foundationFeature}}
|
{{#each source.system.foundationFeatures as | feature | }}
|
||||||
{{> 'systems/daggerheart/templates/sheets/global/partials/feature-section-item.hbs' type='foundationFeature' feature=source.system.foundationFeature}}
|
{{> 'systems/daggerheart/templates/sheets/global/partials/feature-section-item.hbs' type='foundation' feature=feature}}
|
||||||
{{/if}}
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<fieldset class="drop-section" data-type="specializationFeature">
|
<fieldset class="drop-section" data-type="specialization">
|
||||||
<legend>
|
<legend>
|
||||||
{{localize "DAGGERHEART.GENERAL.Tabs.specialization"}}
|
{{localize "DAGGERHEART.GENERAL.Tabs.specialization"}}
|
||||||
<a {{#if source.system.specializationFeature}}disabled{{/if}}><i data-action="addFeature" data-type="specializationFeature" class="fa-solid fa-plus icon-button {{#if source.system.specializationFeature}}disabled{{/if}}"></i></a>
|
<a><i data-action="addFeature" data-type="specialization" class="fa-solid fa-plus icon-button"></i></a>
|
||||||
</legend>
|
</legend>
|
||||||
|
|
||||||
<div class="feature-list">
|
<div class="feature-list">
|
||||||
{{#if source.system.specializationFeature}}
|
{{#each source.system.specializationFeatures as | feature |}}
|
||||||
{{> 'systems/daggerheart/templates/sheets/global/partials/feature-section-item.hbs' type='specializationFeature' feature=source.system.specializationFeature}}
|
{{> 'systems/daggerheart/templates/sheets/global/partials/feature-section-item.hbs' type='specialization' feature=feature}}
|
||||||
{{/if}}
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<fieldset class="drop-section" data-type="masteryFeature">
|
<fieldset class="drop-section" data-type="mastery">
|
||||||
<legend>
|
<legend>
|
||||||
{{localize "DAGGERHEART.GENERAL.Tabs.mastery"}}
|
{{localize "DAGGERHEART.GENERAL.Tabs.mastery"}}
|
||||||
<a {{#if source.system.masteryFeature}}disabled{{/if}}><i data-action="addFeature" data-type="masteryFeature" class="fa-solid fa-plus icon-button {{#if source.system.masteryFeature}}disabled{{/if}}"></i></a>
|
<a><i data-action="addFeature" data-type="mastery" class="fa-solid fa-plus icon-button"></i></a>
|
||||||
</legend>
|
</legend>
|
||||||
|
|
||||||
<div class="feature-list">
|
<div class="feature-list">
|
||||||
{{#if source.system.masteryFeature}}
|
{{#each source.system.masteryFeatures as | feature |}}
|
||||||
{{> 'systems/daggerheart/templates/sheets/global/partials/feature-section-item.hbs' type='masteryFeature' feature=source.system.masteryFeature}}
|
{{> 'systems/daggerheart/templates/sheets/global/partials/feature-section-item.hbs' type='mastery' feature=feature}}
|
||||||
{{/if}}
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</section>
|
</section>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue