diff --git a/source/index.ts b/source/index.ts index 1eec7ed..afc2ab3 100644 --- a/source/index.ts +++ b/source/index.ts @@ -9,6 +9,13 @@ import { M5Item } from "./module/items/M5Item" Hooks.once("init", async () => { Logger.log("M5 | Initialisierung Midgard 5") + Handlebars.registerHelper("times", (n: number, block) => { + var accum = "" + for(let i = 0; i < n; ++i) + accum += block.fn(i) + return accum + }) + Handlebars.registerHelper("array", (arr: any[], index: number) => { return arr[index] }) @@ -34,15 +41,11 @@ Hooks.once("init", async () => { Handlebars.registerHelper("skillBonus", (actorId: string, skill: M5Skill) => { const actor = (game as Game).actors.get(actorId) as M5Character - if (!actor || !skill) - console.log("Handlebars.skillBonus", actor, skill) return actor.skillBonus(skill).toString() }) Handlebars.registerHelper("skillEw", (actorId: string, skill: M5Skill) => { const actor = (game as Game).actors.get(actorId) as M5Character - if (!actor || !skill) - console.log("Handlebars.skillEw", actor, skill) return actor.skillEw(skill).toString() }) diff --git a/source/module/sheets/M5CharacterSheet.ts b/source/module/sheets/M5CharacterSheet.ts index d9520c9..a64b29b 100644 --- a/source/module/sheets/M5CharacterSheet.ts +++ b/source/module/sheets/M5CharacterSheet.ts @@ -45,6 +45,30 @@ export default class M5CharacterSheet extends ActorSheet { override activateListeners(html: JQuery) { super.activateListeners(html) + html.find(".update-lp").on("click", async (event) => { + const valueStr = event.target.dataset["value"] + const value = parseInt(valueStr) + this.actor.update({ + data: { + lp: { + value: value + 1 + } + } + }) + }) + + html.find(".update-ap").on("click", async (event) => { + const valueStr = event.target.dataset["value"] + const value = parseInt(valueStr) + this.actor.update({ + data: { + ap: { + value: value + 1 + } + } + }) + }) + html.find(".roll-attribute-button").on("click", async (event) => { const attributeStr = event.target.dataset["attribute"] const roll = M5Roll.fromAttribute(this.actor, attributeStr) diff --git a/source/style/Character-sheet.less b/source/style/Character-sheet.less index 224ed1f..e0684ab 100644 --- a/source/style/Character-sheet.less +++ b/source/style/Character-sheet.less @@ -90,6 +90,47 @@ flex: 1 1 auto; } + .health-bar { + height: 2rem; + background-color: rgba(0, 0, 0, 0.8); + display: flex; + flex-direction: row; + gap: 1px; + padding: 1px; + //align-items: stretch; + + input { + flex: 0 0 3rem; + text-align: center; + height: 100%; + background-color: rgba(109, 108, 102, 1); + color: rgba(255, 255, 255, 1); + font-weight: bold; + border-radius: 0; + } + + .lp-bar-item-empty, + .ap-bar-item-empty { + flex-grow: 1; + background-color: rgb(201, 201, 201); + } + + .lp-bar-item { + flex-grow: 1; + background-color: rgb(57, 234, 139); + } + + .ap-bar-item { + flex-grow: 1; + background-color: rgb(57, 163, 234); + } + + .negative-bar-item { + flex-grow: 1; + background-color: rgb(234, 57, 57); + } + } + .attributes { display: flex; flex-direction: row; diff --git a/templates/sheets/character/base_values.hbs b/templates/sheets/character/base_values.hbs index d164e39..b159492 100644 --- a/templates/sheets/character/base_values.hbs +++ b/templates/sheets/character/base_values.hbs @@ -1,3 +1,34 @@ + +

{{localize "midgard5.actor-lp"}}

+
+
+ + {{#times data.lp.max}} + {{#if (lt this ../data.lp.value)}} +
+ {{else}} +
+ {{/if}} + {{/times}} + +
+
+ +

{{localize "midgard5.actor-ap"}}

+
+
+ + {{#times data.ap.max}} + {{#if (lt this ../data.ap.value)}} +
+ {{else}} +
+ {{/if}} + {{/times}} + +
+
+

Eigenschaften

{{localize "midgard5.class"}} @@ -10,16 +41,12 @@ - - - -
{{localize "midgard5.actor-lp"}} {{localize "midgard5.maximum"}} {{localize "midgard5.grace"}} {{localize "midgard5.exp-overall"}}
{{localize "midgard5.actor-ap"}} {{localize "midgard5.maximum"}} {{localize "midgard5.destiny"}} {{localize "midgard5.exp-available"}}