diff --git a/scripts/action-handler.js b/scripts/action-handler.js index 3b4c9b1..73415f0 100644 --- a/scripts/action-handler.js +++ b/scripts/action-handler.js @@ -32,7 +32,7 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => { } if (this.actorType === 'character') { - debugger; + //debugger; this.#buildCharacterActions() } else if (!this.actor) { this.#buildMultipleTokenActions() @@ -58,9 +58,13 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => { const value = a[1].value // img + let actionId = key + if ( key == "WILL" ) actionId = "Will"; + if ( key == "PER" ) actionId = "Per"; + actions.push({ - id: key, - name: coreModule.api.Utils.i18n(key), + id: actionId, + name: coreModule.api.Utils.i18n("GURPS.attributes" + key), description: coreModule.api.Utils.i18n('GURPS.Attributes'), encodedValue: [macroType, key].join(this.delimiter), }) diff --git a/scripts/defaults.js b/scripts/defaults.js index 39d5163..6e1c60a 100644 --- a/scripts/defaults.js +++ b/scripts/defaults.js @@ -12,9 +12,17 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => { group.listName = `Group: ${coreModule.api.Utils.i18n(group.listName ?? group.name)}` }) const groupsArray = Object.values(groups) - debugger; + //debugger; DEFAULTS = { layout: [ + { + nestId: 'attributes', + id: 'attributes', + name: coreModule.api.Utils.i18n('GURPS.attributes'), + groups: [ + { ...groups.attributes, nestId: 'attributes_attributes' } + ] + }, { nestId: 'inventory', id: 'inventory', diff --git a/scripts/roll-handler.js b/scripts/roll-handler.js index ea9f716..c205e42 100644 --- a/scripts/roll-handler.js +++ b/scripts/roll-handler.js @@ -1,3 +1,6 @@ + +import {doRoll} from "/systems/gurps/module/dierolls/dieroll.js" + export let RollHandler = null Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => { @@ -74,6 +77,8 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => { case 'utility': this.#handleUtilityAction(token, actionId) break + case 'attributes': + this.#handleAttributeAction(actor, actionId) } } @@ -104,5 +109,25 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => { break } } + + async #handleAttributeAction(actor, actionId) { + // actor, formula, targetmods, prefix = '', thing = '', chatthing = '', origtarget = -1, optionalArgs = {}, + + if ( actionId == "WILL" ) actionId = "Will"; + if ( actionId == "PER" ) actionId = "Per"; + // debugger; + let formula = '3d6'; + let targetmods = null; + let prefix = "Rolls vs" // should be i18n of 'GURPS.rollVs' + let attrname = coreModule.api.Utils.i18n(GURPS.attributeNames[actionId]) + let thing = attrname; // actionID ? + let chatthing = attrname + "/[@" + actor.id + "@" + coreModule.api.Utils.i18n(GURPS.attributes[actionId]) +"]"; + let target = actor.system.attributes[actionId.toUpperCase()].value; + let opt = {}; + + + + doRoll({ actor, formula, targetmods, prefix, thing, chatthing, origtarget: target, optionalArgs: opt }) + } } })