mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-06-06 04:44:16 +02:00
Continue work on updating identifier
This commit is contained in:
parent
d2ec5283a0
commit
20f42e8a0d
12 changed files with 122 additions and 69 deletions
|
|
@ -9,7 +9,8 @@ export default class ClassSheet extends DHBaseItemSheet {
|
|||
position: { width: 700 },
|
||||
actions: {
|
||||
removeItemFromCollection: ClassSheet.#removeItemFromCollection,
|
||||
removeSuggestedItem: ClassSheet.#removeSuggestedItem
|
||||
removeSuggestedItem: ClassSheet.#removeSuggestedItem,
|
||||
resetIdentifier: ClassSheet.#resetIdentifier
|
||||
},
|
||||
tagifyConfigs: [
|
||||
{
|
||||
|
|
@ -107,6 +108,7 @@ export default class ClassSheet extends DHBaseItemSheet {
|
|||
async _prepareContext(_options) {
|
||||
const context = await super._prepareContext(_options);
|
||||
context.domains = this.document.system.domains;
|
||||
context.subclasses = await this.document.system.getSubclasses();
|
||||
return context;
|
||||
}
|
||||
|
||||
|
|
@ -129,19 +131,7 @@ export default class ClassSheet extends DHBaseItemSheet {
|
|||
const itemType = data.type === 'ActiveEffect' ? data.type : item.type;
|
||||
const target = event.target.closest('fieldset.drop-section');
|
||||
|
||||
if (itemType === 'subclass') {
|
||||
if (!this.document.system.identifier) {
|
||||
return ui.notifications.error(
|
||||
game.i18n.localize('DAGGERHEART.UI.Notifications.classMissingIdentifier')
|
||||
);
|
||||
}
|
||||
|
||||
if (item.system.classIdentifiers.includes(this.document.system.identifier)) return;
|
||||
|
||||
await item.update({
|
||||
'system.classIdentifiers': [...item.system.classIdentifiers, this.document.system.identifier]
|
||||
});
|
||||
} else if (['feature', 'ActiveEffect'].includes(itemType)) {
|
||||
if (['feature', 'ActiveEffect'].includes(itemType)) {
|
||||
super._onDrop(event);
|
||||
} else if (this.document.parent?.type !== 'character') {
|
||||
if (itemType === 'weapon') {
|
||||
|
|
@ -218,4 +208,10 @@ export default class ClassSheet extends DHBaseItemSheet {
|
|||
const { target } = element.dataset;
|
||||
await this.document.update({ [`system.characterGuide.${target}`]: null });
|
||||
}
|
||||
|
||||
static async #resetIdentifier() {
|
||||
const document = this.document;
|
||||
const initial = document.system.schema.fields.identifier.getInitialValue(document._source);
|
||||
document.update({ 'system.identifier': initial });
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,4 +40,27 @@ export default class SubclassSheet extends DHBaseItemSheet {
|
|||
get relatedDocs() {
|
||||
return this.document.system.features.map(x => x.item);
|
||||
}
|
||||
|
||||
async _onDrop(event) {
|
||||
event.stopPropagation();
|
||||
const data = TextEditor.getDragEventData(event);
|
||||
const item = await fromUuid(data.uuid);
|
||||
const itemType = data.type === 'ActiveEffect' ? data.type : item.type;
|
||||
if (itemType === 'class') {
|
||||
const identifier = item.system.identifier;
|
||||
if (!identifier) {
|
||||
return ui.notifications.error(
|
||||
game.i18n.localize('DAGGERHEART.UI.Notifications.classMissingIdentifier')
|
||||
);
|
||||
}
|
||||
|
||||
if (this.document.system.classLink.identifier !== identifier) {
|
||||
const { img, name } = item;
|
||||
await this.document.update({ 'system.classLink': { identifier, img, name } });
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
return super._onDrop(event);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue