refactor(#266): move private sanity logic into prepareContext

This commit is contained in:
Tobias Frölich
2025-09-29 08:11:45 +02:00
committed by Tobias Frölich
parent ee149dfcaf
commit ed54e2dbd8
3 changed files with 26 additions and 16 deletions
+6
View File
@@ -1,5 +1,11 @@
# 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).
+15
View File
@@ -94,6 +94,21 @@ export default class DGActorSheet extends DGSheetMixin(ActorSheetV2) {
this._prepareSkillTooltips();
}
// Handle private sanity setting, override for GMs.
const keepSanityPrivate = game.settings.get(
"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;
}
// Set sanity block per actor type.
context.sanityInputs = await foundry.applications.handlebars.renderTemplate(
`${DGActorSheet.TEMPLATE_PATH}/partials/sanity-${this.actor.type}.html`,
+5 -16
View File
@@ -1,27 +1,16 @@
{{#if (keepSanityPrivate)}}
<input class="centered"
type="text"
name="system.sanity.value"
value="???"
readonly
data-dtype="Number" />
<span>/</span>
<div class="max-resource-value"
data-tooltip="{{localize 'DG.Tooltip.MaximumSanity'}}">
<div>???</div>
</div>
{{else}}
<input class="centered
{{#if actor.system.sanity.breakingPointHit }}
breaking-point-hit{{/if }}"
type="text"
name="system.sanity.value"
value="{{actor.system.sanity.value }}"
{{#if keepSanityPrivate }}
readonly
{{/if }}
value="{{ currentSan }}"
data-dtype="Number"
data-tooltip="{{localize 'DG.Tooltip.CurrentSanityPartOne' }}{{actor.system.sanity.currentBreakingPoint }}{{localize 'DG.Tooltip.CurrentSanityPartTwo' }}" />
<span>/</span>
<div class="max-resource-value"
data-tooltip="{{localize 'DG.Tooltip.MaximumSanity'}}">
<div>{{numberFormat actor.system.sanity.max decimals=0 sign=false}}</div>
<div>{{ maxSan }}</div>
</div>
{{/if}}