Skills workng

This commit is contained in:
Neill Cox 2024-05-05 16:37:08 +10:00
parent 4f5b33d29b
commit 9de7b72c02
5 changed files with 64 additions and 3 deletions

View file

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

View file

@ -44,7 +44,9 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
* @private * @private
*/ */
#buildCharacterActions () { #buildCharacterActions () {
debugger;
this._get_attributes({id: "attributes", type:"system"}) this._get_attributes({id: "attributes", type:"system"})
this._get_skills({id: "skills", type:"system"})
this.#buildInventory() 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 * Build multiple token actions
* @private * @private

View file

@ -30,6 +30,7 @@ export const ACTION_TYPE = {
*/ */
export const GROUP = { export const GROUP = {
attributes: { id: 'attributes', name: 'tokenActionHud.gurps.attributes', type: 'system' }, 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' }, 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' },
@ -46,6 +47,7 @@ export const GROUP = {
*/ */
export const ITEM_TYPE = { export const ITEM_TYPE = {
attributes: { groupId: 'attributes' }, attributes: { groupId: 'attributes' },
skills: { groupId: 'skills' },
armor: { groupId: 'armor' }, armor: { groupId: 'armor' },
backpack: { groupId: 'containers' }, backpack: { groupId: 'containers' },
consumable: { groupId: 'consumables' }, consumable: { groupId: 'consumables' },

View file

@ -23,6 +23,14 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
{ ...groups.attributes, nestId: 'attributes_attributes' } { ...groups.attributes, nestId: 'attributes_attributes' }
] ]
}, },
{
nestId: 'skills',
id: 'skills',
name: coreModule.api.Utils.i18n('GURPS.skills'),
groups: [
{ ...groups.skills, nestId: 'skills_skills' }
]
},
{ {
nestId: 'inventory', nestId: 'inventory',
id: 'inventory', id: 'inventory',

View file

@ -1,6 +1,8 @@
import {doRoll} from "/systems/gurps/module/dierolls/dieroll.js" import {doRoll} from "/systems/gurps/module/dierolls/dieroll.js"
// Do we need to use executeOTF?
export let RollHandler = null export let RollHandler = null
Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => { Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
@ -79,6 +81,10 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
break break
case 'attributes': case 'attributes':
this.#handleAttributeAction(actor, actionId) this.#handleAttributeAction(actor, actionId)
break
case 'skills':
this.#handleSkillAction(actor, actionId)
break
} }
} }
@ -105,7 +111,7 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
case 'endTurn': case 'endTurn':
if (game.combat?.current?.tokenId === token.id) { if (game.combat?.current?.tokenId === token.id) {
await game.combat?.nextTurn() await game.combat?.nextTurn()
} }executeOTF
break break
} }
} }
@ -129,5 +135,20 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
doRoll({ actor, formula, targetmods, prefix, thing, chatthing, origtarget: target, optionalArgs: opt }) 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 })
}
} }
}) })