diff --git a/module.json b/module.json index aaec234..883fe9c 100644 --- a/module.json +++ b/module.json @@ -10,7 +10,7 @@ ], "url": "This is auto replaced", "flags": {}, - "version": "0.0.68", + "version": "0.0.72", "compatibility": { "minimum": "11", "verified": "11.351" diff --git a/scripts/action-handler.js b/scripts/action-handler.js index 046369b..3f82c98 100644 --- a/scripts/action-handler.js +++ b/scripts/action-handler.js @@ -44,9 +44,10 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => { * @private */ #buildCharacterActions () { - debugger; + // debugger; this._get_attributes({id: "attributes", type:"system"}) this._get_skills({id: "skills", type:"system"}) + this._get_melee_attacks({id: "melee", type:"system"}) this.#buildInventory() } @@ -77,6 +78,34 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => { } + _get_melee_attacks(parent) { + debugger; + const macroType = "melee"; + let actions = []; + + let melee_attacks = Object.entries(this.actor.system.melee) + melee_attacks.forEach((a) => { + const key = a[1].name + " (" + a[1].mode + ")"; + const value = a[1].level + // img + + let actionId = key; + let otf = 'M:"' + 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.meleeWeapons'), + encodedValue: [macroType, otf].join(this.delimiter), + }) + + + }); + this.addActions(actions, parent) + + } + _get_skills(parent) { debugger; const macroType = "skills"; diff --git a/scripts/constants.js b/scripts/constants.js index 17737f4..da28a83 100644 --- a/scripts/constants.js +++ b/scripts/constants.js @@ -31,6 +31,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' }, + melee: { id: 'melee', name: 'tokenActionHud.gurps.melee', 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' }, @@ -48,6 +49,7 @@ export const GROUP = { export const ITEM_TYPE = { attributes: { groupId: 'attributes' }, skills: { groupId: 'skills' }, + melee: { groupId: 'melee' }, armor: { groupId: 'armor' }, backpack: { groupId: 'containers' }, consumable: { groupId: 'consumables' }, diff --git a/scripts/defaults.js b/scripts/defaults.js index cdc72f7..b11b6ae 100644 --- a/scripts/defaults.js +++ b/scripts/defaults.js @@ -31,6 +31,14 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => { { ...groups.skills, nestId: 'skills_skills' } ] }, + { + nestId: 'melee', + id: 'melee', + name: coreModule.api.Utils.i18n('GURPS.meleeWeapons'), + groups: [ + { ...groups.melee, nestId: 'melee_melee' } + ] + }, { nestId: 'inventory', id: 'inventory', diff --git a/scripts/roll-handler.js b/scripts/roll-handler.js index efbf24c..9e0022c 100644 --- a/scripts/roll-handler.js +++ b/scripts/roll-handler.js @@ -85,7 +85,10 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => { case 'skills': this.#handleSkillAction(actor, actionId) break - } + case 'melee': + this.#handleMeleeAction(actor, actionId) + break + } } /** @@ -136,6 +139,18 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => { doRoll({ actor, formula, targetmods, prefix, thing, chatthing, origtarget: target, optionalArgs: opt }) } + async #handleMeleeAction(actor, actionId) { + /* Melee attacks are done using the otf method. Grab the otf and pass it to the function. */ + let GURPS = globalThis.GURPS; + + debugger; + let otf = actionId; + GURPS.executeOTF(otf, actor=actor); + + + // 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;