Merge pull request #267 from deltagreen-foundryvtt/tobifroe/266/refactor-hidden-sanity
refactor(#266): move private sanity logic into prepareContext
This commit is contained in:
@@ -94,6 +94,17 @@ export default class DGActorSheet extends DGSheetMixin(ActorSheetV2) {
|
||||
this._prepareSkillTooltips();
|
||||
}
|
||||
|
||||
// Handle private sanity setting, override for GMs.
|
||||
const keepSanityPrivate = game.settings.get(
|
||||
"deltagreen",
|
||||
"keepSanityPrivate",
|
||||
);
|
||||
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(
|
||||
`${DGActorSheet.TEMPLATE_PATH}/partials/sanity-${this.actor.type}.html`,
|
||||
|
||||
@@ -1,27 +1,14 @@
|
||||
{{#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 }}"
|
||||
{{disabled keepSanityPrivate}}
|
||||
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}}
|
||||
|
||||
Reference in New Issue
Block a user