From fcdd31567dd5d4f8bd04a087761d1f2d589b3528 Mon Sep 17 00:00:00 2001 From: Neill Cox Date: Mon, 6 May 2024 11:22:00 +1000 Subject: [PATCH 1/5] Initial work on attributes --- .gitignore | 4 +++- module.json | 9 +++++---- scripts/action-handler.js | 26 ++++++++++++++++++++++++++ scripts/constants.js | 2 ++ scripts/defaults.js | 9 +++++++++ 5 files changed, 45 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 666d7e4..ba5b1bc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ node_modules/* -*zip +.vscode/ +mkzip.sh +*.zip diff --git a/module.json b/module.json index c5680eb..651f68d 100644 --- a/module.json +++ b/module.json @@ -1,6 +1,6 @@ { "id": "token-action-hud-gurps", - "title": "Token Action HUD GURPS", + "title": "Token Action HUD for GURPS", "description": "Token Action HUD is a repositionable HUD of actions for a selected token", "authors": [ { @@ -10,10 +10,10 @@ ], "url": "This is auto replaced", "flags": {}, - "version": "0.0.2", + "version": "0.0.37", "compatibility": { "minimum": "11", - "verified": "11.313" + "verified": "11.351" }, "esmodules": [ "./scripts/init.js" @@ -63,7 +63,8 @@ } }, "socket": false, - "readme": "https://github.com/Larkinabout/fvtt-token-action-hud-template#readme", + "readme": "http://172.23.0.17:8000/module.json", + "manifest": "http://172.23.0.17:8000/module.json", "download": "http://172.23.0.17:8000/fvtt-token-action-hud-gurps.zip", "protected": false, "coreTranslation": false, diff --git a/scripts/action-handler.js b/scripts/action-handler.js index 9ecae6d..3b4c9b1 100644 --- a/scripts/action-handler.js +++ b/scripts/action-handler.js @@ -28,9 +28,11 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => { let items = this.actor.items items = coreModule.api.Utils.sortItemsByName(items) this.items = items + } if (this.actorType === 'character') { + debugger; this.#buildCharacterActions() } else if (!this.actor) { this.#buildMultipleTokenActions() @@ -42,9 +44,33 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => { * @private */ #buildCharacterActions () { + this._get_attributes({id: "attributes", type:"system"}) this.#buildInventory() } + _get_attributes(parent) { + const macroType = "attributes"; + let actions = []; + + let attributes = Object.entries(this.actor.system.attributes) + attributes.forEach((a) => { + const key = a[0]; + const value = a[1].value + // img + + actions.push({ + id: key, + name: coreModule.api.Utils.i18n(key), + description: coreModule.api.Utils.i18n('GURPS.Attributes'), + encodedValue: [macroType, key].join(this.delimiter), + }) + + + }); + this.addActions(actions, parent) + + } + /** * Build multiple token actions * @private diff --git a/scripts/constants.js b/scripts/constants.js index e520b60..a18211c 100644 --- a/scripts/constants.js +++ b/scripts/constants.js @@ -29,6 +29,7 @@ export const ACTION_TYPE = { * Groups */ export const GROUP = { + attributes: { id: 'attributes', name: 'tokenActionHud.gurps.attributes', 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' }, @@ -44,6 +45,7 @@ export const GROUP = { * Item types */ export const ITEM_TYPE = { + attributes: { groupId: 'attributes' }, armor: { groupId: 'armor' }, backpack: { groupId: 'containers' }, consumable: { groupId: 'consumables' }, diff --git a/scripts/defaults.js b/scripts/defaults.js index 672e2a6..39d5163 100644 --- a/scripts/defaults.js +++ b/scripts/defaults.js @@ -12,6 +12,7 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => { group.listName = `Group: ${coreModule.api.Utils.i18n(group.listName ?? group.name)}` }) const groupsArray = Object.values(groups) + debugger; DEFAULTS = { layout: [ { @@ -37,6 +38,14 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => { { ...groups.rests, nestId: 'utility_rests' }, { ...groups.utility, nestId: 'utility_utility' } ] + }, + { + nestId: 'attributes', + id: 'attributes', + name: coreModule.api.Utils.i18n('GURPS.attributes'), + groups: [ + { ...groups.attributes, nestId: 'attributes_attributes' } + ] } ], groups: groupsArray -- 2.52.0 From b6c3da112705546226c2438f1e370ce6ac9ba831 Mon Sep 17 00:00:00 2001 From: Neill Cox Date: Mon, 6 May 2024 11:27:06 +1000 Subject: [PATCH 2/5] Attribute rolls working --- scripts/action-handler.js | 10 +++++++--- scripts/defaults.js | 10 +++++++++- scripts/roll-handler.js | 25 +++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 4 deletions(-) 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 }) + } } }) -- 2.52.0 From 9a6fab60145ea943fd0a2fab548fabcca41a4c6b Mon Sep 17 00:00:00 2001 From: Neill Cox Date: Mon, 6 May 2024 11:30:52 +1000 Subject: [PATCH 3/5] Skills working --- module.json | 2 +- scripts/action-handler.js | 30 ++++++++++++++++++++++++++++++ scripts/constants.js | 2 ++ scripts/defaults.js | 18 +++++++++--------- scripts/roll-handler.js | 21 +++++++++++++++++++++ 5 files changed, 63 insertions(+), 10 deletions(-) diff --git a/module.json b/module.json index 651f68d..e759258 100644 --- a/module.json +++ b/module.json @@ -10,7 +10,7 @@ ], "url": "This is auto replaced", "flags": {}, - "version": "0.0.37", + "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 6e1c60a..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', @@ -47,14 +55,6 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => { { ...groups.utility, nestId: 'utility_utility' } ] }, - { - nestId: 'attributes', - id: 'attributes', - name: coreModule.api.Utils.i18n('GURPS.attributes'), - groups: [ - { ...groups.attributes, nestId: 'attributes_attributes' } - ] - } ], groups: groupsArray } diff --git a/scripts/roll-handler.js b/scripts/roll-handler.js index c205e42..db7391f 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 } } @@ -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 }) + } } }) -- 2.52.0 From 1d5328a9f108750ae6314e1741bb532fb3222cc5 Mon Sep 17 00:00:00 2001 From: Neill Cox Date: Mon, 6 May 2024 11:33:00 +1000 Subject: [PATCH 4/5] Melee attacks --- module.json | 2 +- scripts/action-handler.js | 31 ++++++++++++++++++++++++++++++- scripts/constants.js | 2 ++ scripts/defaults.js | 8 ++++++++ scripts/roll-handler.js | 5 ++++- 5 files changed, 45 insertions(+), 3 deletions(-) diff --git a/module.json b/module.json index e759258..03e77de 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 db7391f..a9c0ca9 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 + } } /** -- 2.52.0 From 4619b787e57ede58d944b4a2f145d28156d6b4b4 Mon Sep 17 00:00:00 2001 From: Neill Cox Date: Mon, 6 May 2024 11:37:28 +1000 Subject: [PATCH 5/5] Spells and ranged attacks. Partial cleanup of i18n --- module.json | 2 +- scripts/action-handler.js | 72 ++++++++++++++++++++++++++++++++++++--- scripts/constants.js | 13 +++++-- scripts/defaults.js | 22 ++++++++++-- scripts/roll-handler.js | 42 +++++++++++++++++++++-- 5 files changed, 139 insertions(+), 12 deletions(-) diff --git a/module.json b/module.json index 03e77de..99f4d35 100644 --- a/module.json +++ b/module.json @@ -10,7 +10,7 @@ ], "url": "This is auto replaced", "flags": {}, - "version": "0.0.72", + "version": "0.0.97", "compatibility": { "minimum": "11", "verified": "11.351" diff --git a/scripts/action-handler.js b/scripts/action-handler.js index 3f82c98..afc5d70 100644 --- a/scripts/action-handler.js +++ b/scripts/action-handler.js @@ -47,7 +47,9 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => { // debugger; this._get_attributes({id: "attributes", type:"system"}) this._get_skills({id: "skills", type:"system"}) + this._get_spells({id: "spells", type:"system"}) this._get_melee_attacks({id: "melee", type:"system"}) + this._get_ranged_attacks({id: "ranged", type:"system"}) this.#buildInventory() } @@ -68,7 +70,7 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => { actions.push({ id: actionId, name: coreModule.api.Utils.i18n("GURPS.attributes" + key), - description: coreModule.api.Utils.i18n('GURPS.Attributes'), + description: coreModule.api.Utils.i18n('GURPS.attributes'), encodedValue: [macroType, key].join(this.delimiter), }) @@ -79,13 +81,16 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => { } _get_melee_attacks(parent) { - debugger; + // 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 + ")"; + let key = a[1].name; + if (a[1].mode) { + key += ` (${a[1].mode})`; + } const value = a[1].level // img @@ -106,8 +111,39 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => { } + _get_ranged_attacks(parent) { + // debugger; + const macroType = "ranged"; + let actions = []; + + let ranged_attacks = Object.entries(this.actor.system.ranged) + ranged_attacks.forEach((a) => { + let key = a[1].name; + if (a[1].mode) { + key += ` (${a[1].mode})`; + } + const value = a[1].level + // img + + let actionId = key; + let otf = 'R:"' + 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.rangedWeapons'), + encodedValue: [macroType, otf].join(this.delimiter), + }) + + + }); + this.addActions(actions, parent) + + } + _get_skills(parent) { - debugger; + // debugger; const macroType = "skills"; let actions = []; @@ -134,6 +170,34 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => { } + _get_spells(parent) { + // debugger; + const macroType = "spells"; + let actions = []; + + let spells = Object.entries(this.actor.system.spells) + spells.forEach((a) => { + const key = a[1].name; + const value = a[1].level + // img + + let actionId = key; + let otf = 'Sp:"' + 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.Spells'), + 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 da28a83..5dfc46e 100644 --- a/scripts/constants.js +++ b/scripts/constants.js @@ -28,10 +28,15 @@ export const ACTION_TYPE = { /** * Groups */ + +// Note: names are automatically localized. I could have avoided some effort if I had realised that sooner. + 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' }, + attributes: { id: 'attributes', name: 'GURPS.attributes', type: 'system' }, + skills: { id: 'skills', name: 'GURPS.skills', type: 'system' }, + spells: { id: 'spells', name: 'GURPS.spells', type: 'system' }, + melee: { id: 'melee', name: 'GURPS.meleeAttack', type: 'system' }, + ranged: { id: 'ranged', name: 'GURPS.rangedAttack', 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' }, @@ -49,7 +54,9 @@ export const GROUP = { export const ITEM_TYPE = { attributes: { groupId: 'attributes' }, skills: { groupId: 'skills' }, + spells: { groupId: 'spells' }, melee: { groupId: 'melee' }, + ranged: { groupId: 'ranged' }, armor: { groupId: 'armor' }, backpack: { groupId: 'containers' }, consumable: { groupId: 'consumables' }, diff --git a/scripts/defaults.js b/scripts/defaults.js index b11b6ae..c8a92bd 100644 --- a/scripts/defaults.js +++ b/scripts/defaults.js @@ -28,7 +28,16 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => { id: 'skills', name: coreModule.api.Utils.i18n('GURPS.skills'), groups: [ - { ...groups.skills, nestId: 'skills_skills' } + { ...groups.skills, nestId: 'skills_skills' }, + { ...groups.spells, nestId: 'spells_spells' } + ] + }, + { + nestId: 'spells', + id: 'spells', + name: coreModule.api.Utils.i18n('GURPS.spells'), + groups: [ + { ...groups.spells, nestId: 'spells_spells' } ] }, { @@ -36,7 +45,16 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => { id: 'melee', name: coreModule.api.Utils.i18n('GURPS.meleeWeapons'), groups: [ - { ...groups.melee, nestId: 'melee_melee' } + { ...groups.melee, nestId: 'melee_melee' }, + { ...groups.ranged, nestId: 'ranged_ranged' } + ] + }, + { + nestId: 'ranged', + id: 'ranged', + name: coreModule.api.Utils.i18n('GURPS.rangedWeapons'), + groups: [ + { ...groups.ranged, nestId: 'ranged_ranged' } ] }, { diff --git a/scripts/roll-handler.js b/scripts/roll-handler.js index a9c0ca9..23799af 100644 --- a/scripts/roll-handler.js +++ b/scripts/roll-handler.js @@ -85,10 +85,16 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => { case 'skills': this.#handleSkillAction(actor, actionId) break + case 'spells': + this.#handleSpellAction(actor, actionId) + break case 'melee': this.#handleMeleeAction(actor, actionId) break - } + case 'ranged': + this.#handleRangedAction(actor, actionId) + break + } } /** @@ -139,6 +145,27 @@ 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); + } + + async #handleRangedAction(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; @@ -146,12 +173,23 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => { // executeOTF(inputstring, priv = false, event = null, actor = null) { - debugger; + // debugger; let otf = actionId; GURPS.executeOTF(otf, actor=actor); // doRoll({ actor, formula, targetmods, prefix, thing, chatthing, origtarget: target, optionalArgs: opt }) } + + async #handleSpellAction(actor, actionId) { + /* Spells 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); + + + } } }) -- 2.52.0