Initial work on attributes

This commit is contained in:
Neill Cox 2024-05-06 11:22:00 +10:00
parent 3ab2643f31
commit fcdd31567d
5 changed files with 45 additions and 5 deletions

4
.gitignore vendored
View file

@ -1,2 +1,4 @@
node_modules/* node_modules/*
*zip .vscode/
mkzip.sh
*.zip

View file

@ -1,6 +1,6 @@
{ {
"id": "token-action-hud-gurps", "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", "description": "Token Action HUD is a repositionable HUD of actions for a selected token",
"authors": [ "authors": [
{ {
@ -10,10 +10,10 @@
], ],
"url": "This is auto replaced", "url": "This is auto replaced",
"flags": {}, "flags": {},
"version": "0.0.2", "version": "0.0.37",
"compatibility": { "compatibility": {
"minimum": "11", "minimum": "11",
"verified": "11.313" "verified": "11.351"
}, },
"esmodules": [ "esmodules": [
"./scripts/init.js" "./scripts/init.js"
@ -63,7 +63,8 @@
} }
}, },
"socket": false, "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", "download": "http://172.23.0.17:8000/fvtt-token-action-hud-gurps.zip",
"protected": false, "protected": false,
"coreTranslation": false, "coreTranslation": false,

View file

@ -28,9 +28,11 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
let items = this.actor.items let items = this.actor.items
items = coreModule.api.Utils.sortItemsByName(items) items = coreModule.api.Utils.sortItemsByName(items)
this.items = items this.items = items
} }
if (this.actorType === 'character') { if (this.actorType === 'character') {
debugger;
this.#buildCharacterActions() this.#buildCharacterActions()
} else if (!this.actor) { } else if (!this.actor) {
this.#buildMultipleTokenActions() this.#buildMultipleTokenActions()
@ -42,9 +44,33 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
* @private * @private
*/ */
#buildCharacterActions () { #buildCharacterActions () {
this._get_attributes({id: "attributes", type:"system"})
this.#buildInventory() 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 * Build multiple token actions
* @private * @private

View file

@ -29,6 +29,7 @@ export const ACTION_TYPE = {
* Groups * Groups
*/ */
export const GROUP = { export const GROUP = {
attributes: { id: 'attributes', name: 'tokenActionHud.gurps.attributes', type: 'system' },
armor: { id: 'armor', name: 'tokenActionHud.template.armor', type: 'system' }, armor: { id: 'armor', name: 'tokenActionHud.template.armor', type: 'system' },
equipment: { id: 'equipment', name: 'tokenActionHud.template.equipment', type: 'system' }, equipment: { id: 'equipment', name: 'tokenActionHud.template.equipment', type: 'system' },
consumables: { id: 'consumables', name: 'tokenActionHud.template.consumables', type: 'system' }, consumables: { id: 'consumables', name: 'tokenActionHud.template.consumables', type: 'system' },
@ -44,6 +45,7 @@ export const GROUP = {
* Item types * Item types
*/ */
export const ITEM_TYPE = { export const ITEM_TYPE = {
attributes: { groupId: 'attributes' },
armor: { groupId: 'armor' }, armor: { groupId: 'armor' },
backpack: { groupId: 'containers' }, backpack: { groupId: 'containers' },
consumable: { groupId: 'consumables' }, consumable: { groupId: 'consumables' },

View file

@ -12,6 +12,7 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
group.listName = `Group: ${coreModule.api.Utils.i18n(group.listName ?? group.name)}` group.listName = `Group: ${coreModule.api.Utils.i18n(group.listName ?? group.name)}`
}) })
const groupsArray = Object.values(groups) const groupsArray = Object.values(groups)
debugger;
DEFAULTS = { DEFAULTS = {
layout: [ layout: [
{ {
@ -37,6 +38,14 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
{ ...groups.rests, nestId: 'utility_rests' }, { ...groups.rests, nestId: 'utility_rests' },
{ ...groups.utility, nestId: 'utility_utility' } { ...groups.utility, nestId: 'utility_utility' }
] ]
},
{
nestId: 'attributes',
id: 'attributes',
name: coreModule.api.Utils.i18n('GURPS.attributes'),
groups: [
{ ...groups.attributes, nestId: 'attributes_attributes' }
]
} }
], ],
groups: groupsArray groups: groupsArray