Fixed up downtime dialogs and data model

This commit is contained in:
WBHarry 2025-06-19 17:11:01 +02:00
parent f6e077b290
commit e38ebfab29
10 changed files with 284 additions and 118 deletions

View file

@ -1,3 +1,5 @@
import { actionsTypes } from '../data/_module.mjs';
export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLog {
constructor() {
super();
@ -38,6 +40,9 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
html.querySelectorAll('.ability-use-button').forEach(element =>
element.addEventListener('click', event => this.abilityUseButton.bind(this)(event, data.message))
);
html.querySelectorAll('.action-use-button').forEach(element =>
element.addEventListener('click', event => this.actionUseButton.bind(this)(event, data.message))
);
};
setupHooks() {
@ -137,4 +142,16 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
const actor = game.actors.get(message.system.origin);
await actor.useAction(action);
};
actionUseButton = async (_, message) => {
const parent = await foundry.utils.fromUuid(message.system.actor);
const testAction = Object.values(message.system.moves)[0].actions[0];
const cls = actionsTypes[testAction.type];
const action = new cls(
{ ...testAction, _id: foundry.utils.randomID(), name: game.i18n.localize(testAction.name) },
{ parent: parent }
);
action.use();
};
}