From f974f260b36b877e1129212f9272ee9f190e9bd9 Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Sun, 31 Dec 2023 15:08:50 -0700 Subject: [PATCH] Add logic helpers for sanity --- module/helpers/index.mjs | 16 +++++++++++++++- .../actors/char-sheet-mvp/partials/stat.hbs | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/module/helpers/index.mjs b/module/helpers/index.mjs index a0e362b..0279f6f 100644 --- a/module/helpers/index.mjs +++ b/module/helpers/index.mjs @@ -5,11 +5,25 @@ import { objectValue } from "./objectValue.mjs"; import { toFriendlyDuration } from "./toFriendlyDuration.mjs"; export default { + + // Complex helpers "dd-schemaOptions": schemaOptions, "dd-array": createArray, "dd-toFriendlyDuration": toFriendlyDuration, "dd-objectValue": objectValue, "dd-expanded": detailsExpanded, + + // Simple helpers "dd-stringify": v => JSON.stringify(v, null, ` `), - "dd-negate": v => !v, + + // Logic helpers + "eq": (a, b) => a == b, + "neq": (a, b) => a != b, + "not": v => !v, + "or": (a, b) => a || b, + "and": (a, b) => a && b, + "nor": (a, b) => !(a || b), + "nand": (a, b) => !(a && b), + "xor": (a, b) => (a || b) && !(a && b), + "xnor": (a, b) => !((a || b) && !(a && b)) }; \ No newline at end of file diff --git a/templates/actors/char-sheet-mvp/partials/stat.hbs b/templates/actors/char-sheet-mvp/partials/stat.hbs index 53f6522..989b5c7 100644 --- a/templates/actors/char-sheet-mvp/partials/stat.hbs +++ b/templates/actors/char-sheet-mvp/partials/stat.hbs @@ -4,7 +4,7 @@ data-stat="{{name}}" data-roll-formula="1{{value}}" data-roll-label="dotdungeon.rolls.stats.{{name}}" - {{disabled (dd-negate (dd-objectValue system (concat "stats." name)))}} + {{disabled (not (dd-objectValue system (concat "stats." name)))}} > {{localize (concat "dotdungeon.actor.pc.stat." name)}}