diff --git a/module/applications/dialogs/tagTeamDialog.mjs b/module/applications/dialogs/tagTeamDialog.mjs index cb8a5113..e7290f1c 100644 --- a/module/applications/dialogs/tagTeamDialog.mjs +++ b/module/applications/dialogs/tagTeamDialog.mjs @@ -223,7 +223,9 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio title: game.i18n.localize('DAGGERHEART.APPLICATIONS.TagTeamSelect.title'), speaker: cls.getSpeaker({ actor: this.party.find(x => x.id === mainRollId) }), system: systemData, - rolls: mainRoll.rolls + rolls: mainRoll.rolls, + sound: null, + flags: { core: { RollTable: true } } }; await cls.create(msgData); diff --git a/module/applications/hud/tokenHUD.mjs b/module/applications/hud/tokenHUD.mjs index a5a3f490..030eca59 100644 --- a/module/applications/hud/tokenHUD.mjs +++ b/module/applications/hud/tokenHUD.mjs @@ -22,7 +22,9 @@ export default class DHTokenHUD extends foundry.applications.hud.TokenHUD { async _prepareContext(options) { const context = await super._prepareContext(options); - context.partyOnCanvas = this.actor.system.partyMembers.some(member => member.getActiveTokens().length > 0); + context.partyOnCanvas = + this.actor.type === 'party' && + this.actor.system.partyMembers.some(member => member.getActiveTokens().length > 0); context.icons.toggleParty = 'systems/daggerheart/assets/icons/arrow-dunk.png'; context.actorType = this.actor.type; context.usesEffects = this.actor.type !== 'party'; @@ -77,7 +79,7 @@ export default class DHTokenHUD extends foundry.applications.hud.TokenHUD { const animationDuration = 500; const activeTokens = this.actor.system.partyMembers.flatMap(member => member.getActiveTokens()); - const { x: actorX, y: actorY } = this.actor.token; + const { x: actorX, y: actorY } = this.document; if (activeTokens.length > 0) { for (let token of activeTokens) { await token.document.update( @@ -88,12 +90,15 @@ export default class DHTokenHUD extends foundry.applications.hud.TokenHUD { } } else { const activeScene = game.scenes.find(x => x.active); + const partyTokenData = []; + for (let member of this.actor.system.partyMembers) { + const data = await member.getTokenDocument(); + partyTokenData.push(data.toObject()); + } const newTokens = await activeScene.createEmbeddedDocuments( 'Token', - this.actor.system.partyMembers.map(member => ({ - ...member.getTokenDocument(), - actorId: member.id, - actorLink: true, + partyTokenData.map(tokenData => ({ + ...tokenData, alpha: 0, x: actorX, y: actorY diff --git a/module/applications/ui/chatLog.mjs b/module/applications/ui/chatLog.mjs index 0b9a9f23..6b05fe74 100644 --- a/module/applications/ui/chatLog.mjs +++ b/module/applications/ui/chatLog.mjs @@ -225,8 +225,9 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo }) }); - const renderData = { system: foundry.utils.deepClone(message.system) }; - foundry.utils.setProperty(renderData.system, `${path}.result`, result.roll); + const newMessageData = foundry.utils.deepClone(message.system); + foundry.utils.setProperty(newMessageData, `${path}.result`, result.roll); + const renderData = { system: new game.system.api.models.chatMessages.config.groupRoll(newMessageData) }; const updatedContent = await foundry.applications.handlebars.renderTemplate( 'systems/daggerheart/templates/ui/chat/groupRoll.hbs', @@ -280,8 +281,9 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo }) }); - const renderData = { system: foundry.utils.deepClone(message.system) }; - foundry.utils.setProperty(renderData.system, `${path}.result`, { ...result.roll, rerolled: true }); + const newMessageData = foundry.utils.deepClone(message.system); + foundry.utils.setProperty(newMessageData, `${path}.result`, { ...result.roll, rerolled: true }); + const renderData = { system: new game.system.api.models.chatMessages.config.groupRoll(newMessageData) }; const updatedContent = await foundry.applications.handlebars.renderTemplate( 'systems/daggerheart/templates/ui/chat/groupRoll.hbs', @@ -312,8 +314,9 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo return ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.noActorOwnership')); } - const renderData = { system: foundry.utils.deepClone(message.system) }; - foundry.utils.setProperty(renderData.system, `${path}.manualSuccess`, Boolean(success)); + const newMessageData = foundry.utils.deepClone(message.system); + foundry.utils.setProperty(newMessageData, `${path}.manualSuccess`, Boolean(success)); + const renderData = { system: new game.system.api.models.chatMessages.config.groupRoll(newMessageData) }; const updatedContent = await foundry.applications.handlebars.renderTemplate( 'systems/daggerheart/templates/ui/chat/groupRoll.hbs', diff --git a/module/data/chat-message/groupRoll.mjs b/module/data/chat-message/groupRoll.mjs index 0ca5faff..a5308323 100644 --- a/module/data/chat-message/groupRoll.mjs +++ b/module/data/chat-message/groupRoll.mjs @@ -9,6 +9,14 @@ export default class DHGroupRoll extends foundry.abstract.TypeDataModel { members: new fields.ArrayField(new fields.EmbeddedDataField(GroupRollMemberField)) }; } + + get totalModifier() { + return this.members.reduce((acc, m) => { + if (m.manualSuccess === null) return acc; + + return acc + (m.manualSuccess ? 1 : -1); + }, 0); + } } class GroupRollMemberField extends foundry.abstract.DataModel { diff --git a/module/dice/dhRoll.mjs b/module/dice/dhRoll.mjs index da40696b..c9bda197 100644 --- a/module/dice/dhRoll.mjs +++ b/module/dice/dhRoll.mjs @@ -70,8 +70,10 @@ export default class DHRoll extends Roll { if (Hooks.call(`${CONFIG.DH.id}.postRoll${hook.capitalize()}`, config, message) === false) return null; } - if (config.skips?.createMessage && game.modules.get('dice-so-nice')?.active) { - await game.dice3d.showForRoll(roll, game.user, true); + if (config.skips?.createMessage) { + if (game.modules.get('dice-so-nice')?.active) { + await game.dice3d.showForRoll(roll, game.user, true); + } } else if (!config.source?.message) { config.message = await this.toMessage(roll, config); } diff --git a/module/documents/chatMessage.mjs b/module/documents/chatMessage.mjs index 3a5fef38..ec4c5a49 100644 --- a/module/documents/chatMessage.mjs +++ b/module/documents/chatMessage.mjs @@ -16,7 +16,7 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage { const html = await super.renderHTML({ actor: actorData, author: this.author }); if (this.flags.core?.RollTable) { - html.querySelector('.roll-buttons.apply-buttons').remove(); + html.querySelector('.roll-buttons.apply-buttons')?.remove(); } this.enrichChatMessage(html); diff --git a/templates/ui/chat/groupRoll.hbs b/templates/ui/chat/groupRoll.hbs index 54c62ca9..83cc4ce9 100644 --- a/templates/ui/chat/groupRoll.hbs +++ b/templates/ui/chat/groupRoll.hbs @@ -3,7 +3,7 @@

-
+
@@ -22,11 +22,9 @@
{{else}} -
+
{{#if (isNullish system.leader.manualSuccess)}}
- {{system.leader.result.total}} -
@@ -47,17 +45,23 @@
{{/unless}}
- {{#unless (isNullish system.leader.manualSuccess)}} + {{#if system.leader.result}}

{{localize "DAGGERHEART.UI.Chat.dualityRoll.abilityCheckTitle" ability=(localize (concat "DAGGERHEART.CONFIG.Traits." system.leader.trait ".name"))}}

- {{system.leader.result.total}} + + {{system.leader.result.total}} + {{#unless (isNullish system.totalModifier)}} + {{#if (gte system.totalModifier 0)}}+{{else}}-{{/if}} + {{positive system.totalModifier}} = {{add system.leader.result.total system.totalModifier}} + {{/unless}} + {{localize "DAGGERHEART.GENERAL.withThing" thing=system.leader.result.result.label}}
- {{/unless}} + {{/if}}