@@ -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'
|
||||
}) */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user