Skip to content

Commit

Permalink
Merge pull request #402 from MangoFVTT/develop
Browse files Browse the repository at this point in the history
release/3.0.13
  • Loading branch information
MangoFVTT authored Mar 4, 2024
2 parents 1e2114b + 9880108 commit 6083deb
Showing 1 changed file with 22 additions and 23 deletions.
45 changes: 22 additions & 23 deletions src/utils/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,37 +228,36 @@ async function _injectContent(message, type, html) {
LogUtility.log("Injecting content into chat message");
const parent = game.messages.get(message.flags.dnd5e?.originatingMessage);

switch (type) {
case ROLL_TYPE.ATTACK:
switch (type) {
case ROLL_TYPE.DAMAGE:
// Handle damage enrichers
if (!message.flags.dnd5e?.roll.itemId) {
const enricher = html.find('.dice-roll');

html.parent().find('.flavor-text').text('');
html.append('<div class="dnd5e2 chat-card"></div>');
html.find('.chat-card').append(enricher);

message.flags[MODULE_SHORT].renderDamage = true;
message.flags[MODULE_SHORT].isCritical = message.rolls[0]?.isCritical;
message.flags[MODULE_SHORT].versatile = message.flags.dnd5e.roll.versatile ?? false;

await _injectDamageRoll(message, enricher);

if (SettingsUtility.getSettingValue(SETTING_NAMES.DAMAGE_BUTTONS_ENABLED)) {
await _injectApplyDamageButtons(message, html);
}
enricher.remove();
break;
}
case ROLL_TYPE.ATTACK:
case ROLL_TYPE.TOOL:
if (parent && message.isOwner) {
if (type === ROLL_TYPE.ATTACK) {
parent.flags[MODULE_SHORT].renderAttack = true;
}

if (type === ROLL_TYPE.DAMAGE) {
// Handle damage enrichers
if (!message.flags.dnd5e?.roll.itemId) {
const enricher = html.find('.dice-roll');

html.parent().find('.flavor-text').text('');
html.append('<div class="dnd5e2 chat-card"></div>');
html.find('.chat-card').append(enricher);

message.flags[MODULE_SHORT].renderDamage = true;
message.flags[MODULE_SHORT].isCritical = message.rolls[0]?.isCritical;
message.flags[MODULE_SHORT].versatile = message.flags.dnd5e.roll.versatile ?? false;

await _injectDamageRoll(message, enricher);

if (SettingsUtility.getSettingValue(SETTING_NAMES.DAMAGE_BUTTONS_ENABLED)) {
await _injectApplyDamageButtons(message, html);
}
enricher.remove();
break;
}

parent.flags[MODULE_SHORT].renderDamage = true;
parent.flags[MODULE_SHORT].versatile = message.flags.dnd5e.roll.versatile ?? false;
parent.flags[MODULE_SHORT].isCritical = message.rolls[0]?.isCritical;
Expand Down

0 comments on commit 6083deb

Please sign in to comment.