Finalized Character-Settings

This commit is contained in:
WBHarry 2025-07-31 14:57:27 +02:00
parent 2faa5e5460
commit d9a0decbda
16 changed files with 130 additions and 42 deletions

View file

@ -162,6 +162,8 @@
}, },
"faith": "Faith", "faith": "Faith",
"levelUp": "You can level up", "levelUp": "You can level up",
"maxEvasionBonus": "Max Evasion Increase",
"maxHPBonus": "Max HP Increase",
"pronouns": "Pronouns", "pronouns": "Pronouns",
"story": { "story": {
"backgroundTitle": "Background", "backgroundTitle": "Background",
@ -2244,6 +2246,8 @@
"openItemWorld": "Open Item World", "openItemWorld": "Open Item World",
"openActorWorld": "Open Actor World", "openActorWorld": "Open Actor World",
"sendToChat": "Send to Chat", "sendToChat": "Send to Chat",
"maxEvasionClassBound": "Your Evasion base is set on your class. This is the increase ontop of that.",
"maxHPClassBound": "Your max HP base is set on your class. This is the increase ontop of that.",
"moreOptions": "More Options", "moreOptions": "More Options",
"equip": "Equip", "equip": "Equip",
"unequip": "Unequip", "unequip": "Unequip",
@ -2253,7 +2257,8 @@
"rangeAndTarget": "Range & Target", "rangeAndTarget": "Range & Target",
"dragApplyEffect": "Drag effect to apply it to an actor", "dragApplyEffect": "Drag effect to apply it to an actor",
"appliedEvenIfSuccessful": "Applied even if save succeeded", "appliedEvenIfSuccessful": "Applied even if save succeeded",
"diceIsRerolled": "The dice has been rerolled (x{times})" "diceIsRerolled": "The dice has been rerolled (x{times})",
"openSheetSettings": "Open Settings"
} }
} }
} }

View file

@ -73,18 +73,23 @@ export default class DHCharacterSettings extends DHBaseActorSettings {
const experience = this.actor.system.experiences[target.dataset.experience]; const experience = this.actor.system.experiences[target.dataset.experience];
const updates = {}; const updates = {};
const relinkData = Object.keys(this.actor.system.levelData.levelups).reduce((acc, key) => { const relinkAchievementData = [];
const relinkSelectionData = [];
Object.keys(this.actor.system.levelData.levelups).forEach(key => {
const level = this.actor.system.levelData.levelups[key]; const level = this.actor.system.levelData.levelups[key];
const achievementIncludesExp = level.achievements.experiences[target.dataset.experience];
if (achievementIncludesExp)
relinkAchievementData.push({ levelKey: key, experience: target.dataset.experience });
const selectionIndex = level.selections.findIndex( const selectionIndex = level.selections.findIndex(
x => x.optionKey === 'experience' && x.data[0] === target.dataset.experience x => x.optionKey === 'experience' && x.data[0] === target.dataset.experience
); );
if (selectionIndex !== -1) if (selectionIndex !== -1)
acc.push({ levelKey: key, selectionIndex, experience: target.dataset.experience }); relinkSelectionData.push({ levelKey: key, selectionIndex, experience: target.dataset.experience });
});
return acc; if (relinkAchievementData.length > 0 || relinkSelectionData.length > 0) {
}, []);
if (relinkData.length > 0) {
const confirmed = await foundry.applications.api.DialogV2.confirm({ const confirmed = await foundry.applications.api.DialogV2.confirm({
window: { window: {
title: game.i18n.localize('DAGGERHEART.ACTORS.Character.experienceDataRemoveConfirmation.title') title: game.i18n.localize('DAGGERHEART.ACTORS.Character.experienceDataRemoveConfirmation.title')
@ -92,8 +97,15 @@ export default class DHCharacterSettings extends DHBaseActorSettings {
content: game.i18n.localize('DAGGERHEART.ACTORS.Character.experienceDataRemoveConfirmation.text') content: game.i18n.localize('DAGGERHEART.ACTORS.Character.experienceDataRemoveConfirmation.text')
}); });
if (!confirmed) return; if (!confirmed) return;
}
relinkData.forEach(data => { if (relinkAchievementData.length > 0) {
relinkAchievementData.forEach(data => {
updates[`system.levelData.levelups.${data.levelKey}.achievements.experiences.-=${data.experience}`] =
null;
});
} else if (relinkSelectionData.length > 0) {
relinkSelectionData.forEach(data => {
updates[`system.levelData.levelups.${data.levelKey}.selections`] = this.actor.system.levelData.levelups[ updates[`system.levelData.levelups.${data.levelKey}.selections`] = this.actor.system.levelData.levelups[
data.levelKey data.levelKey
].selections.reduce((acc, selection, index) => { ].selections.reduce((acc, selection, index) => {

View file

@ -10,6 +10,8 @@ export default class DHCompanionSettings extends DHBaseActorSettings {
classes: ['companion-settings'], classes: ['companion-settings'],
position: { width: 455, height: 'auto' }, position: { width: 455, height: 'auto' },
actions: { actions: {
addExperience: DHCompanionSettings.#addExperience,
removeExperience: DHCompanionSettings.#removeExperience,
levelUp: DHCompanionSettings.#levelUp levelUp: DHCompanionSettings.#levelUp
} }
}; };
@ -88,6 +90,38 @@ export default class DHCompanionSettings extends DHBaseActorSettings {
if (!value) await this.actor.updateLevel(1); if (!value) await this.actor.updateLevel(1);
} }
/**
* Adds a new experience entry to the actor.
* @type {ApplicationClickAction}
*/
static async #addExperience() {
const newExperience = {
name: 'Experience',
modifier: 0
};
await this.actor.update({ [`system.experiences.${foundry.utils.randomID()}`]: newExperience });
}
/**
* Removes an experience entry from the actor.
* @type {ApplicationClickAction}
*/
static async #removeExperience(_, target) {
const experience = this.actor.system.experiences[target.dataset.experience];
const confirmed = await foundry.applications.api.DialogV2.confirm({
window: {
title: game.i18n.format('DAGGERHEART.APPLICATIONS.DeleteConfirmation.title', {
type: game.i18n.localize(`DAGGERHEART.GENERAL.Experience.single`),
name: experience.name
})
},
content: game.i18n.format('DAGGERHEART.APPLICATIONS.DeleteConfirmation.text', { name: experience.name })
});
if (!confirmed) return;
await this.actor.update({ [`system.experiences.-=${target.dataset.experience}`]: null });
}
/** /**
* Opens the companion level-up dialog for the associated actor. * Opens the companion level-up dialog for the associated actor.
* @type {ApplicationClickAction} * @type {ApplicationClickAction}

View file

@ -24,7 +24,12 @@ export default class DhCharacter extends BaseDataActor {
return { return {
...super.defineSchema(), ...super.defineSchema(),
resources: new fields.SchemaField({ resources: new fields.SchemaField({
hitPoints: resourceField(0, 'DAGGERHEART.GENERAL.HitPoints.plural', true), hitPoints: resourceField(
0,
'DAGGERHEART.GENERAL.HitPoints.plural',
true,
'DAGGERHEART.ACTORS.Character.maxHPBonus'
),
stress: resourceField(6, 'DAGGERHEART.GENERAL.stress', true), stress: resourceField(6, 'DAGGERHEART.GENERAL.stress', true),
hope: resourceField(6, 'DAGGERHEART.GENERAL.hope') hope: resourceField(6, 'DAGGERHEART.GENERAL.hope')
}), }),
@ -505,7 +510,7 @@ export default class DhCharacter extends BaseDataActor {
} }
prepareBaseData() { prepareBaseData() {
this.evasion = this.class.value?.system?.evasion ?? 0; this.evasion += this.class.value?.system?.evasion ?? 0;
const currentLevel = this.levelData.level.current; const currentLevel = this.levelData.level.current;
const currentTier = const currentTier =

View file

@ -6,13 +6,14 @@ const attributeField = label =>
tierMarked: new fields.BooleanField({ initial: false }) tierMarked: new fields.BooleanField({ initial: false })
}); });
const resourceField = (max = 0, label, reverse = false) => const resourceField = (max = 0, label, reverse = false, maxLabel) =>
new fields.SchemaField({ new fields.SchemaField({
value: new fields.NumberField({ initial: 0, min: 0, integer: true, label }), value: new fields.NumberField({ initial: 0, min: 0, integer: true, label }),
max: new fields.NumberField({ max: new fields.NumberField({
initial: max, initial: max,
integer: true, integer: true,
label: game.i18n.format('DAGGERHEART.GENERAL.maxWithThing', { thing: game.i18n.localize(label) }) label:
maxLabel ?? game.i18n.format('DAGGERHEART.GENERAL.maxWithThing', { thing: game.i18n.localize(label) })
}), }),
isReversed: new fields.BooleanField({ initial: reverse }) isReversed: new fields.BooleanField({ initial: reverse })
}); });

View file

@ -263,6 +263,11 @@
gap: 8px; gap: 8px;
.experience-container { .experience-container {
display: flex;
flex-direction: column;
gap: 5px;
.experience-inner-container {
position: relative; position: relative;
display: flex; display: flex;
align-items: center; align-items: center;
@ -283,6 +288,12 @@
justify-content: center; justify-content: center;
} }
} }
textarea {
width: 100%;
resize: none;
}
}
} }
.creation-action-footer { .creation-action-footer {

View file

@ -196,6 +196,7 @@
.character-downtime-container { .character-downtime-container {
display: flex; display: flex;
align-items: center;
gap: 2px; gap: 2px;
button { button {

View file

@ -18,6 +18,7 @@
} }
.character-header-sheet { .character-header-sheet {
position: relative;
grid-row: 1; grid-row: 1;
grid-column: 2; grid-column: 2;
} }

View file

@ -9,9 +9,13 @@
<div class="experiences-inner-container"> <div class="experiences-inner-container">
{{#each experience.values as |experience id|}} {{#each experience.values as |experience id|}}
<div class="experience-container"> <div class="experience-container">
<div class="experience-inner-container">
<input class="experience-description" type="text" name="{{concat "experiences." id ".name" }}" value="{{experience.name}}" placeholder="{{localize "DAGGERHEART.APPLICATIONS.CharacterCreation.newExperience"}}" /> <input class="experience-description" type="text" name="{{concat "experiences." id ".name" }}" value="{{experience.name}}" placeholder="{{localize "DAGGERHEART.APPLICATIONS.CharacterCreation.newExperience"}}" />
<div class="experience-value">{{numberFormat this.value sign=true}}</div> <div class="experience-value">{{numberFormat this.value sign=true}}</div>
</div> </div>
<textarea name="system.experiences.{{key}}.description">{{experience.description}}</textarea>
</div>
{{/each}} {{/each}}
</div> </div>
</fieldset> </fieldset>

View file

@ -8,7 +8,7 @@
<div class="nest-inputs"> <div class="nest-inputs">
<div class="traits-inner-container"> <div class="traits-inner-container">
{{#each document.system.traits as | trait key |}} {{#each document._source.system.traits as | trait key |}}
<div class="trait-container"> <div class="trait-container">
<div>{{localize (concat "DAGGERHEART.CONFIG.Traits." key ".name" )}}</div> <div>{{localize (concat "DAGGERHEART.CONFIG.Traits." key ".name" )}}</div>
<input type="text" data-dtype="Number" name="{{concat "system.traits." key ".value"}}" value="{{trait.value}}" /> <input type="text" data-dtype="Number" name="{{concat "system.traits." key ".value"}}" value="{{trait.value}}" />
@ -22,13 +22,18 @@
<legend>{{localize 'DAGGERHEART.GENERAL.basics'}}</legend> <legend>{{localize 'DAGGERHEART.GENERAL.basics'}}</legend>
<div class="two-columns even"> <div class="two-columns even">
{{formGroup systemFields.resources.fields.hitPoints.fields.value value=document.system.resources.hitPoints.value localize=true}} {{formGroup systemFields.resources.fields.hitPoints.fields.value value=document._source.system.resources.hitPoints.value localize=true}}
{{formGroup systemFields.resources.fields.hitPoints.fields.max value=document.system.resources.hitPoints.max localize=true}} <span data-tooltip-text="{{localize "DAGGERHEART.UI.Tooltip.maxHPClassBound"}}">
{{formGroup systemFields.resources.fields.hitPoints.fields.max value=document._source.system.resources.hitPoints.max localize=true}}
</span>
{{formGroup systemFields.resources.fields.stress.fields.value value=document.system.resources.stress.value localize=true}} {{formGroup systemFields.resources.fields.stress.fields.value value=document._source.system.resources.stress.value localize=true}}
{{formGroup systemFields.resources.fields.stress.fields.max value=document.system.resources.stress.max localize=true}} {{formGroup systemFields.resources.fields.stress.fields.max value=document._source.system.resources.stress.max localize=true}}
{{formGroup systemFields.proficiency value=document.proficiency localize=true}} {{formGroup systemFields.proficiency value=document._source.system.proficiency localize=true}}
<span data-tooltip-text="{{localize "DAGGERHEART.UI.Tooltip.maxEvasionClassBound"}}">
{{formGroup systemFields.evasion value=document._source.system.evasion label="DAGGERHEART.ACTORS.Character.maxEvasionBonus" localize=true}}
</span>
</div> </div>
</fieldset> </fieldset>
</section> </section>

View file

@ -10,7 +10,7 @@
<fieldset> <fieldset>
<legend>{{localize tabs.experiences.label}}</legend> <legend>{{localize tabs.experiences.label}}</legend>
<ul class="experience-list"> <ul class="experience-list">
{{#each document.system.experiences as |experience key|}} {{#each document._source.system.experiences as |experience key|}}
<li class="experience-item"> <li class="experience-item">
<div class="experience-inner-item {{#if @root.levelupAuto}}no-controls{{/if}}"> <div class="experience-inner-item {{#if @root.levelupAuto}}no-controls{{/if}}">
<input class="name" type="text" name="system.experiences.{{key}}.name" value="{{experience.name}}" /> <input class="name" type="text" name="system.experiences.{{key}}.name" value="{{experience.name}}" />

View file

@ -18,4 +18,5 @@
{{/if}} {{/if}}
{{/if}} {{/if}}
</fieldset> </fieldset>
{{> 'systems/daggerheart/templates/actionTypes/damage.hbs' fields=systemFields.attack.fields.damage.fields.parts.element.fields source=document.system.attack.damage path="system.attack."}}
</section> </section>

View file

@ -3,16 +3,24 @@
data-tab='{{tabs.experiences.id}}' data-tab='{{tabs.experiences.id}}'
data-group='{{tabs.experiences.group}}' data-group='{{tabs.experiences.group}}'
> >
<button type="button" class="add-experience-btn" type="button" data-action="addExperience">
<span>{{localize "DOCUMENT.New" type=(localize "DAGGERHEART.GENERAL.experience.single")}}</span>
</button>
<fieldset> <fieldset>
<legend>{{localize tabs.experiences.label}}</legend> <legend>{{localize tabs.experiences.label}}</legend>
<ul class="experience-list"> <ul class="experience-list">
{{#each document.system.experiences as |experience key|}} {{#each document._source.system.experiences as |experience key|}}
<li class="experience-item"> <li class="experience-item">
<div class="experience-inner-item {{#if @root.levelupAuto}}no-controls{{/if}}">
<input class="name" type="text" name="system.experiences.{{key}}.name" value="{{experience.name}}" /> <input class="name" type="text" name="system.experiences.{{key}}.name" value="{{experience.name}}" />
<input disabled class="modifier" type="text" name="system.experiences.{{key}}.value" value="{{experience.value}}" data-dtype="Number" /> <input class="modifier" type="text" name="system.experiences.{{key}}.value" value="{{experience.value}}" data-dtype="Number" />
{{#unless @root.levelupAuto}}<a data-action="removeExperience" data-experience="{{key}}" data-tooltip="{{localize 'CONTROLS.CommonDelete'}}"><i class="fa-solid fa-trash"></i></a>{{/unless}}
</div>
<textarea name="system.experiences.{{key}}.description">{{experience.description}}</textarea>
</li> </li>
{{/each}} {{/each}}
</ul> </ul>
</fieldset> </fieldset>
</section> </section>

View file

@ -36,7 +36,7 @@
<div class="adversary-navigation"> <div class="adversary-navigation">
{{> 'systems/daggerheart/templates/sheets/global/tabs/tab-navigation.hbs'}} {{> 'systems/daggerheart/templates/sheets/global/tabs/tab-navigation.hbs'}}
<button data-action="openSettings"> <button data-action="openSettings" data-tooltip-text="{{localize "DAGGERHEART.UI.Tooltip.openSheetSettings"}}">
<i class="fa-solid fa-wrench"></i> <i class="fa-solid fa-wrench"></i>
</button> </button>
</div> </div>

View file

@ -12,7 +12,6 @@
<div class='level-div'> <div class='level-div'>
<h3 class='label'> <h3 class='label'>
<button data-action="openSettings">Temp</button>
{{#if (or document.system.needsCharacterSetup document.system.levelData.canLevelUp)}} {{#if (or document.system.needsCharacterSetup document.system.levelData.canLevelUp)}}
<button <button
type="button" type="button"
@ -118,6 +117,7 @@
</div> </div>
{{#> 'systems/daggerheart/templates/sheets/global/tabs/tab-navigation.hbs'}} {{#> 'systems/daggerheart/templates/sheets/global/tabs/tab-navigation.hbs'}}
<button data-action="openSettings" data-tooltip-text="{{localize "DAGGERHEART.UI.Tooltip.openSheetSettings"}}"><i class="fa-solid fa-wrench"></i></button>
<div class="character-downtime-container"> <div class="character-downtime-container">
<button type="button" data-action="useDowntime" data-type="shortRest" data-tooltip="{{localize "DAGGERHEART.APPLICATIONS.Downtime.shortRest.title"}}"> <button type="button" data-action="useDowntime" data-type="shortRest" data-tooltip="{{localize "DAGGERHEART.APPLICATIONS.Downtime.shortRest.title"}}">
<i class="fa-solid fa-chair"></i> <i class="fa-solid fa-chair"></i>

View file

@ -39,7 +39,7 @@
</div> </div>
<div class="companion-navigation"> <div class="companion-navigation">
{{> 'systems/daggerheart/templates/sheets/global/tabs/tab-navigation.hbs'}} {{> 'systems/daggerheart/templates/sheets/global/tabs/tab-navigation.hbs'}}
<button type="button" data-action="openSettings"> <button type="button" data-action="openSettings" data-tooltip-text="{{localize "DAGGERHEART.UI.Tooltip.openSheetSettings"}}">
<i class="fa-solid fa-wrench"></i> <i class="fa-solid fa-wrench"></i>
</button> </button>
</div> </div>