Melee attacks

This commit is contained in:
Neill Cox 2024-05-06 11:33:00 +10:00
parent 9a6fab6014
commit 1d5328a9f1
5 changed files with 45 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.68", "version": "0.0.72",
"compatibility": { "compatibility": {
"minimum": "11", "minimum": "11",
"verified": "11.351" "verified": "11.351"

View file

@ -44,9 +44,10 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
* @private * @private
*/ */
#buildCharacterActions () { #buildCharacterActions () {
debugger; // debugger;
this._get_attributes({id: "attributes", type:"system"}) this._get_attributes({id: "attributes", type:"system"})
this._get_skills({id: "skills", type:"system"}) this._get_skills({id: "skills", type:"system"})
this._get_melee_attacks({id: "melee", type:"system"})
this.#buildInventory() this.#buildInventory()
} }
@ -77,6 +78,34 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
} }
_get_melee_attacks(parent) {
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 + ")";
const value = a[1].level
// img
let actionId = key;
let otf = 'M:"' + 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.meleeWeapons'),
encodedValue: [macroType, otf].join(this.delimiter),
})
});
this.addActions(actions, parent)
}
_get_skills(parent) { _get_skills(parent) {
debugger; debugger;
const macroType = "skills"; const macroType = "skills";

View file

@ -31,6 +31,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' }, skills: { id: 'skills', name: 'tokenActionHud.gurps.skills', type: 'system' },
melee: { id: 'melee', name: 'tokenActionHud.gurps.melee', 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' },
@ -48,6 +49,7 @@ export const GROUP = {
export const ITEM_TYPE = { export const ITEM_TYPE = {
attributes: { groupId: 'attributes' }, attributes: { groupId: 'attributes' },
skills: { groupId: 'skills' }, skills: { groupId: 'skills' },
melee: { groupId: 'melee' },
armor: { groupId: 'armor' }, armor: { groupId: 'armor' },
backpack: { groupId: 'containers' }, backpack: { groupId: 'containers' },
consumable: { groupId: 'consumables' }, consumable: { groupId: 'consumables' },

View file

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

View file

@ -85,6 +85,9 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
case 'skills': case 'skills':
this.#handleSkillAction(actor, actionId) this.#handleSkillAction(actor, actionId)
break break
case 'melee':
this.#handleMeleeAction(actor, actionId)
break
} }
} }