Spells and ranged attacks. Partial cleanup of i18n
This commit is contained in:
parent
5d5af7328c
commit
d09d0905b3
5 changed files with 129 additions and 14 deletions
|
|
@ -10,7 +10,7 @@
|
||||||
],
|
],
|
||||||
"url": "This is auto replaced",
|
"url": "This is auto replaced",
|
||||||
"flags": {},
|
"flags": {},
|
||||||
"version": "0.0.72",
|
"version": "0.0.97",
|
||||||
"compatibility": {
|
"compatibility": {
|
||||||
"minimum": "11",
|
"minimum": "11",
|
||||||
"verified": "11.351"
|
"verified": "11.351"
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,9 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
|
||||||
// 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_spells({id: "spells", type:"system"})
|
||||||
this._get_melee_attacks({id: "melee", type:"system"})
|
this._get_melee_attacks({id: "melee", type:"system"})
|
||||||
|
this._get_ranged_attacks({id: "ranged", type:"system"})
|
||||||
this.#buildInventory()
|
this.#buildInventory()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -68,7 +70,7 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
|
||||||
actions.push({
|
actions.push({
|
||||||
id: actionId,
|
id: actionId,
|
||||||
name: coreModule.api.Utils.i18n("GURPS.attributes" + key),
|
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),
|
encodedValue: [macroType, key].join(this.delimiter),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -79,13 +81,16 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
_get_melee_attacks(parent) {
|
_get_melee_attacks(parent) {
|
||||||
debugger;
|
// debugger;
|
||||||
const macroType = "melee";
|
const macroType = "melee";
|
||||||
let actions = [];
|
let actions = [];
|
||||||
|
|
||||||
let melee_attacks = Object.entries(this.actor.system.melee)
|
let melee_attacks = Object.entries(this.actor.system.melee)
|
||||||
melee_attacks.forEach((a) => {
|
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
|
const value = a[1].level
|
||||||
// img
|
// 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) {
|
_get_skills(parent) {
|
||||||
debugger;
|
// debugger;
|
||||||
const macroType = "skills";
|
const macroType = "skills";
|
||||||
let actions = [];
|
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
|
* Build multiple token actions
|
||||||
* @private
|
* @private
|
||||||
|
|
|
||||||
|
|
@ -28,10 +28,15 @@ export const ACTION_TYPE = {
|
||||||
/**
|
/**
|
||||||
* Groups
|
* Groups
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Note: names are automatically localized. I could have avided some effort if I had realised that sooner.
|
||||||
|
|
||||||
export const GROUP = {
|
export const GROUP = {
|
||||||
attributes: { id: 'attributes', name: 'tokenActionHud.gurps.attributes', type: 'system' },
|
attributes: { id: 'attributes', name: 'GURPS.attributes', type: 'system' },
|
||||||
skills: { id: 'skills', name: 'tokenActionHud.gurps.skills', type: 'system' },
|
skills: { id: 'skills', name: 'GURPS.skills', type: 'system' },
|
||||||
melee: { id: 'melee', name: 'tokenActionHud.gurps.melee', 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' },
|
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' },
|
||||||
|
|
@ -49,7 +54,9 @@ export const GROUP = {
|
||||||
export const ITEM_TYPE = {
|
export const ITEM_TYPE = {
|
||||||
attributes: { groupId: 'attributes' },
|
attributes: { groupId: 'attributes' },
|
||||||
skills: { groupId: 'skills' },
|
skills: { groupId: 'skills' },
|
||||||
|
spells: { groupId: 'spells' },
|
||||||
melee: { groupId: 'melee' },
|
melee: { groupId: 'melee' },
|
||||||
|
ranged: { groupId: 'ranged' },
|
||||||
armor: { groupId: 'armor' },
|
armor: { groupId: 'armor' },
|
||||||
backpack: { groupId: 'containers' },
|
backpack: { groupId: 'containers' },
|
||||||
consumable: { groupId: 'consumables' },
|
consumable: { groupId: 'consumables' },
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,16 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
|
||||||
id: 'skills',
|
id: 'skills',
|
||||||
name: coreModule.api.Utils.i18n('GURPS.skills'),
|
name: coreModule.api.Utils.i18n('GURPS.skills'),
|
||||||
groups: [
|
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',
|
id: 'melee',
|
||||||
name: coreModule.api.Utils.i18n('GURPS.meleeWeapons'),
|
name: coreModule.api.Utils.i18n('GURPS.meleeWeapons'),
|
||||||
groups: [
|
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' }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -85,10 +85,16 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
|
||||||
case 'skills':
|
case 'skills':
|
||||||
this.#handleSkillAction(actor, actionId)
|
this.#handleSkillAction(actor, actionId)
|
||||||
break
|
break
|
||||||
|
case 'spells':
|
||||||
|
this.#handleSpellAction(actor, actionId)
|
||||||
|
break
|
||||||
case 'melee':
|
case 'melee':
|
||||||
this.#handleMeleeAction(actor, actionId)
|
this.#handleMeleeAction(actor, actionId)
|
||||||
break
|
break
|
||||||
}
|
case 'ranged':
|
||||||
|
this.#handleRangedAction(actor, actionId)
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -143,11 +149,20 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
|
||||||
/* Melee attacks are done using the otf method. Grab the otf and pass it to the function. */
|
/* Melee attacks are done using the otf method. Grab the otf and pass it to the function. */
|
||||||
let GURPS = globalThis.GURPS;
|
let GURPS = globalThis.GURPS;
|
||||||
|
|
||||||
debugger;
|
// debugger;
|
||||||
let otf = actionId;
|
let otf = actionId;
|
||||||
GURPS.executeOTF(otf, actor=actor);
|
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 })
|
// doRoll({ actor, formula, targetmods, prefix, thing, chatthing, origtarget: target, optionalArgs: opt })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -158,12 +173,23 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
|
||||||
|
|
||||||
// executeOTF(inputstring, priv = false, event = null, actor = null) {
|
// executeOTF(inputstring, priv = false, event = null, actor = null) {
|
||||||
|
|
||||||
debugger;
|
// debugger;
|
||||||
let otf = actionId;
|
let otf = actionId;
|
||||||
GURPS.executeOTF(otf, actor=actor);
|
GURPS.executeOTF(otf, actor=actor);
|
||||||
|
|
||||||
|
|
||||||
// doRoll({ actor, formula, targetmods, prefix, thing, chatthing, origtarget: target, optionalArgs: opt })
|
// 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);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue