From e377bda6444623fee0c857dcc8f2618ceec9e52e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Fr=C3=B6lich?= Date: Wed, 10 Sep 2025 09:31:50 +0200 Subject: [PATCH] chore: improve private sanity logic readability --- CHANGELOG.md | 6 -- module/sheets/base-actor-sheet.js | 144 ++++++++++++------------------ 2 files changed, 57 insertions(+), 93 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 33ec08c..7c7aec2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,5 @@ # Release/Patch Notes -## Version 1.7.0 - ????-??-?? - -### **Tech Debt** - -- [#267](https://github.com/deltagreen-foundryvtt/delta-green-foundry-vtt-system/pull/267) - Moved private sanity logic out of templates. - ## Version 1.6.1 - 2025-09-09 > Thanks to the following new contributor: [Tobifroe](https://github.com/tobifroe). diff --git a/module/sheets/base-actor-sheet.js b/module/sheets/base-actor-sheet.js index 76bd6bc..9b4e0f8 100644 --- a/module/sheets/base-actor-sheet.js +++ b/module/sheets/base-actor-sheet.js @@ -99,15 +99,11 @@ export default class DGActorSheet extends DGSheetMixin(ActorSheetV2) { "deltagreen", "keepSanityPrivate", ); - if (keepSanityPrivate && !game.user.isGM) { - context.maxSan = "???"; - context.currentSan = "???"; - context.keepSanityPrivate = true; - } else { - context.maxSan = this.actor.system.sanity.max; - context.currentSan = this.actor.system.sanity.value; - context.keepSanityPrivate = false; - } + const hideSan = keepSanityPrivate && !game.user.isGM; + + context.maxSan = hideSan ? "???" : this.actor.system.sanity.max; + context.currentSan = hideSan ? "???" : this.actor.system.sanity.value; + context.keepSanityPrivate = keepSanityPrivate; // Set sanity block per actor type. context.sanityInputs = await foundry.applications.handlebars.renderTemplate( @@ -784,110 +780,94 @@ export default class DGActorSheet extends DGSheetMixin(ActorSheetV2) { const currentGroup = typedSkills[targetSkill].group; let htmlContent = `
`; - htmlContent += ` `; + htmlContent += ` `; htmlContent += ` `; htmlContent += `
`; htmlContent += `
`; - htmlContent += ` `; + htmlContent += ` `; htmlContent += ` `; htmlContent += `
`; @@ -925,40 +905,31 @@ export default class DGActorSheet extends DGSheetMixin(ActorSheetV2) { let htmlContent = ""; htmlContent += `
`; - htmlContent += ` `; + htmlContent += ` `; htmlContent += ` `; htmlContent += `
`; htmlContent += `
`; - htmlContent += ` `; + htmlContent += ` `; htmlContent += ` `; htmlContent += `
`; @@ -1096,9 +1067,8 @@ export default class DGActorSheet extends DGSheetMixin(ActorSheetV2) { ([key, skill]) => ({ value: key, group: optionGroups.typedSkills, - label: `${game.i18n.localize(`DG.TypeSkills.${skill.group}`)} (${ - skill.label - })`, + label: `${game.i18n.localize(`DG.TypeSkills.${skill.group}`)} (${skill.label + })`, targetNumber: skill.proficiency, }), );