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

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

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

View file

@ -8,7 +8,9 @@
<h4 class="dice-total">{{total}}</h4>
</div>
</div>
<div class="roll-buttons apply-buttons">
<button class="simple-roll-button">{{localize "DAGGERHEART.UI.Chat.damageRoll.dealDamage"}}</button>
<button class="simple-roll-button" data-type="healing">{{localize "DAGGERHEART.UI.Chat.healingRoll.applyHealing"}}</button>
</div>
{{#unless flags.core.RollTable}}
<div class="roll-buttons apply-buttons">
<button class="simple-roll-button">{{localize "DAGGERHEART.UI.Chat.damageRoll.dealDamage"}}</button>
<button class="simple-roll-button" data-type="healing">{{localize "DAGGERHEART.UI.Chat.healingRoll.applyHealing"}}</button>
</div>
{{/unless}}