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

@@ -1,6 +1,7 @@
// System Module Imports
import { Utils } from './utils.js'
import { SYSTEM } from "../../config/system.mjs"
import CthulhuEternalUtils from '../../utils.mjs'
export let ActionHandler = null
@@ -53,7 +54,7 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
async buildCharacteristics() {
const actions = []
for (const key in this.actor.system.characteristics) {
const encodedValue = [coreModule.api.Utils.i18n('CTHULHUETERNAL.Label.characteristics'), key].join(this.delimiter)
const encodedValue = ['characteristics', key].join(this.delimiter)
const tooltip = {
content: String(this.actor.system.characteristics[key].value * 5),
class: 'tah-system-tooltip',
@@ -94,7 +95,7 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
if (typeof this.actor.system?.san?.value !== 'undefined') {
const actions = []
const groupData = {
id: 'other_sanity',
id: 'other_san',
name: coreModule.api.Utils.i18n('CTHULHUETERNAL.Label.SAN'),
type: 'system'
}
@@ -106,29 +107,29 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
}
actions.push({
name: coreModule.api.Utils.i18n('CTHULHUETERNAL.Label.SAN'),
id: 'sanity',
id: 'san',
info1: this.#showValue() ? { text: tooltip.content } : null,
tooltip,
encodedValue: ['characteristics', 'sanity'].join(this.delimiter)
encodedValue: ['characteristics', 'san'].join(this.delimiter)
},
{
name: '+',
id: 'sanity_add',
id: 'san_add',
tooltip,
encodedValue: ['characteristics', 'sanity_add'].join(this.delimiter)
encodedValue: ['characteristics', 'san_add'].join(this.delimiter)
},
{
name: '-',
id: 'sanity_subtract',
id: 'san_subtract',
tooltip,
encodedValue: ['characteristics', 'sanity_subtract'].join(this.delimiter)
encodedValue: ['characteristics', 'san_subtract'].join(this.delimiter)
})
await this.addActions(actions, { id: 'other_sanity', type: 'system' })
await this.addActions(actions, { id: 'other_san', type: 'system' })
}
if (typeof this.actor.system.hp.value !== 'undefined') {
const actions = []
const groupData = {
id: 'other_health',
id: 'other_hp',
name: coreModule.api.Utils.i18n('CTHULHUETERNAL.Label.HP'),
type: 'system'
}
@@ -140,24 +141,24 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
}
actions.push({
name: coreModule.api.Utils.i18n('CTHULHUETERNAL.Label.HP'),
id: 'health',
id: 'hp',
info1: this.#showValue() ? { text: tooltip.content } : null,
tooltip,
encodedValue: ['characteristics', 'health'].join(this.delimiter)
encodedValue: ['characteristics', 'hp'].join(this.delimiter)
},
{
name: '+',
id: 'health_add',
id: 'hp_add',
tooltip,
encodedValue: ['characteristics', 'health_add'].join(this.delimiter)
encodedValue: ['characteristics', 'hp_add'].join(this.delimiter)
},
{
name: '-',
id: 'health_subtract',
id: 'hp_subtract',
tooltip,
encodedValue: ['characteristics', 'health_subtract'].join(this.delimiter)
encodedValue: ['characteristics', 'hp_subtract'].join(this.delimiter)
})
await this.addActions(actions, { id: 'other_health', type: 'system' })
await this.addActions(actions, { id: 'other_hp', type: 'system' })
}
if (typeof this.actor.system.wp.value !== 'undefined') {
const actions = []
@@ -197,12 +198,15 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
async buildSkills() {
const actions = []
for (const item of this.actor.items) {
if (item.type !== 'skill') continue;
if (item.type === 'skill' && item.system.skillTotal > 0) {
const skill = item
// Build alpha sorted skill list
let skills = this.actor.items.filter(i => i.type === 'skill')
skills = skills.sort((a, b) => a.name.localeCompare(b.name))
console.log('Building skills actions for skills:', skills)
for (const skill of skills) {
console.log('Processing skill item:', skill)
if (skill.system.skillTotal > 0) {
const tooltip = {
content: String(item.system.skillTotal),
content: String(skill.system.skillTotal),
direction: 'LEFT'
}
actions.push({
@@ -218,56 +222,55 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
}
async buildEquipment() {
let era = game.settings.get("fvtt-cthulhu-eternal", "settings-era")
// const rituals = []
for (const item of this.actor.items) {
// Push the weapon name as a new group
const groupData = {
id: 'weapons_' + item._id,
id: `weapons_${item._id}`,
name: item.name,
type: 'system'
}
this.addGroup(groupData, { id: 'weapons', type: 'system' }, true)
if (item.type === 'weapon') {
const weapons = []
let skill = CthulhuEternalUtils.getWeaponSkill(this.actor, item, era)
item.skillTotal = skill ? skill.system.skillTotal : 0
let weapons = []
const tooltip = {
content: String(item.system.skillTotal),
content: String(item.skillTotal),
direction: 'LEFT'
}
console.log('Weapon skill total for', item.name, 'is', item.skillTotal, item._id)
weapons.push({
name: item.name,
id: item._id,
name: `${item.name} (${item.skillTotal})`,
id: `weapon_${item._id}`,
info1: this.#showValue() ? { text: tooltip.content } : null,
encodedValue: ['weapons', item._id].join(this.delimiter),
tooltip
})
let damage = ''
if (item.system.lethality > 0) {
damage = `L:${item.system.lethality}%`
} else {
damage = item.system.damage
}
const damageTooltip = {
content: String(item.system.damage),
content: String(damage),
direction: 'LEFT'
}
if (item.system.damage !== '') {
weapons.push({
name: coreModule.api.Utils.i18n('CTHULHUETERNAL.Label.Damage'),
id: item._id,
name: `${coreModule.api.Utils.i18n('CTHULHUETERNAL.Label.Damage')} (${damage})`,
id: `damage_${item._id}`,
info1: this.#showValue() ? { text: damageTooltip.content } : null,
encodedValue: ['damage', item._id].join(this.delimiter),
tooltip: damageTooltip
})
}
if (item.system.lethality > 0) {
const lethalityTooltip = {
content: String(item.system.lethality),
direction: 'LEFT'
}
weapons.push({
name: coreModule.api.Utils.i18n('CTHULHUETERNAL.Label.Lethality'),
id: item._id,
info1: this.#showValue() ? { text: lethalityTooltip.content } : null,
encodedValue: ['lethality', item._id].join(this.delimiter),
tooltip: lethalityTooltip
})
}
console.log('Adding weapon actions for', item.name, weapons)
await this.addActions(weapons, {
id: 'weapons_' + item._id,
id: `weapons_${item._id}`,
type: 'system'
})
}/* else if (item.type === 'ritual') {