Combat/automation enhancements !
All checks were successful
Release Creation / build (release) Successful in 58s

This commit is contained in:
2025-11-13 13:59:02 +01:00
parent 6ad8226265
commit 2c25820152
26 changed files with 233 additions and 220 deletions

View File

@@ -66,9 +66,10 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
* @param {string} actionId The actionId
*/
async #handleAction(event, actor, token, actionTypeId, actionId) {
console.log('Handling action', actionId, 'of type', actionTypeId, 'for actor', actor.name)
switch (actionTypeId) {
case 'attributes':
await this.#handleAttributesAction(event, actor, actionId)
case 'characteristics':
await this.#handleCharacteristicsAction(event, actor, actionId)
break
case 'skills':
await this.#handleSkillsAction(event, actor, actionId)
@@ -92,18 +93,20 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
}
/**
* Handle Attribute action
* Handle Characteristic action
* @private
* @param {object} event The event
* @param {object} actor The actor
* @param {string} actionId The action id
*/
async #handleAttributesAction(event, actor, actionId) {
async #handleCharacteristicsAction(event, actor, actionId) {
let rollType
if (actionId === 'wp' || actionId === 'health') return
if (actionId === 'wp' || actionId === 'hp') return
if (actionId.includes('_add') || actionId.includes('_subtract')) {
const attr = actionId.split('_')[0]
const action = actionId.split('_')[1]
console.log('Updating', attr, 'with action', action)
const update = {}
update.system = {}
update.system[attr] = {}
@@ -111,21 +114,23 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
if (update.system[attr].value > this.actor.system[attr].max || update.system[attr].value < this.actor.system[attr].min) return
return await this.actor.update(update)
}
if (actionId === 'sanity') {
rollType = actionId
if (actionId === 'san') {
let item = foundry.utils.duplicate(actor.system.san)
item.name = game.i18n.localize("CTHULHUETERNAL.Label.SAN")
item.targetScore = item.value
await actor.system.roll('san', item)
} else if (actionId === 'luck') {
rollType = actionId
let item = foundry.utils.duplicate(actor.system.characteristics.int)
item.name = game.i18n.localize("CTHULHUETERNAL.Label.Luck")
item.value = 10
item.targetScore = 50
await actor.system.roll('luck', item)
} else {
rollType = 'stat'
let item = foundry.utils.duplicate(actor.system.characteristics[actionId])
item.name = game.i18n.localize(`CTHULHUETERNAL.Label.${actionId}Long`)
item.targetScore = item.value * 5
await actor.system.roll('char', item)
}
const options = {
actor: this.actor,
rollType,
key: actionId
}
/*const roll = new DGPercentileRoll('1D100', {}, options)
return await this.actor.sheet.processRoll(event, roll)*/
}
/**
@@ -136,18 +141,9 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
* @param {string} actionId The action id
*/
async #handleSkillsAction(event, actor, actionId) {
const options = {
actor: this.actor,
rollType: 'skill',
key: actionId
}
const skill = this.actor.items.find(i => i.type === 'skill' && i.id === actionId)
if (!skill) return ui.notifications.warn('Bad skill name in HUD.')
/** TO FIX
const roll = new DGPercentileRoll('1D100', {}, options)
await this.actor.sheet.processRoll(event, roll)*/
const skill = actor.items.find(i => i.type === 'skill' && i.id === actionId)
if (!skill) return ui.notifications.warn(`Skill not found for action id '${actionId}'`)
await actor.system.roll('skill', skill)
}
@@ -159,16 +155,10 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
* @param {string} actionId The action id
*/
async #handleWeaponsAction(event, actor, actionId) {
const item = this.actor.items.get(actionId)
const options = {
actor: this.actor,
rollType: 'weapon',
key: item.system.skill,
item
}
/* TO FIX
const roll = new DGPercentileRoll('1D100', {}, options)
await this.actor.sheet.processRoll(event, roll)*/
let weapon = actor.items.find(i => i.type === 'weapon' && i.id === actionId)
weapon.damageFormula = weapon.system.damage
weapon.damageBonus = actor.system.damageBonus
await actor.system.roll('weapon', weapon)
}
/**
@@ -179,22 +169,10 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
* @param {string} actionId The action id
*/
async #handleDamageAction(event, actor, actionId) {
const item = this.actor.items.get(actionId)
if (item.system.lethality > 0 && event.ctrlKey) {
// Toggle on/off lethality
const isLethal = !item.system.isLethal
await item.update({ 'system.isLethal': isLethal })
} else {
const options = {
actor: this.actor,
rollType: 'damage',
key: item.system.damage,
item
}
/* TOFIX
const roll = new DGDamageRoll(item.system.damage, {}, options)
await this.actor.sheet.processRoll(event, roll)*/
}
let weapon = actor.items.find(i => i.type === 'weapon' && i.id === actionId)
weapon.damageFormula = weapon.system.damage
weapon.damageBonus = actor.system.damageBonus
await actor.system.roll('damage', weapon)
}
/**