diff --git a/daggerheart.mjs b/daggerheart.mjs index a2f41735..795764cc 100644 --- a/daggerheart.mjs +++ b/daggerheart.mjs @@ -8,7 +8,7 @@ import RegisterHandlebarsHelpers from './module/helpers/handlebarsHelper.mjs'; import { enricherConfig, enricherRenderSetup } from './module/enrichers/_module.mjs'; import { getCommandTarget, rollCommandToJSON } from './module/helpers/utils.mjs'; import { NarrativeCountdowns } from './module/applications/ui/countdowns.mjs'; -import { DHRoll, DualityRoll, D20Roll, DamageRoll } from './module/dice/_module.mjs'; +import { BaseRoll, DHRoll, DualityRoll, D20Roll, DamageRoll } from './module/dice/_module.mjs'; import { enrichedDualityRoll } from './module/enrichers/DualityRollEnricher.mjs'; import { registerCountdownHooks } from './module/data/countdowns.mjs'; import { @@ -49,9 +49,7 @@ Hooks.once('init', () => { DamageRoll: DamageRoll }; - CONFIG.Dice.rolls = [...CONFIG.Dice.rolls, DHRoll, DualityRoll, D20Roll, DamageRoll]; - Roll.CHAT_TEMPLATE = 'systems/daggerheart/templates/ui/chat/foundryRoll.hbs'; - Roll.TOOLTIP_TEMPLATE = 'systems/daggerheart/templates/ui/chat/foundryRollTooltip.hbs'; + CONFIG.Dice.rolls = [BaseRoll, DHRoll, DualityRoll, D20Roll, DamageRoll]; CONFIG.MeasuredTemplate.objectClass = placeables.DhMeasuredTemplate; const { DocumentSheetConfig } = foundry.applications.apps; diff --git a/module/dice/_module.mjs b/module/dice/_module.mjs index f34f32d3..e6755a74 100644 --- a/module/dice/_module.mjs +++ b/module/dice/_module.mjs @@ -1,3 +1,4 @@ +export { default as BaseRoll } from './baseRoll.mjs'; export { default as D20Roll } from './d20Roll.mjs'; export { default as DamageRoll } from './damageRoll.mjs'; export { default as DHRoll } from './dhRoll.mjs'; diff --git a/module/dice/baseRoll.mjs b/module/dice/baseRoll.mjs new file mode 100644 index 00000000..4d065fff --- /dev/null +++ b/module/dice/baseRoll.mjs @@ -0,0 +1,7 @@ +export default class BaseRoll extends Roll { + /** @inheritdoc */ + static CHAT_TEMPLATE = 'systems/daggerheart/templates/ui/chat/foundryRoll.hbs'; + + /** @inheritdoc */ + static TOOLTIP_TEMPLATE = 'systems/daggerheart/templates/ui/chat/foundryRollTooltip.hbs'; +} diff --git a/module/documents/chatMessage.mjs b/module/documents/chatMessage.mjs index baf4ca17..a51686e6 100644 --- a/module/documents/chatMessage.mjs +++ b/module/documents/chatMessage.mjs @@ -13,6 +13,10 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage { /* We can change to fully implementing the renderHTML function if needed, instead of augmenting it. */ const html = await super.renderHTML({ actor: actorData, author: this.author }); + if (this.flags.core?.RollTable) { + html.querySelector('.roll-buttons.apply-buttons').remove(); + } + this.enrichChatMessage(html); this.addChatListeners(html); @@ -54,26 +58,44 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage { e.setAttribute('data-use-perm', document.testUserPermission(game.user, 'OWNER')); }); - if (this.isContentVisible && this.type === 'dualityRoll') { - html.classList.add('duality'); - switch (this.system.roll?.result?.duality) { - case 1: - html.classList.add('hope'); - break; - case -1: - html.classList.add('fear'); - break; - default: - html.classList.add('critical'); - break; + if (this.isContentVisible) { + if (this.type === 'dualityRoll') { + html.classList.add('duality'); + switch (this.system.roll?.result?.duality) { + case 1: + html.classList.add('hope'); + break; + case -1: + html.classList.add('fear'); + break; + default: + html.classList.add('critical'); + break; + } } + + const autoExpandRoll = game.settings.get( + CONFIG.DH.id, + CONFIG.DH.SETTINGS.gameSettings.appearance + ).expandRollMessage, + rollSections = html.querySelectorAll('.roll-part'), + itemDesc = html.querySelector('.domain-card-move'); + rollSections.forEach(s => { + if (s.classList.contains('roll-section')) { + const toExpand = s.querySelector('[data-action="expandRoll"]'); + toExpand.classList.toggle('expanded', autoExpandRoll.roll); + } else if (s.classList.contains('damage-section')) + s.classList.toggle('expanded', autoExpandRoll.damage); + else if (s.classList.contains('target-section')) s.classList.toggle('expanded', autoExpandRoll.target); + }); + if (itemDesc && autoExpandRoll.desc) itemDesc.setAttribute('open', ''); } - - if(!game.user.isGM) { - const applyButtons = html.querySelector(".apply-buttons"); + + if (!game.user.isGM) { + const applyButtons = html.querySelector('.apply-buttons'); applyButtons?.remove(); - if(!this.isAuthor && !this.speakerActor?.isOwner) { - const buttons = html.querySelectorAll(".ability-card-footer > .ability-use-button"); + if (!this.isAuthor && !this.speakerActor?.isOwner) { + const buttons = html.querySelectorAll('.ability-card-footer > .ability-use-button'); buttons.forEach(b => b.remove()); } } diff --git a/templates/ui/chat/foundryRoll.hbs b/templates/ui/chat/foundryRoll.hbs index a3c55a9e..8fc62219 100644 --- a/templates/ui/chat/foundryRoll.hbs +++ b/templates/ui/chat/foundryRoll.hbs @@ -8,7 +8,9 @@