diff --git a/src/module/chat.js b/src/module/chat.js index b0d2086..15835ea 100644 --- a/src/module/chat.js +++ b/src/module/chat.js @@ -28,6 +28,19 @@ export const addChatMessageContextOptions = function(html, options) { /* -------------------------------------------- */ +export const addChatMessageButtons = function(msg, html, data) { + let roll = html.find('.damage-roll'); + if (roll.length > 0) { + let total = roll.find('.dice-total'); + let value = total.text(); + roll.append($(`
`)) + roll.find('button[data-action="apply-damage"]').click((ev) => { + ev.preventDefault(); + applyChatCardDamage(roll, 1); + }) + } +} + /** * Apply rolled dice damage to the token or tokens which are currently controlled. * This allows for damage to be scaled by a multiplier to account for healing, critical hits, or resistance diff --git a/src/module/dice.js b/src/module/dice.js index 5c93d24..b079d61 100644 --- a/src/module/dice.js +++ b/src/module/dice.js @@ -4,6 +4,7 @@ export class OseDice { isSuccess: false, isFailure: false, target: data.rollData.target, + total: roll.total }; let die = roll.parts[0].total; @@ -119,6 +120,7 @@ export class OseDice { isSuccess: false, isFailure: false, target: "", + total: roll.total }; result.target = data.rollData.thac0; if (game.settings.get("ose", "ascendingAC")) { @@ -194,6 +196,7 @@ export class OseDice { ) .then(() => { if (templateData.result.isSuccess) { + templateData.result.dmg = dmgRoll.total; game.dice3d .showForRoll( dmgRoll, diff --git a/src/ose.js b/src/ose.js index 23f0934..0e326b1 100644 --- a/src/ose.js +++ b/src/ose.js @@ -118,3 +118,4 @@ Hooks.on("preUpdateCombat", async (combat, data, diff, id) => { Hooks.on("renderChatLog", (app, html, data) => OseItem.chatListeners(html)); Hooks.on("getChatLogEntryContext", chat.addChatMessageContextOptions); +Hooks.on("renderChatMessage", chat.addChatMessageButtons); diff --git a/src/scss/apps.scss b/src/scss/apps.scss index 5596558..dee0e6f 100644 --- a/src/scss/apps.scss +++ b/src/scss/apps.scss @@ -67,6 +67,32 @@ color: #aa0200; } } + .damage-roll { + position: relative; + .dice-damage { + display: none; + position: absolute; + line-height: 24px; + text-align: center; + background: rgba(0, 0, 0, 0.1); + border-radius: 3px; + box-shadow: 0 0 2px #fff inset; + bottom: 1px; + right: 10px; + button { + padding: 2px 5px; + width: 22px; + line-height: 14px; + height: 22px; + cursor: pointer; + } + } + &:hover { + .dice-damage { + display: block; + } + } + } } .ose.chat-card { diff --git a/src/templates/chat/roll-attack.html b/src/templates/chat/roll-attack.html index 16df2ce..f02d53b 100644 --- a/src/templates/chat/roll-attack.html +++ b/src/templates/chat/roll-attack.html @@ -12,7 +12,7 @@