Feature/chat message styles (#514)

* style items and action chat messages

* enhance death move chat message and fix border bottom from title actions

* fix padding bottom

* Added basic chat-message.hbs

* .

* style remaing chat messages

* style action messages

* remove console log

* add colapsable descriptions in chat messages

* inital style for message rolls

* fix deal damage button style

* add new partchments

* Roll Chat message new design template

* j

* l

* p

* y

* fix _getTags type error and add a alias label for non base messages

* Fix damage & healing roll

* Fix conflict

* Deleting old templates

* Good for now

* fix labels in duality rolls messages and style experience and effects messages

---------

Co-authored-by: WBHarry <williambjrklund@gmail.com>
Co-authored-by: Dapoolp <elcatnet@gmail.com>
This commit is contained in:
Murilo Brito 2025-08-02 04:24:51 -03:00 committed by GitHub
parent a4b1130142
commit 74df2c4e87
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
72 changed files with 1661 additions and 996 deletions

View file

@ -13,12 +13,16 @@ export default class D20Roll extends DHRoll {
DISADVANTAGE: -1
};
static messageType = 'adversaryRoll';
static CRITICAL_TRESHOLD = 20;
static DefaultDialog = D20RollDialog;
get title() {
return game.i18n.localize(
"DAGGERHEART.GENERAL.d20Roll"
);
}
get d20() {
if (!(this.terms[0] instanceof foundry.dice.terms.Die)) this.createBaseDice();
return this.terms[0];
@ -136,7 +140,9 @@ export default class D20Roll extends DHRoll {
static postEvaluate(roll, config = {}) {
const data = super.postEvaluate(roll, config);
data.type = config.roll?.type;
if (config.targets?.length) {
config.targetSelection = true;
config.targets.forEach(target => {
const difficulty = config.roll.difficulty ?? target.difficulty ?? target.evasion;
target.hit = this.isCritical || roll.total >= difficulty;
@ -145,7 +151,6 @@ export default class D20Roll extends DHRoll {
data.difficulty = config.roll.difficulty;
data.success = roll.isCritical || roll.total >= config.roll.difficulty;
}
data.type = config.roll.type;
data.advantage = {
type: config.roll.advantage,
dice: roll.dAdvantage?.denomination,
@ -159,7 +164,7 @@ export default class D20Roll extends DHRoll {
rerolls: dice.results.filter(x => x.rerolled)
}
}));
data.isCritical = roll.isCritical;
data.isCritical = config.isCritical = roll.isCritical;
data.extra = roll.dice
.filter(d => !roll.baseTerms.includes(d))
.map(d => {

View file

@ -6,23 +6,17 @@ export default class DamageRoll extends DHRoll {
super(formula, data, options);
}
static messageType = 'damageRoll';
static DefaultDialog = DamageDialog;
static async buildEvaluate(roll, config = {}, message = {}) {
if (config.evaluate !== false) {
// if (config.dialog.configure === false) roll.constructFormula(config);
if (config.evaluate !== false)
for (const roll of config.roll) await roll.roll.evaluate();
}
roll._evaluated = true;
const parts = [];
for (let r of config.roll) {
const part = this.postEvaluate(r);
parts.push(part);
}
const parts = config.roll.map(r => this.postEvaluate(r));
config.roll = this.unifyDamageRoll(parts);
config.damage = this.unifyDamageRoll(parts);
config.targetSelection = config.targets?.length
}
static postEvaluate(roll, config = {}) {
@ -37,11 +31,18 @@ export default class DamageRoll extends DHRoll {
}
static async buildPost(roll, config, message) {
if (game.modules.get('dice-so-nice')?.active) {
const pool = foundry.dice.terms.PoolTerm.fromRolls(
Object.values(config.damage).flatMap(r => r.parts.map(p => p.roll))
),
diceRoll = Roll.fromTerms([pool]);
await game.dice3d.showForRoll(diceRoll, game.user, true);
}
await super.buildPost(roll, config, message);
if (config.source?.message) {
const chatMessage = ui.chat.collection.get(config.source.message);
chatMessage.update({ 'system.damage': config });
}
chatMessage.update({ 'system.damage': config.damage });
}
}
static unifyDamageRoll(rolls) {

View file

@ -7,6 +7,12 @@ export default class DHRoll extends Roll {
if (!this.data || !Object.keys(this.data).length) this.data = options.data;
}
get title() {
return game.i18n.localize(
"DAGGERHEART.GENERAL.Roll.basic"
);
}
static messageType = 'adversaryRoll';
static DefaultDialog = D20RollDialog;
@ -46,8 +52,10 @@ export default class DHRoll extends Roll {
}
static async buildEvaluate(roll, config = {}, message = {}) {
if (config.evaluate !== false) await roll.evaluate();
config.roll = this.postEvaluate(roll, config);
if (config.evaluate !== false) {
await roll.evaluate();
config.roll = this.postEvaluate(roll, config);
}
}
static async buildPost(roll, config, message) {
@ -56,15 +64,8 @@ export default class DHRoll extends Roll {
}
// Create Chat Message
if (roll instanceof CONFIG.Dice.daggerheart.DamageRoll && Object.values(config.roll)?.length) {
const pool = foundry.dice.terms.PoolTerm.fromRolls(
Object.values(config.roll).flatMap(r => r.parts.map(p => p.roll))
);
roll = Roll.fromTerms([pool]);
}
if (config.source?.message) {
if (game.modules.get('dice-so-nice')?.active) await game.dice3d.showForRoll(roll, game.user, true);
} else config.message = await this.toMessage(roll, config);
if (!config.source?.message)
config.message = await this.toMessage(roll, config);
}
static postEvaluate(roll, config = {}) {
@ -85,11 +86,14 @@ export default class DHRoll extends Roll {
msg = {
type: this.messageType,
user: game.user.id,
title: roll.title,
speaker: cls.getSpeaker(),
sound: config.mute ? null : CONFIG.sounds.dice,
system: config,
rolls: [roll]
};
return await cls.create(msg, { rollMode: config.selectedRollMode });
if(roll._evaluated) return await cls.create(msg, { rollMode: config.selectedRollMode });
return msg;
}
static applyKeybindings(config) {
@ -178,7 +182,7 @@ export default class DHRoll extends Roll {
export const registerRollDiceHooks = () => {
Hooks.on(`${CONFIG.DH.id}.postRollDuality`, async (config, message) => {
const hopeFearAutomation = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Automation).hopeFear;
const hopeFearAutomation = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Automation).hopeFear;
if (
!config.source?.actor ||
(game.user.isGM ? !hopeFearAutomation.gm : !hopeFearAutomation.players) ||

View file

@ -17,6 +17,12 @@ export default class DualityRoll extends D20Roll {
static DefaultDialog = D20RollDialog;
get title() {
return game.i18n.localize(
"DAGGERHEART.GENERAL.dualityRoll"
);
}
get dHope() {
// if ( !(this.terms[0] instanceof foundry.dice.terms.Die) ) return;
if (!(this.dice[0] instanceof CONFIG.Dice.daggerheart.DualityDie)) this.createBaseDice();