From 8269cb4ac1005d9d83ffb793accb49605f88fe02 Mon Sep 17 00:00:00 2001 From: walcutt Date: Wed, 11 Dec 2024 16:17:00 -0500 Subject: [PATCH] Finish draft 1 character sheet --- hench.mjs | 12 +- module/helpers/mutation-helper.mjs | 6 +- module/sheets/hench-actor-sheet.mjs | 17 +- styles/hench.css | 140 ++++++++++ system.json | 6 +- templates/actors/hench.hbs | 420 +++++++++++++++++++--------- 6 files changed, 451 insertions(+), 150 deletions(-) create mode 100644 styles/hench.css diff --git a/hench.mjs b/hench.mjs index 09c6e0b..8b25a54 100644 --- a/hench.mjs +++ b/hench.mjs @@ -3,9 +3,15 @@ import { HenchDataModel } from "./module/data-models.mjs"; import { HenchActorSheet } from "./module/sheets/hench-actor-sheet.mjs"; Handlebars.registerHelper('int2checkbox', (size, threshold, options) => { - return new Array(size).fill(0).map( + return Array(size).fill(0).map( (e, i) => options.fn({index: i + 1, marked: i < threshold}) - ); + ).reduce((prev, next) => (prev + next), ""); +}); + +Handlebars.registerHelper('partialList', (list, start, end, options) => { + return list.slice(start, end).map( + (e, i) => options.fn({ item: e, index: (start + i)}) + ).reduce((prev, next) => (prev + next), ""); }); Hooks.once("init", () => { @@ -16,6 +22,6 @@ Hooks.once("init", () => { Actors.unregisterSheet('core', ActorSheet); Actors.registerSheet('hench', HenchActorSheet, { makeDefault: true, - label: 'Hench Debug Sheet', + label: 'Hench Sheet', }); }); \ No newline at end of file diff --git a/module/helpers/mutation-helper.mjs b/module/helpers/mutation-helper.mjs index f7cea4d..d77600a 100644 --- a/module/helpers/mutation-helper.mjs +++ b/module/helpers/mutation-helper.mjs @@ -70,7 +70,7 @@ function getDataPathFromString(dataPathString) { } } -export function updateField(actor, dataPathString, value) { +export async function updateField(actor, dataPathString, value) { const dataPath = getDataPathFromString(dataPathString); console.log(`Converted ${dataPathString} to:`); @@ -85,11 +85,11 @@ export function updateField(actor, dataPathString, value) { console.log(`Array write at index ${dataPath.index}`); console.log(copy); - actor.update({ + await actor.update({ [dataPath.path]: copy, }); } else { - actor.update({ + await actor.update({ [dataPath.path]: value }); } diff --git a/module/sheets/hench-actor-sheet.mjs b/module/sheets/hench-actor-sheet.mjs index 384a769..a11d905 100644 --- a/module/sheets/hench-actor-sheet.mjs +++ b/module/sheets/hench-actor-sheet.mjs @@ -52,12 +52,25 @@ export class HenchActorSheet extends ActorSheet { }); // text fields - html.find('.hench-text-input').on('change', (event) => { + html.find('.hench-text-input').on('change', async (event) => { const element = event.currentTarget; const path = element.dataset.fieldPath; const value = element.value; - updateField(this.actor, path, value); + await updateField(this.actor, path, value); + }); + + // harm auto-marking + html.find('.hench-harm-field').on('change', async (event) => { + const element = event.currentTarget; + const primaryPath = element.dataset.fieldPath; + const secondaryPath = element.dataset.dependentPath; + const stringValue = element.value; + + const markedValue = stringValue !== null && stringValue !== undefined && stringValue !== ""; + + await updateField(this.actor, primaryPath, stringValue) + await updateField(this.actor, secondaryPath, markedValue); }); } diff --git a/styles/hench.css b/styles/hench.css new file mode 100644 index 0000000..9697045 --- /dev/null +++ b/styles/hench.css @@ -0,0 +1,140 @@ +/* Color tags */ +.hench-white { + background-color: #FFFFFF; + color: #000000; +} + +.hench-l-grey { + background-color: #DDDDDD; + color: #000000; +} + +.hench-m-grey { + background-color: #BBBBBB; + color: #000000; +} + +.hench-d-grey { + background-color: #444444; + color: #FFFFFF; +} + +.hench-black { + background-color: #111111; + color: #FFFFFF; +} + +/* Flexbox */ +.hench-row { + display: flex; + flex-direction: row; + align-items: stretch; +} + +.hench-sheet-container { + display: flex; + flex-direction: column; + justify-content: center; +} + +.hench-box { + display: flex; + flex-direction: column; + justify-content: center; +} + +.hench-box > * { + flex-grow: 1; + flex-shrink: 0; + align-items: center; +} + +.hench-flex-fixed { + flex-grow: 0; + flex-shrink: 0; +} + +.hench-flex-resizeable { + flex-grow: 1; + flex-shrink: 1; + flex-basis: 0; +} + +.hench-gap-narrow { + gap: 0.5em; +} + +.hench-gap-wide { + gap: 1em; +} + +.hench-padding-narrow { + padding: 0.5em; +} + +.hench-padding-wide { + padding: 1em; +} + +/* Labels */ +.hench-centered { + text-align: center; +} + +/* Inputs */ +.hench-sheet-container input[type="text"], .hench-sheet-container select { + border: 0px; + border-bottom: 1px solid #000; + border-radius: 0px; + + background-color: #00000000; + height: auto; + padding: 0; + padding-top: 1px; + margin: 0; +} + +/* Specific */ + +.hench-row-even{ + justify-content: space-evenly; +} + +.hench-stress-checkboxes-2-rows { + display: flex; + flex-wrap: wrap; + gap: 3.5%; + padding: 3.5%; + justify-content: center; +} + +.hench-stress-checkboxes-2-rows > input[type="checkbox"] { + width: 12.5%; + flex-basis: 12.5%; + margin-left: 0; + margin-right: 0; + margin-bottom: 0.5em; +} + +.hench-icon { + aspect-ratio: 1; + width: 10em; +} + +.hench-harm-fixed-width { + width: 8em; + text-align: center; +} + +.hench-harm-input-cell { + border-left: 1px solid #000; + border-right: 1px solid #000; +} + +.hench-harm-input-cell > input[type=text] { + border: 0px solid #000; +} + +.hench-harm-row { + border-bottom: 1px solid #000; +} \ No newline at end of file diff --git a/system.json b/system.json index 61a458d..1f69142 100644 --- a/system.json +++ b/system.json @@ -4,8 +4,8 @@ "description": "HENCH (2025)", "version": "0.0.0", "compatibility": { - "minimum": "11", - "verified": "11" + "minimum": "12", + "verified": "12" }, "authors": [ { @@ -17,7 +17,7 @@ "esmodules": [ "hench.mjs" ], - "styles": [], + "styles": ["styles/hench.css"], "packs": [], "languages": [], "documentTypes": { diff --git a/templates/actors/hench.hbs b/templates/actors/hench.hbs index b96f08d..00cf6cb 100644 --- a/templates/actors/hench.hbs +++ b/templates/actors/hench.hbs @@ -1,148 +1,290 @@
-

{{ actor.name }}

- -

Details:

- -
-

Name:

-

Look:

-
- Playbook: - +
+ +
+ +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
+ +
+
+ Inclinations +
+
    + {{#each actor.system.fixedInclinations}} +
  • + {{this}} +
  • + {{/each}} +
  • + +
  • +
+
+ +
+ +
-

Details

-
-
    + +
    + +
    {{#each actor.system.details}} -
  • - {{this.question}}: - -
  • +
    + +
    +
    + +
    {{/each}} -
+
+ +
+
+ Mission Planning +
+
    + {{#each actor.system.missionPlanning}} +
  • {{this}}
  • + {{/each}} +
+
-

Inclinations

-
-
    - {{#each actor.system.fixedInclinations}} -
  • {{this}}
  • - {{/each}} -
  • - -
  • -
+ +
+
+
+ +
+
+ {{#int2checkbox maxStress actor.system.stress}} + + {{/int2checkbox}} +
+
-

Mission Planning

-
    - {{#each actor.system.missionPlanning}} -
  • {{this}}
  • - {{/each}} -
- -

Gear Limit: {{actor.system.gearLimit}}

- -

Gear

-
    - {{#each actor.system.fixedGear}} -
  • - - {{this.description}} -
  • - {{/each}} -
  • - - -
  • -
- -

Abilities

-
    - {{#each actor.system.moves}} -
  • - - {{this.name}}: {{this.description}} - {{#if this.hasWriteIn}} - - {{/if}} -
  • - {{/each}} -
  • - - -
  • -
- -

Harm:

-
-

Level 1:

-
    - {{#each actor.system.harm.levelOne}} -
  • - - -
  • - {{/each}} -
-

Level 2:

-
    - {{#each actor.system.harm.levelTwo}} -
  • - - -
  • - {{/each}} -
-

Level 3:

-
    - {{#each actor.system.harm.levelThree}} -
  • - - -
  • - {{/each}} -
-

Level 3:

-
    - {{#each actor.system.harm.levelFour}} -
  • - - -
  • - {{/each}} -
+ +
+
+
+ Gear +
+
+
+ {{#partialList actor.system.fixedGear 0 5}} +
+
+ +
+
+
+ {{item.description}} +
+
+
+ {{/partialList}} +
+
+ {{#partialList actor.system.fixedGear 5 9}} +
+
+ +
+
+
+ {{item.description}} +
+
+
+ {{/partialList}} +
+
+ +
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+ Abilities +
+ {{#each actor.system.moves}} +
+
+ +
+
+
+ +
+
+ {{this.description}} +
+ {{#if this.hasWriteIn}} +
+ +
+ {{/if}} +
+
+ {{/each}} +
+
+ +
+
+
+ +
+
+ +
+
+
+
+
+ +
+
+
+
+ Harm +
+
+ +
+
+ 3: +
+ {{#each actor.system.harm.levelThree}} +
+ +
+ {{/each}} +
+ Need help. +
+
+ +
+
+ 2: +
+ {{#each actor.system.harm.levelTwo}} +
+ +
+ {{/each}} +
+ -1 Card +
+
+ +
+
+ 1: +
+ {{#each actor.system.harm.levelOne}} +
+ +
+ {{/each}} +
+ +
+
+
+
+ +
+
+
+ Experience +
+
+ {{#int2checkbox maxExp actor.system.experience}} +
+ +
+ {{/int2checkbox}} +
+
    + {{#each actor.system.experienceTriggers}} +
  • + {{this.description}} +
  • + {{/each}} +
+
+
+ +
+ +
+
+ Advancements +
+ {{#each actor.system.baseAdvancements}} +
+
+ +
+
+ {{this.description}} +
+
+ {{/each}} +
+ +
+
+ Advancements +
+
+ (Take only after 3 or more advancements) +
+ {{#each actor.system.exAdvancements}} +
+
+ +
+
+ {{this.description}} +
+
+ {{/each}} +
-

Stress: {{ actor.system.stress }}

-
    - {{#int2checkbox maxStress actor.system.stress}} -
  • - {{/int2checkbox}} -
-

Experience Triggers

-
    - {{#each actor.system.experienceTriggers}} -
  • {{this.description}}
  • - {{/each}} -
-

Experience: {{ actor.system.experience }}

-
    - {{#int2checkbox maxExp actor.system.experience}} -
  • - {{/int2checkbox}} -
- -

Advancements

-
    - {{#each actor.system.baseAdvancements}} -
  • {{this.description}}
  • - {{/each}} -
    - {{#each actor.system.exAdvancements}} -
  • {{this.description}}
  • - {{/each}} -
\ No newline at end of file