diff --git a/module.json b/module.json index c7aba3d..aaec234 100644 --- a/module.json +++ b/module.json @@ -10,7 +10,7 @@ ], "url": "This is auto replaced", "flags": {}, - "version": "0.0.58", + "version": "0.0.68", "compatibility": { "minimum": "11", "verified": "11.351" diff --git a/scripts/action-handler.js b/scripts/action-handler.js index 73415f0..046369b 100644 --- a/scripts/action-handler.js +++ b/scripts/action-handler.js @@ -44,7 +44,9 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => { * @private */ #buildCharacterActions () { + debugger; this._get_attributes({id: "attributes", type:"system"}) + this._get_skills({id: "skills", type:"system"}) this.#buildInventory() } @@ -75,6 +77,34 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => { } + _get_skills(parent) { + debugger; + const macroType = "skills"; + let actions = []; + + let skills = Object.entries(this.actor.system.skills) + skills.forEach((a) => { + const key = a[1].name; + const value = a[1].level + // img + + let actionId = key; + let otf = 'Sk:"' + key + '"'; // This is going to end badly if the delimiter is set to ":" + + + actions.push({ + id: actionId, + name: coreModule.api.Utils.i18n(key), + description: coreModule.api.Utils.i18n('GURPS.Skills'), + encodedValue: [macroType, otf].join(this.delimiter), + }) + + + }); + this.addActions(actions, parent) + + } + /** * Build multiple token actions * @private diff --git a/scripts/constants.js b/scripts/constants.js index a18211c..17737f4 100644 --- a/scripts/constants.js +++ b/scripts/constants.js @@ -30,6 +30,7 @@ export const ACTION_TYPE = { */ export const GROUP = { attributes: { id: 'attributes', name: 'tokenActionHud.gurps.attributes', type: 'system' }, + skills: { id: 'skills', name: 'tokenActionHud.gurps.skills', type: 'system' }, armor: { id: 'armor', name: 'tokenActionHud.template.armor', type: 'system' }, equipment: { id: 'equipment', name: 'tokenActionHud.template.equipment', type: 'system' }, consumables: { id: 'consumables', name: 'tokenActionHud.template.consumables', type: 'system' }, @@ -46,6 +47,7 @@ export const GROUP = { */ export const ITEM_TYPE = { attributes: { groupId: 'attributes' }, + skills: { groupId: 'skills' }, armor: { groupId: 'armor' }, backpack: { groupId: 'containers' }, consumable: { groupId: 'consumables' }, diff --git a/scripts/defaults.js b/scripts/defaults.js index a17d9c6..cdc72f7 100644 --- a/scripts/defaults.js +++ b/scripts/defaults.js @@ -12,7 +12,7 @@ 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: [ { @@ -23,6 +23,14 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => { { ...groups.attributes, nestId: 'attributes_attributes' } ] }, + { + nestId: 'skills', + id: 'skills', + name: coreModule.api.Utils.i18n('GURPS.skills'), + groups: [ + { ...groups.skills, nestId: 'skills_skills' } + ] + }, { nestId: 'inventory', id: 'inventory', diff --git a/scripts/roll-handler.js b/scripts/roll-handler.js index c205e42..efbf24c 100644 --- a/scripts/roll-handler.js +++ b/scripts/roll-handler.js @@ -1,6 +1,8 @@ import {doRoll} from "/systems/gurps/module/dierolls/dieroll.js" +// Do we need to use executeOTF? + export let RollHandler = null Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => { @@ -79,6 +81,10 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => { break case 'attributes': this.#handleAttributeAction(actor, actionId) + break + case 'skills': + this.#handleSkillAction(actor, actionId) + break } } @@ -105,7 +111,7 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => { case 'endTurn': if (game.combat?.current?.tokenId === token.id) { await game.combat?.nextTurn() - } + }executeOTF break } } @@ -129,5 +135,20 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => { doRoll({ actor, formula, targetmods, prefix, thing, chatthing, origtarget: target, optionalArgs: opt }) } + + async #handleSkillAction(actor, actionId) { + /* Skills are done using the otf method. Grab the otf and pass it to the function. */ + let GURPS = globalThis.GURPS; + // actor, formula, targetmods, prefix = '', thing = '', chatthing = '', origtarget = -1, optionalArgs = {}, + + // executeOTF(inputstring, priv = false, event = null, actor = null) { + + debugger; + let otf = actionId; + GURPS.executeOTF(otf, actor=actor); + + + // doRoll({ actor, formula, targetmods, prefix, thing, chatthing, origtarget: target, optionalArgs: opt }) + } } })