mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
feat(subclassFeatures): fix adding abilities (#54)
* feat(subclassFeatures): fix adding abilities * fix(subclassFeatures): fix tabs names --------- Co-authored-by: JimCanE <6275508-jimcane@users.noreply.gitlab.com>
This commit is contained in:
parent
71319f2b74
commit
e135a44222
2 changed files with 40 additions and 25 deletions
|
|
@ -76,11 +76,14 @@ import DaggerheartSheet from './daggerheart-sheet.mjs';
|
||||||
import DaggerheartFeature from '../../data/feature.mjs';
|
import DaggerheartFeature from '../../data/feature.mjs';
|
||||||
|
|
||||||
const { ItemSheetV2 } = foundry.applications.sheets;
|
const { ItemSheetV2 } = foundry.applications.sheets;
|
||||||
|
const { TextEditor } = foundry.applications.ux;
|
||||||
|
const { duplicate, getProperty } = foundry.utils;
|
||||||
export default class SubclassSheet extends DaggerheartSheet(ItemSheetV2) {
|
export default class SubclassSheet extends DaggerheartSheet(ItemSheetV2) {
|
||||||
static DEFAULT_OPTIONS = {
|
static DEFAULT_OPTIONS = {
|
||||||
tag: 'form',
|
tag: 'form',
|
||||||
classes: ['daggerheart', 'sheet', 'subclass'],
|
classes: ['daggerheart', 'sheet', 'subclass'],
|
||||||
position: { width: 600 },
|
position: { width: 600, height: 600 },
|
||||||
|
window: { resizable: true },
|
||||||
actions: {
|
actions: {
|
||||||
editAbility: this.editAbility,
|
editAbility: this.editAbility,
|
||||||
deleteFeatureAbility: this.deleteFeatureAbility
|
deleteFeatureAbility: this.deleteFeatureAbility
|
||||||
|
|
@ -180,28 +183,22 @@ export default class SubclassSheet extends DaggerheartSheet(ItemSheetV2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async _onDrop(event) {
|
async _onDrop(event) {
|
||||||
|
event.preventDefault()
|
||||||
const data = TextEditor.getDragEventData(event);
|
const data = TextEditor.getDragEventData(event);
|
||||||
const item = await fromUuid(data.uuid);
|
const item = await fromUuid(data.uuid);
|
||||||
if (item.type === 'feature' && item.system.type === SYSTEM.ITEM.featureTypes.subclass.id) {
|
if (!(item.type === 'feature' && item.system.type === SYSTEM.ITEM.featureTypes.subclass.id)) return;
|
||||||
if (event.currentTarget.classList.contains('foundation-tab')) {
|
|
||||||
await this.document.update({
|
let featureField;
|
||||||
'system.foundationFeature.abilities': [
|
if (event.currentTarget.classList.contains('foundation-tab')) featureField = 'foundation';
|
||||||
...this.document.system.foundationFeature.abilities,
|
else if (event.currentTarget.classList.contains('specialization-tab')) featureField = 'specialization';
|
||||||
item.system
|
else if (event.currentTarget.classList.contains('mastery-tab')) featureField = 'mastery';
|
||||||
]
|
else return;
|
||||||
});
|
|
||||||
} else if (event.currentTarget.classList.contains('specialization-tab')) {
|
const path = `system.${featureField}Feature.abilities`;
|
||||||
await this.document.update({
|
const abilities = duplicate(getProperty(this.document, path)) || [];
|
||||||
'system.specializationFeature.abilities': [
|
const featureData = {name: item.name, img: item.img, uuid: item.uuid };
|
||||||
...this.document.system.specializationFeature.abilities,
|
abilities.push(featureData);
|
||||||
data.system
|
|
||||||
]
|
await this.document.update({ [path]: abilities });
|
||||||
});
|
|
||||||
} else if (event.currentTarget.classList.contains('mastery-tab')) {
|
|
||||||
await this.document.update({
|
|
||||||
'system.masteryFeature.abilities': [...this.document.system.masteryFeature.abilities, data.system]
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,19 +15,37 @@ export default class DhpSubclass extends foundry.abstract.TypeDataModel {
|
||||||
}),
|
}),
|
||||||
foundationFeature: new fields.SchemaField({
|
foundationFeature: new fields.SchemaField({
|
||||||
description: new fields.HTMLField({}),
|
description: new fields.HTMLField({}),
|
||||||
abilities: new fields.ArrayField(new fields.EmbeddedDataField(DaggerheartFeature))
|
abilities: new fields.ArrayField(
|
||||||
|
new fields.SchemaField({
|
||||||
|
name: new fields.StringField({}),
|
||||||
|
img: new fields.StringField({}),
|
||||||
|
uuid: new fields.StringField({})
|
||||||
|
})
|
||||||
|
)
|
||||||
}),
|
}),
|
||||||
specializationFeature: new fields.SchemaField({
|
specializationFeature: new fields.SchemaField({
|
||||||
unlocked: new fields.BooleanField({ initial: false }),
|
unlocked: new fields.BooleanField({ initial: false }),
|
||||||
tier: new fields.NumberField({ initial: null, nullable: true, integer: true }),
|
tier: new fields.NumberField({ initial: null, nullable: true, integer: true }),
|
||||||
description: new fields.HTMLField({}),
|
description: new fields.HTMLField({}),
|
||||||
abilities: new fields.ArrayField(new fields.EmbeddedDataField(DaggerheartFeature))
|
abilities: new fields.ArrayField(
|
||||||
|
new fields.SchemaField({
|
||||||
|
name: new fields.StringField({}),
|
||||||
|
img: new fields.StringField({}),
|
||||||
|
uuid: new fields.StringField({})
|
||||||
|
})
|
||||||
|
)
|
||||||
}),
|
}),
|
||||||
masteryFeature: new fields.SchemaField({
|
masteryFeature: new fields.SchemaField({
|
||||||
unlocked: new fields.BooleanField({ initial: false }),
|
unlocked: new fields.BooleanField({ initial: false }),
|
||||||
tier: new fields.NumberField({ initial: null, nullable: true, integer: true }),
|
tier: new fields.NumberField({ initial: null, nullable: true, integer: true }),
|
||||||
description: new fields.HTMLField({}),
|
description: new fields.HTMLField({}),
|
||||||
abilities: new fields.ArrayField(new fields.EmbeddedDataField(DaggerheartFeature))
|
abilities: new fields.ArrayField(
|
||||||
|
new fields.SchemaField({
|
||||||
|
name: new fields.StringField({}),
|
||||||
|
img: new fields.StringField({}),
|
||||||
|
uuid: new fields.StringField({})
|
||||||
|
})
|
||||||
|
)
|
||||||
}),
|
}),
|
||||||
multiclass: new fields.NumberField({ initial: null, nullable: true, integer: true })
|
multiclass: new fields.NumberField({ initial: null, nullable: true, integer: true })
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue