diff --git a/modules/malefices-utility.js b/modules/malefices-utility.js index 1de804b..3e618ac 100644 --- a/modules/malefices-utility.js +++ b/modules/malefices-utility.js @@ -7,7 +7,7 @@ export class MaleficesUtility { /* -------------------------------------------- */ static async init() { - Hooks.on('renderChatLog', (log, html, data) => MaleficesUtility.chatListeners(html)); + Hooks.on('renderChatMessageHTML', (message, html) => MaleficesUtility.chatListeners(message, html)); this.rollDataStore = {} this.defenderStore = {} @@ -105,29 +105,32 @@ export class MaleficesUtility { /* -------------------------------------------- */ static drawDeckCard(msgId) { if (game.user.isGM) { - game.system.malefices.currentTirage.addCard(msgId) + const tirage = game.system.malefices.currentTirage + if (tirage) { + tirage.addCard(msgId) + } else { + ui.notifications.warn("Aucun tirage en cours.") + } } else { game.socket.emit("system.fvtt-malefices", { name: "msg-draw-card", data: { msgId: msgId } }) } } /* -------------------------------------------- */ - static async chatListeners(html) { + static chatListeners(message, html) { + if (!html) return - $(html).on("click", '.roll-destin', event => { - let messageId = MaleficesUtility.findChatMessageId(event.currentTarget) - let message = game.messages.get(messageId) - let rollData = message.getFlag("world", "rolldata") - let actor = this.getActorFromRollData(rollData) + html.querySelector('.roll-destin')?.addEventListener('click', () => { + const rollData = message.getFlag("world", "rolldata") + const actor = MaleficesUtility.getActorFromRollData(rollData) actor.incDecDestin(-1) rollData.isReroll = true - this.rollMalefices(rollData) - }) - $(html).on("click", '.draw-tarot-card', event => { - let messageId = MaleficesUtility.findChatMessageId(event.currentTarget) - this.drawDeckCard(messageId) + MaleficesUtility.rollMalefices(rollData) }) + html.querySelector('.draw-tarot-card')?.addEventListener('click', () => { + MaleficesUtility.drawDeckCard(message.id) + }) } /* -------------------------------------------- */ diff --git a/packs/malefices-archetypes/000074.log b/packs/malefices-archetypes/000074.log new file mode 100644 index 0000000..e69de29 diff --git a/packs/malefices-archetypes/000080.ldb b/packs/malefices-archetypes/000080.ldb deleted file mode 100644 index 42d6179..0000000 Binary files a/packs/malefices-archetypes/000080.ldb and /dev/null differ diff --git a/packs/malefices-armes/000074.log b/packs/malefices-armes/000074.log new file mode 100644 index 0000000..e69de29 diff --git a/packs/malefices-armes/000080.ldb b/packs/malefices-armes/000080.ldb deleted file mode 100644 index 4997e06..0000000 Binary files a/packs/malefices-armes/000080.ldb and /dev/null differ diff --git a/packs/malefices-macros/000074.log b/packs/malefices-macros/000074.log new file mode 100644 index 0000000..e69de29 diff --git a/packs/malefices-macros/000080.ldb b/packs/malefices-macros/000080.ldb deleted file mode 100644 index 1682904..0000000 Binary files a/packs/malefices-macros/000080.ldb and /dev/null differ diff --git a/packs/malefices-tarots/000074.log b/packs/malefices-tarots/000074.log new file mode 100644 index 0000000..e69de29 diff --git a/packs/malefices-tarots/000080.ldb b/packs/malefices-tarots/000080.ldb deleted file mode 100644 index b252578..0000000 Binary files a/packs/malefices-tarots/000080.ldb and /dev/null differ