RollTable chat message cleanup (#1012)

This commit is contained in:
WBHarry 2025-08-19 13:16:08 +02:00 committed by GitHub
parent 540ee49f50
commit b3062bf5b9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 55 additions and 25 deletions

View file

@ -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';

7
module/dice/baseRoll.mjs Normal file
View file

@ -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';
}

View file

@ -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());
}
}