mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-04-23 07:53:39 +02:00
Added confirmation on ignoring character setup. Added reset option to character sheet.
This commit is contained in:
parent
5b61340fee
commit
96c421cc6a
2 changed files with 50 additions and 1 deletions
|
|
@ -27,6 +27,7 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
|||
makeDeathMove: CharacterSheet.#makeDeathMove,
|
||||
levelManagement: CharacterSheet.#levelManagement,
|
||||
viewLevelups: CharacterSheet.#viewLevelups,
|
||||
resetCharacter: CharacterSheet.#resetCharacter,
|
||||
toggleEquipItem: CharacterSheet.#toggleEquipItem,
|
||||
toggleResourceDice: CharacterSheet.#toggleResourceDice,
|
||||
handleResourceDice: CharacterSheet.#handleResourceDice,
|
||||
|
|
@ -42,6 +43,11 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
|||
icon: 'fa-solid fa-angles-up',
|
||||
label: 'DAGGERHEART.ACTORS.Character.viewLevelups',
|
||||
action: 'viewLevelups'
|
||||
},
|
||||
{
|
||||
icon: 'fa-solid fa-arrow-rotate-left',
|
||||
label: 'DAGGERHEART.ACTORS.Character.resetCharacter',
|
||||
action: 'resetCharacter'
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
@ -666,6 +672,32 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
|||
new LevelupViewMode(this.document).render({ force: true });
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the character data and removes all embedded documents.
|
||||
*/
|
||||
static async #resetCharacter() {
|
||||
const confirmed = await foundry.applications.api.DialogV2.confirm({
|
||||
window: {
|
||||
title: game.i18n.localize('DAGGERHEART.ACTORS.Character.resetCharacterConfirmationTitle')
|
||||
},
|
||||
content: game.i18n.localize('DAGGERHEART.ACTORS.Character.resetCharacterConfirmationContent')
|
||||
});
|
||||
|
||||
if (!confirmed) return;
|
||||
|
||||
await this.document.update({
|
||||
'==system': {}
|
||||
});
|
||||
await this.document.deleteEmbeddedDocuments(
|
||||
'Item',
|
||||
this.document.items.map(x => x.id)
|
||||
);
|
||||
await this.document.deleteEmbeddedDocuments(
|
||||
'ActiveEffect',
|
||||
this.document.effects.map(x => x.id)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the Death Move interface for the character.
|
||||
* @type {ApplicationClickAction}
|
||||
|
|
@ -956,6 +988,18 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
|||
}
|
||||
|
||||
async _onDropItem(event, item) {
|
||||
const setupCriticalItemTypes = ['class', 'subclass', 'ancestry', 'community'];
|
||||
if (this.document.system.needsCharacterSetup && setupCriticalItemTypes.includes(item.type)) {
|
||||
const confirmed = await foundry.applications.api.DialogV2.confirm({
|
||||
window: {
|
||||
title: game.i18n.localize('DAGGERHEART.APPLICATIONS.CharacterCreation.setupSkipTitle')
|
||||
},
|
||||
content: game.i18n.localize('DAGGERHEART.APPLICATIONS.CharacterCreation.setupSkipContent')
|
||||
});
|
||||
|
||||
if (!confirmed) return;
|
||||
}
|
||||
|
||||
if (this.document.uuid === item.parent?.uuid) {
|
||||
return super._onDropItem(event, item);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue