From 5c3301b88edeb628998799e35c2d239b4249b2e0 Mon Sep 17 00:00:00 2001 From: rwanoux Date: Wed, 15 May 2024 10:36:45 +0200 Subject: [PATCH] fixe hexa radios --- module/sheets/actor-sheet.mjs | 35 ++++++++++++++----- module/sheets/character-sheet.mjs | 5 +++ .../actor/character/character-combat.hbs | 12 +++---- 3 files changed, 37 insertions(+), 15 deletions(-) diff --git a/module/sheets/actor-sheet.mjs b/module/sheets/actor-sheet.mjs index da48479..16641a1 100644 --- a/module/sheets/actor-sheet.mjs +++ b/module/sheets/actor-sheet.mjs @@ -40,6 +40,8 @@ export class VermineActorSheet extends ActorSheet { // Add the actor's data to context.data for easier access, as well as flags. context.system = actorData.system; context.flags = actorData.flags; + + //add system config for convenience use context.config = CONFIG.VERMINE; // Add roll data for TinyMCE editors. @@ -48,6 +50,7 @@ export class VermineActorSheet extends ActorSheet { // Prepare active effects context.effects = prepareActiveEffectCategories(this.actor.effects); + return context; } @@ -92,22 +95,33 @@ export class VermineActorSheet extends ActorSheet { } //click on wound radio - html.find('.hexa [type="radio"]').change(ev => { - ev.preventDefault() - console.log(ev.target.checked, "CHECK______________________") + html.find('.hexa [type="radio"]').click(ev => { + ev.preventDefault(); + ev.stopPropagation(); + return this._onClickRadioHexa(ev) }) } _onClickRadioHexa(ev) { - console.log("________________iiiiiii") - if (!ev.currentTarget.checked) { return false }; - ev.preventDefault(); - let prop = ev.currentTarget.name; + let input = ev.currentTarget; + console.log(input.value, input.name); let update = {}; - update[prop] = ev.currentTarget.value - 1 + update[input.name] = 0 + let propTree = input.name.split('.') + let current = this.actor; + for (let prop of propTree) { + current = current[prop] + } + if (current != input.value) { + update[input.name] = parseInt(input.value) + + } else { + update[input.name] = parseInt(input.value) - 1; + } + this.actor.update(update) + - return this.actor.update(update) } async _onMinMaxEdit(event) { @@ -162,4 +176,7 @@ export class VermineActorSheet extends ActorSheet { // Finally, create the item! return await Item.create(itemData, { parent: this.actor }); } + async getGroup() { + return await game.actors.find(group => { group == group - 1 }) + } } diff --git a/module/sheets/character-sheet.mjs b/module/sheets/character-sheet.mjs index a2d1896..f0ed7b1 100644 --- a/module/sheets/character-sheet.mjs +++ b/module/sheets/character-sheet.mjs @@ -56,6 +56,11 @@ export class VermineCharacterSheet extends VermineActorSheet { // Add roll data for TinyMCE editors. context.rollData = context.actor.getRollData(); + + //get the group actor + context.group = this.getGroup() + + // Prepare active effects context.effects = prepareActiveEffectCategories(this.actor.effects); diff --git a/templates/actor/character/character-combat.hbs b/templates/actor/character/character-combat.hbs index 624db3b..f38e7b1 100644 --- a/templates/actor/character/character-combat.hbs +++ b/templates/actor/character/character-combat.hbs @@ -103,9 +103,9 @@ checked {{/iflteq}} " - {{#iflteq @minorwoundmax @root.system.minorWound.value }} + {{#ife @minorwoundmax @root.system.minorWound.value }} checked="true" - {{/iflteq}} /> + {{/ife}} /> {{/repeat}} @@ -127,9 +127,9 @@ {{/iflteq}} " - {{#iflteq @minorwoundmax @root.system.majorWound.value }} + {{#ife @majourwoundmax @root.system.majorWound.value }} checked="true" - {{/iflteq}} /> + {{/ife}} /> {{/repeat}} @@ -153,9 +153,9 @@ {{/iflteq}} " - {{#iflteq @minorwoundmax @root.system.deadlyWound.value }} + {{#ife @deadlywoundmax @root.system.deadlyWound.value }} checked="true" - {{/iflteq}} /> + {{/ife}} /> {{/repeat}}