diff --git a/lang/en.json b/lang/en.json index 720a08c5..dda78410 100755 --- a/lang/en.json +++ b/lang/en.json @@ -330,12 +330,6 @@ "title": "{actor} - Character Setup", "traitIncreases": "Trait Increases" }, - "CharacterReset": { - "title": "Reset Character", - "alwaysDeleteSection": "Deleted Data", - "optionalDeleteSection": "Optional Data", - "headerTitle": "Select which data you'd like to keep" - }, "CombatTracker": { "combatStarted": "Active", "giveSpotlight": "Give The Spotlight", @@ -2220,7 +2214,6 @@ "single": "Player", "plurial": "Players" }, - "portrait": "Portrait", "proficiency": "Proficiency", "quantity": "Quantity", "range": "Range", @@ -2883,8 +2876,7 @@ "documentIsMissing": "The {documentType} is missing from the world.", "tokenActorMissing": "{name} is missing an Actor", "tokenActorsMissing": "[{names}] missing Actors", - "domainTouchRequirement": "This domain card requires {nr} {domain} cards in the loadout to be used", - "knowTheTide": "Know The Tide gained a token" + "domainTouchRequirement": "This domain card requires {nr} {domain} cards in the loadout to be used" }, "Sidebar": { "actorDirectory": { diff --git a/module/applications/dialogs/_module.mjs b/module/applications/dialogs/_module.mjs index 4eda8579..d43045e6 100644 --- a/module/applications/dialogs/_module.mjs +++ b/module/applications/dialogs/_module.mjs @@ -1,6 +1,5 @@ export { default as AttributionDialog } from './attributionDialog.mjs'; export { default as BeastformDialog } from './beastformDialog.mjs'; -export { default as CharacterResetDialog } from './characterResetDialog.mjs'; export { default as d20RollDialog } from './d20RollDialog.mjs'; export { default as DamageDialog } from './damageDialog.mjs'; export { default as DamageReductionDialog } from './damageReductionDialog.mjs'; diff --git a/module/applications/dialogs/characterResetDialog.mjs b/module/applications/dialogs/characterResetDialog.mjs deleted file mode 100644 index 1f3f3d5a..00000000 --- a/module/applications/dialogs/characterResetDialog.mjs +++ /dev/null @@ -1,105 +0,0 @@ -const { ApplicationV2, HandlebarsApplicationMixin } = foundry.applications.api; - -export default class CharacterResetDialog extends HandlebarsApplicationMixin(ApplicationV2) { - constructor(actor, options = {}) { - super(options); - - this.actor = actor; - this.data = { - delete: { - class: { keep: false, label: 'TYPES.Item.class' }, - subclass: { keep: false, label: 'TYPES.Item.subclass' }, - ancestry: { keep: false, label: 'TYPES.Item.ancestry' }, - community: { keep: false, label: 'TYPES.Item.community' } - }, - optional: { - portrait: { keep: true, label: 'DAGGERHEART.GENERAL.portrait' }, - name: { keep: true, label: 'Name' }, - biography: { keep: true, label: 'DAGGERHEART.GENERAL.Tabs.biography' }, - inventory: { keep: false, label: 'DAGGERHEART.GENERAL.inventory' } - } - }; - } - - static DEFAULT_OPTIONS = { - tag: 'form', - classes: ['daggerheart', 'dialog', 'dh-style', 'views', 'character-reset'], - window: { - icon: 'fa-solid fa-arrow-rotate-left', - title: 'DAGGERHEART.APPLICATIONS.CharacterReset.title' - }, - actions: { - finishSelection: this.#finishSelection - }, - form: { - handler: this.updateData, - submitOnChange: true, - submitOnClose: false - } - }; - - /** @override */ - static PARTS = { - resourceDice: { - id: 'resourceDice', - template: 'systems/daggerheart/templates/dialogs/characterReset.hbs' - } - }; - - async _prepareContext(_options) { - const context = await super._prepareContext(_options); - context.data = this.data; - - return context; - } - - static async updateData(event, _, formData) { - const { data } = foundry.utils.expandObject(formData.object); - - this.data = foundry.utils.mergeObject(this.data, data); - this.render(); - } - - static getUpdateData() { - const update = {}; - if (!this.data.optional.portrait) update.if(!this.data.optional.biography); - - if (!this.data.optional.inventory) return update; - } - - static async #finishSelection() { - const update = {}; - if (!this.data.optional.name.keep) { - const defaultName = game.system.api.documents.DhpActor.defaultName({ type: 'character' }); - foundry.utils.setProperty(update, 'name', defaultName); - foundry.utils.setProperty(update, 'prototypeToken.name', defaultName); - } - - if (!this.data.optional.portrait.keep) { - foundry.utils.setProperty(update, 'img', this.actor.schema.fields.img.initial(this.actor)); - foundry.utils.setProperty(update, 'prototypeToken.==texture', {}); - foundry.utils.setProperty(update, 'prototypeToken.==ring', {}); - } - - if (this.data.optional.biography.keep) - foundry.utils.setProperty(update, 'system.biography', this.actor.system.biography); - - if (this.data.optional.inventory.keep) foundry.utils.setProperty(update, 'system.gold', this.actor.system.gold); - - const { system, ...rest } = update; - await this.actor.update({ - ...rest, - '==system': system ?? {} - }); - - const inventoryItemTypes = ['weapon', 'armor', 'consumable', 'loot']; - await this.actor.deleteEmbeddedDocuments( - 'Item', - this.actor.items - .filter(x => !inventoryItemTypes.includes(x.type) || !this.data.optional.inventory.keep) - .map(x => x.id) - ); - - this.close(); - } -} diff --git a/module/applications/sheets/actors/character.mjs b/module/applications/sheets/actors/character.mjs index 4ecaeb06..5c6bac3a 100644 --- a/module/applications/sheets/actors/character.mjs +++ b/module/applications/sheets/actors/character.mjs @@ -669,7 +669,26 @@ export default class CharacterSheet extends DHBaseActorSheet { * Resets the character data and removes all embedded documents. */ static async #resetCharacter() { - new game.system.api.applications.dialogs.CharacterResetDialog(this.document).render({ force: true }); + 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) + ); } /** @@ -734,9 +753,8 @@ export default class CharacterSheet extends DHBaseActorSheet { if (!result) return; /* This could be avoided by baking config.costs into config.resourceUpdates. Didn't feel like messing with it at the time */ - const costResources = - result.costs?.filter(x => x.enabled).map(cost => ({ ...cost, value: -cost.value, total: -cost.total })) || - {}; + const costResources = result.costs?.filter(x => x.enabled) + .map(cost => ({ ...cost, value: -cost.value, total: -cost.total })) || {}; config.resourceUpdates.addResources(costResources); await config.resourceUpdates.updateResources(); } diff --git a/module/data/registeredTriggers.mjs b/module/data/registeredTriggers.mjs index 3fd9f82c..8a100585 100644 --- a/module/data/registeredTriggers.mjs +++ b/module/data/registeredTriggers.mjs @@ -20,7 +20,6 @@ export default class RegisteredTriggers extends Map { } registerItemTriggers(item, registerOverride) { - if (!item.actor || !item._stats.createdTime) return; for (const action of item.system.actions ?? []) { if (!action.actor) continue; diff --git a/src/packs/communities/feature_Know_the_Tide_07x6Qe6qMzDw2xN4.json b/src/packs/communities/feature_Know_the_Tide_07x6Qe6qMzDw2xN4.json index 41f11a74..069fe6ba 100644 --- a/src/packs/communities/feature_Know_the_Tide_07x6Qe6qMzDw2xN4.json +++ b/src/packs/communities/feature_Know_the_Tide_07x6Qe6qMzDw2xN4.json @@ -9,47 +9,13 @@ "resource": { "type": "simple", "value": 0, - "max": "@system.levelData.level.current", - "icon": "fa-solid fa-water", - "recovery": "session", + "max": "", + "icon": "", + "recovery": null, "diceStates": {}, "dieFaces": "d4" }, - "actions": { - "tFlus34KotJjHfTe": { - "type": "effect", - "_id": "tFlus34KotJjHfTe", - "systemPath": "actions", - "baseAction": false, - "description": "", - "chatDisplay": true, - "originItem": { - "type": "itemCollection" - }, - "actionType": "action", - "triggers": [ - { - "trigger": "fearRoll", - "triggeringActorType": "self", - "command": "const { max, value } = this.item.system.resource;\nconst maxValue = actor.system.levelData.level.current;\nconst afterUpdate = value+1;\nif (afterUpdate > maxValue) return;\n\nui.notifications.info(game.i18n.localize('DAGGERHEART.UI.Notifications.knowTheTide'));\nreturn { updates: [{\n key: 'resource',\n itemId: this.item.id,\n target: this.item,\n value: 1,\n}]};" - } - ], - "cost": [], - "uses": { - "value": null, - "max": "", - "recovery": null, - "consumeOnSuccess": false - }, - "effects": [], - "target": { - "type": "any", - "amount": null - }, - "name": "Know The Tide", - "range": "" - } - }, + "actions": {}, "originItemType": null, "subType": null, "originId": null, diff --git a/styles/less/dialog/character-reset/sheet.less b/styles/less/dialog/character-reset/sheet.less deleted file mode 100644 index 44312a3e..00000000 --- a/styles/less/dialog/character-reset/sheet.less +++ /dev/null @@ -1,27 +0,0 @@ -.daggerheart.dh-style.dialog.views.character-reset { - .character-reset-container { - display: flex; - flex-direction: column; - gap: 8px; - - legend { - padding: 0 4px; - } - - .character-reset-header { - font-size: var(--font-size-18); - text-align: center; - } - - .reset-data-container { - display: grid; - grid-template-columns: 3fr 2fr; - align-items: center; - gap: 4px; - - label { - font-weight: bold; - } - } - } -} diff --git a/styles/less/dialog/index.less b/styles/less/dialog/index.less index 733cdd1c..01a3f954 100644 --- a/styles/less/dialog/index.less +++ b/styles/less/dialog/index.less @@ -41,5 +41,3 @@ @import './settings/change-currency-icon.less'; @import './risk-it-all/sheet.less'; - -@import './character-reset/sheet.less'; diff --git a/templates/dialogs/characterReset.hbs b/templates/dialogs/characterReset.hbs deleted file mode 100644 index 298826e5..00000000 --- a/templates/dialogs/characterReset.hbs +++ /dev/null @@ -1,33 +0,0 @@ -