restart #1

Merged
neillc merged 5 commits from restart into main 2024-05-06 11:41:02 +10:00
5 changed files with 63 additions and 10 deletions
Showing only changes of commit 9a6fab6014 - Show all commits

View file

@ -10,7 +10,7 @@
],
"url": "This is auto replaced",
"flags": {},
"version": "0.0.37",
"version": "0.0.68",
"compatibility": {
"minimum": "11",
"verified": "11.351"

View file

@ -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

View file

@ -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' },

View file

@ -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
}

View file

@ -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 })
}
}
})