Attribute rolls working

This commit is contained in:
Neill Cox 2024-05-05 11:22:51 +10:00
parent 03761d2e2f
commit 4f5b33d29b
4 changed files with 42 additions and 13 deletions

View file

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

View file

@ -32,7 +32,7 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
} }
if (this.actorType === 'character') { if (this.actorType === 'character') {
debugger; //debugger;
this.#buildCharacterActions() this.#buildCharacterActions()
} else if (!this.actor) { } else if (!this.actor) {
this.#buildMultipleTokenActions() this.#buildMultipleTokenActions()
@ -58,9 +58,13 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
const value = a[1].value const value = a[1].value
// img // img
let actionId = key
if ( key == "WILL" ) actionId = "Will";
if ( key == "PER" ) actionId = "Per";
actions.push({ actions.push({
id: key, id: actionId,
name: coreModule.api.Utils.i18n(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),
}) })

View file

@ -12,9 +12,17 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
group.listName = `Group: ${coreModule.api.Utils.i18n(group.listName ?? group.name)}` group.listName = `Group: ${coreModule.api.Utils.i18n(group.listName ?? group.name)}`
}) })
const groupsArray = Object.values(groups) const groupsArray = Object.values(groups)
debugger; //debugger;
DEFAULTS = { DEFAULTS = {
layout: [ layout: [
{
nestId: 'attributes',
id: 'attributes',
name: coreModule.api.Utils.i18n('GURPS.attributes'),
groups: [
{ ...groups.attributes, nestId: 'attributes_attributes' }
]
},
{ {
nestId: 'inventory', nestId: 'inventory',
id: 'inventory', id: 'inventory',
@ -39,14 +47,6 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
{ ...groups.utility, nestId: 'utility_utility' } { ...groups.utility, nestId: 'utility_utility' }
] ]
}, },
{
nestId: 'attributes',
id: 'attributes',
name: coreModule.api.Utils.i18n('GURPS.attributes'),
groups: [
{ ...groups.attributes, nestId: 'attributes_attributes' }
]
}
], ],
groups: groupsArray groups: groupsArray
} }

View file

@ -1,3 +1,6 @@
import {doRoll} from "/systems/gurps/module/dierolls/dieroll.js"
export let RollHandler = null export let RollHandler = null
Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => { Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
@ -74,6 +77,8 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
case 'utility': case 'utility':
this.#handleUtilityAction(token, actionId) this.#handleUtilityAction(token, actionId)
break break
case 'attributes':
this.#handleAttributeAction(actor, actionId)
} }
} }
@ -104,5 +109,25 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
break break
} }
} }
async #handleAttributeAction(actor, actionId) {
// actor, formula, targetmods, prefix = '', thing = '', chatthing = '', origtarget = -1, optionalArgs = {},
if ( actionId == "WILL" ) actionId = "Will";
if ( actionId == "PER" ) actionId = "Per";
// debugger;
let formula = '3d6';
let targetmods = null;
let prefix = "Rolls vs" // should be i18n of 'GURPS.rollVs'
let attrname = coreModule.api.Utils.i18n(GURPS.attributeNames[actionId])
let thing = attrname; // actionID ?
let chatthing = attrname + "/[@" + actor.id + "@" + coreModule.api.Utils.i18n(GURPS.attributes[actionId]) +"]";
let target = actor.system.attributes[actionId.toUpperCase()].value;
let opt = {};
doRoll({ actor, formula, targetmods, prefix, thing, chatthing, origtarget: target, optionalArgs: opt })
}
} }
}) })