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",
"levelUp": "You can level up",
"maxEvasionBonus": "Max Evasion Increase",
"maxHPBonus": "Max HP Increase",
"pronouns": "Pronouns",
"story": {
"backgroundTitle": "Background",
@ -2244,6 +2246,8 @@
"openItemWorld": "Open Item World",
"openActorWorld": "Open Actor World",
"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",
"equip": "Equip",
"unequip": "Unequip",
@ -2253,7 +2257,8 @@
"rangeAndTarget": "Range & Target",
"dragApplyEffect": "Drag effect to apply it to an actor",
"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 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 achievementIncludesExp = level.achievements.experiences[target.dataset.experience];
if (achievementIncludesExp)
relinkAchievementData.push({ levelKey: key, experience: target.dataset.experience });
const selectionIndex = level.selections.findIndex(
x => x.optionKey === 'experience' && x.data[0] === target.dataset.experience
);
if (selectionIndex !== -1)
acc.push({ levelKey: key, selectionIndex, experience: target.dataset.experience });
relinkSelectionData.push({ levelKey: key, selectionIndex, experience: target.dataset.experience });
});
return acc;
}, []);
if (relinkData.length > 0) {
if (relinkAchievementData.length > 0 || relinkSelectionData.length > 0) {
const confirmed = await foundry.applications.api.DialogV2.confirm({
window: {
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')
});
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[
data.levelKey
].selections.reduce((acc, selection, index) => {

View file

@ -10,6 +10,8 @@ export default class DHCompanionSettings extends DHBaseActorSettings {
classes: ['companion-settings'],
position: { width: 455, height: 'auto' },
actions: {
addExperience: DHCompanionSettings.#addExperience,
removeExperience: DHCompanionSettings.#removeExperience,
levelUp: DHCompanionSettings.#levelUp
}
};
@ -88,6 +90,38 @@ export default class DHCompanionSettings extends DHBaseActorSettings {
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.
* @type {ApplicationClickAction}

View file

@ -24,7 +24,12 @@ export default class DhCharacter extends BaseDataActor {
return {
...super.defineSchema(),
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),
hope: resourceField(6, 'DAGGERHEART.GENERAL.hope')
}),
@ -505,7 +510,7 @@ export default class DhCharacter extends BaseDataActor {
}
prepareBaseData() {
this.evasion = this.class.value?.system?.evasion ?? 0;
this.evasion += this.class.value?.system?.evasion ?? 0;
const currentLevel = this.levelData.level.current;
const currentTier =

View file

@ -6,13 +6,14 @@ const attributeField = label =>
tierMarked: new fields.BooleanField({ initial: false })
});
const resourceField = (max = 0, label, reverse = false) =>
const resourceField = (max = 0, label, reverse = false, maxLabel) =>
new fields.SchemaField({
value: new fields.NumberField({ initial: 0, min: 0, integer: true, label }),
max: new fields.NumberField({
initial: max,
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 })
});

View file

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

View file

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

View file

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

View file

@ -9,9 +9,13 @@
<div class="experiences-inner-container">
{{#each experience.values as |experience id|}}
<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"}}" />
<div class="experience-value">{{numberFormat this.value sign=true}}</div>
</div>
<textarea name="system.experiences.{{key}}.description">{{experience.description}}</textarea>
</div>
{{/each}}
</div>
</fieldset>

View file

@ -8,7 +8,7 @@
<div class="nest-inputs">
<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>{{localize (concat "DAGGERHEART.CONFIG.Traits." key ".name" )}}</div>
<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>
<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.max value=document.system.resources.hitPoints.max localize=true}}
{{formGroup systemFields.resources.fields.hitPoints.fields.value value=document._source.system.resources.hitPoints.value 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.max value=document.system.resources.stress.max 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._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>
</fieldset>
</section>

View file

@ -10,7 +10,7 @@
<fieldset>
<legend>{{localize tabs.experiences.label}}</legend>
<ul class="experience-list">
{{#each document.system.experiences as |experience key|}}
{{#each document._source.system.experiences as |experience key|}}
<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}}" />

View file

@ -18,4 +18,5 @@
{{/if}}
{{/if}}
</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>

View file

@ -3,16 +3,24 @@
data-tab='{{tabs.experiences.id}}'
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>
<legend>{{localize tabs.experiences.label}}</legend>
<ul class="experience-list">
{{#each document.system.experiences as |experience key|}}
{{#each document._source.system.experiences as |experience key|}}
<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 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>
{{/each}}
</ul>
</fieldset>
</section>

View file

@ -36,7 +36,7 @@
<div class="adversary-navigation">
{{> '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>
</button>
</div>

View file

@ -12,7 +12,6 @@
<div class='level-div'>
<h3 class='label'>
<button data-action="openSettings">Temp</button>
{{#if (or document.system.needsCharacterSetup document.system.levelData.canLevelUp)}}
<button
type="button"
@ -118,6 +117,7 @@
</div>
{{#> '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">
<button type="button" data-action="useDowntime" data-type="shortRest" data-tooltip="{{localize "DAGGERHEART.APPLICATIONS.Downtime.shortRest.title"}}">
<i class="fa-solid fa-chair"></i>

View file

@ -39,7 +39,7 @@
</div>
<div class="companion-navigation">
{{> '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>
</button>
</div>