mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-06-08 13:48:11 +02:00
Compare commits
2 commits
cc998bffa7
...
2aba7cf921
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2aba7cf921 | ||
|
|
3725fc29ef |
9 changed files with 220 additions and 27 deletions
10
lang/en.json
10
lang/en.json
|
|
@ -330,6 +330,12 @@
|
||||||
"title": "{actor} - Character Setup",
|
"title": "{actor} - Character Setup",
|
||||||
"traitIncreases": "Trait Increases"
|
"traitIncreases": "Trait Increases"
|
||||||
},
|
},
|
||||||
|
"CharacterReset": {
|
||||||
|
"title": "Reset Character",
|
||||||
|
"alwaysDeleteSection": "Deleted Data",
|
||||||
|
"optionalDeleteSection": "Optional Data",
|
||||||
|
"headerTitle": "Select which data you'd like to keep"
|
||||||
|
},
|
||||||
"CombatTracker": {
|
"CombatTracker": {
|
||||||
"combatStarted": "Active",
|
"combatStarted": "Active",
|
||||||
"giveSpotlight": "Give The Spotlight",
|
"giveSpotlight": "Give The Spotlight",
|
||||||
|
|
@ -2214,6 +2220,7 @@
|
||||||
"single": "Player",
|
"single": "Player",
|
||||||
"plurial": "Players"
|
"plurial": "Players"
|
||||||
},
|
},
|
||||||
|
"portrait": "Portrait",
|
||||||
"proficiency": "Proficiency",
|
"proficiency": "Proficiency",
|
||||||
"quantity": "Quantity",
|
"quantity": "Quantity",
|
||||||
"range": "Range",
|
"range": "Range",
|
||||||
|
|
@ -2876,7 +2883,8 @@
|
||||||
"documentIsMissing": "The {documentType} is missing from the world.",
|
"documentIsMissing": "The {documentType} is missing from the world.",
|
||||||
"tokenActorMissing": "{name} is missing an Actor",
|
"tokenActorMissing": "{name} is missing an Actor",
|
||||||
"tokenActorsMissing": "[{names}] missing Actors",
|
"tokenActorsMissing": "[{names}] missing Actors",
|
||||||
"domainTouchRequirement": "This domain card requires {nr} {domain} cards in the loadout to be used"
|
"domainTouchRequirement": "This domain card requires {nr} {domain} cards in the loadout to be used",
|
||||||
|
"knowTheTide": "Know The Tide gained a token"
|
||||||
},
|
},
|
||||||
"Sidebar": {
|
"Sidebar": {
|
||||||
"actorDirectory": {
|
"actorDirectory": {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
export { default as AttributionDialog } from './attributionDialog.mjs';
|
export { default as AttributionDialog } from './attributionDialog.mjs';
|
||||||
export { default as BeastformDialog } from './beastformDialog.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 d20RollDialog } from './d20RollDialog.mjs';
|
||||||
export { default as DamageDialog } from './damageDialog.mjs';
|
export { default as DamageDialog } from './damageDialog.mjs';
|
||||||
export { default as DamageReductionDialog } from './damageReductionDialog.mjs';
|
export { default as DamageReductionDialog } from './damageReductionDialog.mjs';
|
||||||
|
|
|
||||||
105
module/applications/dialogs/characterResetDialog.mjs
Normal file
105
module/applications/dialogs/characterResetDialog.mjs
Normal file
|
|
@ -0,0 +1,105 @@
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -669,26 +669,7 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
||||||
* Resets the character data and removes all embedded documents.
|
* Resets the character data and removes all embedded documents.
|
||||||
*/
|
*/
|
||||||
static async #resetCharacter() {
|
static async #resetCharacter() {
|
||||||
const confirmed = await foundry.applications.api.DialogV2.confirm({
|
new game.system.api.applications.dialogs.CharacterResetDialog(this.document).render({ force: true });
|
||||||
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)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -753,8 +734,9 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
||||||
if (!result) return;
|
if (!result) return;
|
||||||
|
|
||||||
/* This could be avoided by baking config.costs into config.resourceUpdates. Didn't feel like messing with it at the time */
|
/* 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)
|
const costResources =
|
||||||
.map(cost => ({ ...cost, value: -cost.value, total: -cost.total })) || {};
|
result.costs?.filter(x => x.enabled).map(cost => ({ ...cost, value: -cost.value, total: -cost.total })) ||
|
||||||
|
{};
|
||||||
config.resourceUpdates.addResources(costResources);
|
config.resourceUpdates.addResources(costResources);
|
||||||
await config.resourceUpdates.updateResources();
|
await config.resourceUpdates.updateResources();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ export default class RegisteredTriggers extends Map {
|
||||||
}
|
}
|
||||||
|
|
||||||
registerItemTriggers(item, registerOverride) {
|
registerItemTriggers(item, registerOverride) {
|
||||||
|
if (!item.actor || !item._stats.createdTime) return;
|
||||||
for (const action of item.system.actions ?? []) {
|
for (const action of item.system.actions ?? []) {
|
||||||
if (!action.actor) continue;
|
if (!action.actor) continue;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,13 +9,47 @@
|
||||||
"resource": {
|
"resource": {
|
||||||
"type": "simple",
|
"type": "simple",
|
||||||
"value": 0,
|
"value": 0,
|
||||||
"max": "",
|
"max": "@system.levelData.level.current",
|
||||||
"icon": "",
|
"icon": "fa-solid fa-water",
|
||||||
"recovery": null,
|
"recovery": "session",
|
||||||
"diceStates": {},
|
"diceStates": {},
|
||||||
"dieFaces": "d4"
|
"dieFaces": "d4"
|
||||||
},
|
},
|
||||||
"actions": {},
|
"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": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
"originItemType": null,
|
"originItemType": null,
|
||||||
"subType": null,
|
"subType": null,
|
||||||
"originId": null,
|
"originId": null,
|
||||||
|
|
|
||||||
27
styles/less/dialog/character-reset/sheet.less
Normal file
27
styles/less/dialog/character-reset/sheet.less
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -41,3 +41,5 @@
|
||||||
@import './settings/change-currency-icon.less';
|
@import './settings/change-currency-icon.less';
|
||||||
|
|
||||||
@import './risk-it-all/sheet.less';
|
@import './risk-it-all/sheet.less';
|
||||||
|
|
||||||
|
@import './character-reset/sheet.less';
|
||||||
|
|
|
||||||
33
templates/dialogs/characterReset.hbs
Normal file
33
templates/dialogs/characterReset.hbs
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
<div>
|
||||||
|
<div class="character-reset-container">
|
||||||
|
<div class="character-reset-header">{{localize "DAGGERHEART.APPLICATIONS.CharacterReset.headerTitle"}}</div>
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
|
<legend>{{localize "DAGGERHEART.APPLICATIONS.CharacterReset.alwaysDeleteSection"}} <i class="fa-solid fa-lock"></i></legend>
|
||||||
|
|
||||||
|
<div class="reset-data-wrapper two-columns even">
|
||||||
|
{{#each this.data.delete as | data key|}}
|
||||||
|
<div class="reset-data-container">
|
||||||
|
<label>{{localize data.label}}</label>
|
||||||
|
<input type="checkbox" {{checked data.keep}} disabled />
|
||||||
|
</div>
|
||||||
|
{{/each}}
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
|
<legend>{{localize "DAGGERHEART.APPLICATIONS.CharacterReset.optionalDeleteSection"}}</legend>
|
||||||
|
|
||||||
|
<div class="reset-data-wrapper two-columns even">
|
||||||
|
{{#each this.data.optional as | data key|}}
|
||||||
|
<div class="reset-data-container">
|
||||||
|
<label>{{localize data.label}}</label>
|
||||||
|
<input type="checkbox" name="{{concat "data.optional." key ".keep"}}" {{checked data.keep}} />
|
||||||
|
</div>
|
||||||
|
{{/each}}
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<button type="button" data-action="finishSelection">{{localize "Reset"}}</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue