fixing some roll template bugs

This commit is contained in:
Vlyan
2022-02-13 17:02:04 +01:00
parent 8c4072d8af
commit f640949016
8 changed files with 28 additions and 61 deletions

View File

@@ -56,39 +56,6 @@ export default class HooksL5r5e {
});
}
/**
* Modify the content for chat roll command
*
* The 0.8.x introduce a weird behavior, it get to roll.total as content event if a template was defined.
* So we need to intercept a chat roll (/r 1dr) for having them use the right template and not the inline (=total)
*
* @param {ChatMessage} document
* @param {Object} data
* @param {Object} options
* @param {string} userId
* @return {boolean}
*/
static async preCreateChatMessage(document, data, options, userId) {
// Roll from DP have the "isL5r5eTemplate" option set
if (!document.isRoll || options?.isL5r5eTemplate || !document.data?.roll) {
return;
}
// Get the roll object
const roll = game.l5r5e.RollL5r5e.fromJSON(document.data.roll);
// Ignore non l5r roll (std or table)
if (!roll.l5r5e?.dicesTypes?.l5r) {
return;
}
// So now we have our wrong message only, redo it using the roll
await roll.toMessage();
// Return false to let the system known we handled this
return false;
}
/**
* Chat Message
*/