From fcdd31567dd5d4f8bd04a087761d1f2d589b3528 Mon Sep 17 00:00:00 2001 From: Neill Cox Date: Mon, 6 May 2024 11:22:00 +1000 Subject: [PATCH] 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