[Feature] Damage-Reroll (#753)

* Added rerolls for damage dice in chat

* Fixed multiple dice

* Added reroll icon

* Fixed new style of dialog
This commit is contained in:
WBHarry 2025-08-10 01:32:12 +02:00 committed by GitHub
parent 2aaab73699
commit 300719c116
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
28 changed files with 1094 additions and 167 deletions

View file

@ -8,9 +8,7 @@ export default class DHRoll extends Roll {
}
get title() {
return game.i18n.localize(
"DAGGERHEART.GENERAL.Roll.basic"
);
return game.i18n.localize('DAGGERHEART.GENERAL.Roll.basic');
}
static messageType = 'adversaryRoll';
@ -68,8 +66,7 @@ export default class DHRoll extends Roll {
}
// Create Chat Message
if (!config.source?.message)
config.message = await this.toMessage(roll, config);
if (!config.source?.message) config.message = await this.toMessage(roll, config);
}
static postEvaluate(roll, config = {}) {
@ -97,30 +94,30 @@ export default class DHRoll extends Roll {
rolls: [roll]
};
config.selectedRollMode ??= game.settings.get('core', 'rollMode');
if(roll._evaluated) return await cls.create(msg, { rollMode: config.selectedRollMode });
if (roll._evaluated) return await cls.create(msg, { rollMode: config.selectedRollMode });
return msg;
}
/** @inheritDoc */
async render({flavor, template=this.constructor.CHAT_TEMPLATE, isPrivate=false, ...options}={}) {
if ( !this._evaluated ) return;
const chatData = await this._prepareChatRenderContext({flavor, isPrivate, ...options});
async render({ flavor, template = this.constructor.CHAT_TEMPLATE, isPrivate = false, ...options } = {}) {
if (!this._evaluated) return;
const chatData = await this._prepareChatRenderContext({ flavor, isPrivate, ...options });
return foundry.applications.handlebars.renderTemplate(template, chatData);
}
/** @inheritDoc */
async _prepareChatRenderContext({flavor, isPrivate=false, ...options}={}) {
if(isPrivate) {
async _prepareChatRenderContext({ flavor, isPrivate = false, ...options } = {}) {
if (isPrivate) {
return {
user: game.user.id,
flavor: null,
title: "???",
title: '???',
roll: {
total: "??"
total: '??'
},
hasRoll: true,
isPrivate
}
};
} else {
options.message.system.user = game.user.id;
return options.message.system;
@ -217,7 +214,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) ||