Fix for v14
Release Creation / build (release) Successful in 48s

This commit is contained in:
2026-04-28 07:52:18 +02:00
parent bb6a6248f2
commit e26db56585
29 changed files with 99 additions and 75 deletions
+13 -29
View File
@@ -1,6 +1,4 @@
// System Module Imports
import { Utils } from './utils.js'
import { SYSTEM } from "../../config/system.mjs"
import CthulhuEternalUtils from '../../utils.mjs'
export let ActionHandler = null
@@ -17,8 +15,7 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
* @param {array} groupIds
*/
async buildSystemActions(groupIds) {
// Set actor and token variables
this.actors = (!this.actor) ? this._getActors() : [this.actor]
// this.actor and this.actors are provided by the base class (TAH Core v2+)
this.actorType = this.actor?.type
// Set items variable
@@ -28,9 +25,11 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
this.items = items
}
if (this.actorType !== 'vehicle') {
this.#buildCharacterActions()
} else if (!this.actor) {
if (this.actor) {
if (this.actorType !== 'vehicle') {
this.#buildCharacterActions()
}
} else {
this.#buildMultipleTokenActions()
}
}
@@ -201,7 +200,7 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
// 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) {
@@ -224,8 +223,8 @@ 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) {
const weapons = this.actor.items.filter(i => i.type === 'weapon')
for (const item of weapons) {
// Push the weapon name as a new group
const groupData = {
id: `weapons_${item._id}`,
@@ -233,16 +232,14 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
type: 'system'
}
this.addGroup(groupData, { id: 'weapons', type: 'system' }, true)
if (item.type === 'weapon') {
let skill = CthulhuEternalUtils.getWeaponSkill(this.actor, item, era)
item.skillTotal = skill ? skill.system.skillTotal : 0
let weapons = []
let weaponActions = []
const tooltip = {
content: String(item.skillTotal),
direction: 'LEFT'
}
console.log('Weapon skill total for', item.name, 'is', item.skillTotal, item._id)
weapons.push({
weaponActions.push({
name: `${item.name} (${item.skillTotal})`,
id: `weapon_${item._id}`,
info1: this.#showValue() ? { text: tooltip.content } : null,
@@ -260,7 +257,7 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
direction: 'LEFT'
}
if (item.system.damage !== '') {
weapons.push({
weaponActions.push({
name: `${coreModule.api.Utils.i18n('CTHULHUETERNAL.Label.Damage')} (${damage})`,
id: `damage_${item._id}`,
info1: this.#showValue() ? { text: damageTooltip.content } : null,
@@ -268,23 +265,10 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
tooltip: damageTooltip
})
}
console.log('Adding weapon actions for', item.name, weapons)
await this.addActions(weapons, {
await this.addActions(weaponActions, {
id: `weapons_${item._id}`,
type: 'system'
})
}/* else if (item.type === 'ritual') {
rituals.push({
name: item.name,
id: item._id,
encodedValue: ['rituals', item.name].join(this.delimiter)
})
} */
/* await this.addActions(rituals, {
id: 'rituals',
type: 'system'
}) */
}
}
+1 -1
View File
@@ -15,7 +15,7 @@ export const CORE_MODULE = {
/**
* Core module version required by the system module
*/
export const REQUIRED_CORE_MODULE_VERSION = '2.0'
export const REQUIRED_CORE_MODULE_VERSION = '2'
/**
* Action types
+9 -13
View File
@@ -1,6 +1,3 @@
import { SYSTEM } from "../../config/system.mjs"
export let RollHandler = null
Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
@@ -66,7 +63,6 @@ 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 'characteristics':
await this.#handleCharacteristicsAction(event, actor, actionId)
@@ -100,19 +96,17 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
* @param {string} actionId The action id
*/
async #handleCharacteristicsAction(event, actor, actionId) {
let rollType
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] = {}
update.system[attr].value = action === 'add' ? this.actor.system[attr].value + 1 : this.actor.system[attr].value - 1
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)
update.system[attr].value = action === 'add' ? actor.system[attr].value + 1 : actor.system[attr].value - 1
if (update.system[attr].value > actor.system[attr].max || update.system[attr].value < actor.system[attr].min) return
return await actor.update(update)
}
if (actionId === 'san') {
let item = foundry.utils.duplicate(actor.system.san)
@@ -155,7 +149,8 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
* @param {string} actionId The action id
*/
async #handleWeaponsAction(event, actor, actionId) {
let weapon = actor.items.find(i => i.type === 'weapon' && i.id === actionId)
const weapon = actor.items.find(i => i.type === 'weapon' && i.id === actionId)
if (!weapon) return ui.notifications.warn(`Weapon not found for action id '${actionId}'`)
weapon.damageFormula = weapon.system.damage
weapon.damageBonus = actor.system.damageBonus
await actor.system.roll('weapon', weapon)
@@ -169,7 +164,8 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
* @param {string} actionId The action id
*/
async #handleDamageAction(event, actor, actionId) {
let weapon = actor.items.find(i => i.type === 'weapon' && i.id === actionId)
const weapon = actor.items.find(i => i.type === 'weapon' && i.id === actionId)
if (!weapon) return ui.notifications.warn(`Weapon not found for action id '${actionId}'`)
weapon.damageFormula = weapon.system.damage
weapon.damageBonus = actor.system.damageBonus
await actor.system.roll('damage', weapon)
@@ -183,13 +179,13 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
* @param {string} actionId The action id
*/
async #handleLethalityAction(event, actor, actionId) {
const item = await this.actor.items.get(actionId)
const item = actor.items.get(actionId)
if (item.system.damage !== '' && event.ctrlKey) {
const isLethal = !item.system.isLethal
await item.update({ 'system.isLethal': isLethal })
} else {
const options = {
actor: this.actor,
actor,
rollType: 'lethality',
key: item.system.lethality,
item
+2 -9
View File
@@ -1,7 +1,6 @@
// System Module Imports
import { ActionHandler } from './action-handler.js'
import { RollHandler as Core } from './roll-handler.js'
import { MODULE } from './constants.js'
import { DEFAULTS } from './defaults.js'
import * as systemSettings from './settings.js'
@@ -79,14 +78,8 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
* @returns {object} The TAH system styles
*/
registerStyles() {
return {
template: {
class: 'tah-style-template-style', // The class to add to first DIV element
file: 'tah-template-style', // The file without the css extension
moduleId: MODULE.ID, // The module ID
name: 'Template Style' // The name to display in the Token Action HUD Core 'Style' module setting
}
}
// No system-specific styles; use the core styles only
return {}
}
}
})