restart #1

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

View file

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

View file

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

View file

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

View file

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

View file

@ -85,8 +85,14 @@ 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);
}
}
})