diff --git a/hench.mjs b/hench.mjs index b8b5c29..c580974 100644 --- a/hench.mjs +++ b/hench.mjs @@ -2,6 +2,12 @@ import { HenchDataModel } from "./module/data-models.mjs"; import { HenchDebugSheet } from "./module/sheets/hench-debug.mjs"; +Handlebars.registerHelper('int2checkbox', (size, threshold, options) => { + return new Array(size).fill(0).map( + (e, i) => options.fn({index: i + 1, marked: i < threshold}) + ); +}); + Hooks.once("init", () => { CONFIG.Actor.dataModels = { hench: HenchDataModel, diff --git a/module/helpers/object-helper.mjs b/module/helpers/object-helper.mjs index 409954d..60615ef 100644 --- a/module/helpers/object-helper.mjs +++ b/module/helpers/object-helper.mjs @@ -75,6 +75,7 @@ export function updateField(actor, dataPathString, value) { console.log(`Converted ${dataPathString} to:`); console.log(dataPath); + console.log(`Writing: ${value}`); if(dataPath.isArray) { const initial = getValueAtPath(actor, dataPath.path); diff --git a/module/sheets/hench-debug.mjs b/module/sheets/hench-debug.mjs index a270018..d8d5519 100644 --- a/module/sheets/hench-debug.mjs +++ b/module/sheets/hench-debug.mjs @@ -13,6 +13,10 @@ export class HenchDebugSheet extends ActorSheet { context.playbookKeys = [...playbookKeys, 'test'].map((k) => ({ key: k, selected: k === this.actor.system.playbook})); + // TODO define system constants for these + context.maxStress = 12; + context.maxExp = 5; + return context; } @@ -33,6 +37,18 @@ export class HenchDebugSheet extends ActorSheet { updateField(this.actor, path, value); }); + + // int checkboxes + html.find('.hench-checkbox-int-field').on('change', (event) => { + const element = event.currentTarget; + const path = element.dataset.fieldPath; + const checked = element.checked; + const valueData = parseInt(element.dataset.value); + + const value = checked ? valueData : valueData - 1; + + updateField(this.actor, path, value); + }); } _changePlaybook(newPlaybookKeyEvent) { diff --git a/templates/hench-debug.hbs b/templates/hench-debug.hbs index a4416bd..7fbaa0f 100644 --- a/templates/hench-debug.hbs +++ b/templates/hench-debug.hbs @@ -41,9 +41,10 @@
Stress: {{ actor.system.stress }}
+Experience: {{ actor.system.experience }}
+