ENhance actor sheet with roll messages

This commit is contained in:
2026-03-07 16:09:00 +01:00
parent 8dec307ced
commit 63da2ef664
32 changed files with 888 additions and 22 deletions
+39
View File
@@ -4,6 +4,8 @@ globalThis.SYSTEM = SYSTEM
import * as models from "./module/models/_module.mjs"
import * as documents from "./module/documents/_module.mjs"
import * as applications from "./module/applications/_module.mjs"
import { SystemManager } from "./module/applications/hud/system-manager.js"
import { MODULE, REQUIRED_CORE_MODULE_VERSION } from "./module/applications/hud/constants.js"
Hooks.once("init", function () {
console.info("Adventures with Emmy | Initializing System")
@@ -72,6 +74,13 @@ Hooks.once("init", function () {
CONFIG.Dice.rolls.push(documents.AwERoll)
CONFIG.Combatant.documentClass = documents.AwECombatant
// Register conditions as status effects (token HUD overlays)
CONFIG.statusEffects = Object.values(SYSTEM.CONDITIONS).map(c => ({
id: c.id,
name: c.label,
img: `systems/fvtt-adventures-with-emmy/assets/conditions/${c.id}.svg`
}))
// Handlebars helpers
Handlebars.registerHelper("abs", (value) => Math.abs(value ?? 0))
})
@@ -79,3 +88,33 @@ Hooks.once("init", function () {
Hooks.once("ready", function () {
console.info("Adventures with Emmy | System Ready")
})
// Token Action HUD Core integration (only fires if the module is active)
Hooks.on('tokenActionHudCoreApiReady', async () => {
const module = {
api: {
requiredCoreModuleVersion: REQUIRED_CORE_MODULE_VERSION,
SystemManager
}
}
Hooks.call('tokenActionHudSystemReady', module)
})
// Chat message: "Roll Damage" button on weapon attack messages
Hooks.on('renderChatMessageHTML', (message, html) => {
const btn = html.querySelector('.roll-damage-btn')
if (!btn) return
btn.addEventListener('click', async () => {
const actorId = btn.dataset.actorId
const actor = game.actors.get(actorId)
if (!actor) return ui.notifications.warn('Actor not found')
await actor.rollDamage({
name: btn.dataset.itemName,
img: btn.dataset.itemImg,
system: {
damageFormula: btn.dataset.damageFormula,
damageType: btn.dataset.damageType
}
})
})
})