diff --git a/module/applications/dialogs/groupRollDialog.mjs b/module/applications/dialogs/groupRollDialog.mjs index 6ee659a3..37780ea5 100644 --- a/module/applications/dialogs/groupRollDialog.mjs +++ b/module/applications/dialogs/groupRollDialog.mjs @@ -481,22 +481,23 @@ export default class GroupRollDialog extends HandlebarsApplicationMixin(Applicat await cls.create(msgData); - if (!shouldUseHopeFearAutomation()) return this.cancelRoll({ confirm: false }); + /* Handle resource updates for the finished GroupRoll */ + if (shouldUseHopeFearAutomation({ gmAsPlayer: true })) { + const resourceMap = new ResourceUpdateMap(actor); + if (totalRoll.isCritical) { + resourceMap.addResources([ + { key: 'stress', value: -1, total: 1 }, + { key: 'hope', value: 1, total: 1 } + ]); + } else if (totalRoll.withHope) { + resourceMap.addResources([{ key: 'hope', value: 1, total: 1 }]); + } else { + resourceMap.addResources([{ key: 'fear', value: 1, total: 1 }]); + } - const resourceMap = new ResourceUpdateMap(actor); - if (totalRoll.isCritical) { - resourceMap.addResources([ - { key: 'stress', value: -1, total: 1 }, - { key: 'hope', value: 1, total: 1 } - ]); - } else if (totalRoll.withHope) { - resourceMap.addResources([{ key: 'hope', value: 1, total: 1 }]); - } else { - resourceMap.addResources([{ key: 'fear', value: 1, total: 1 }]); + resourceMap.updateResources(); } - resourceMap.updateResources(); - /* Fin */ this.cancelRoll({ confirm: false }); } diff --git a/module/applications/dialogs/tagTeamDialog.mjs b/module/applications/dialogs/tagTeamDialog.mjs index a0976051..92a92369 100644 --- a/module/applications/dialogs/tagTeamDialog.mjs +++ b/module/applications/dialogs/tagTeamDialog.mjs @@ -750,35 +750,35 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio await cls.create(msgData); - if (!shouldUseHopeFearAutomation()) return this.cancelRoll({ confirm: false }); - /* Handle resource updates from the finished TagTeamRoll */ - const tagTeamData = this.party.system.tagTeam; - const fearUpdate = { key: 'fear', value: null, total: null, enabled: true }; - for (let memberId in tagTeamData.members) { - const resourceUpdates = []; - const rollGivesHope = finalRoll.isCritical || finalRoll.withHope; - if (memberId === tagTeamData.initiator.memberId) { - const value = tagTeamData.initiator.cost - ? rollGivesHope - ? 1 - tagTeamData.initiator.cost - : -tagTeamData.initiator.cost - : 1; - resourceUpdates.push({ key: 'hope', value: value, total: -value, enabled: true }); - } else if (rollGivesHope) { - resourceUpdates.push({ key: 'hope', value: 1, total: -1, enabled: true }); - } - if (finalRoll.isCritical) resourceUpdates.push({ key: 'stress', value: -1, total: 1, enabled: true }); - if (finalRoll.withFear) { - fearUpdate.value = fearUpdate.value === null ? 1 : fearUpdate.value + 1; - fearUpdate.total = fearUpdate.total === null ? -1 : fearUpdate.total - 1; + if (shouldUseHopeFearAutomation({ gmAsPlayer: true })) { + const tagTeamData = this.party.system.tagTeam; + const fearUpdate = { key: 'fear', value: null, total: null, enabled: true }; + for (let memberId in tagTeamData.members) { + const resourceUpdates = []; + const rollGivesHope = finalRoll.isCritical || finalRoll.withHope; + if (memberId === tagTeamData.initiator.memberId) { + const value = tagTeamData.initiator.cost + ? rollGivesHope + ? 1 - tagTeamData.initiator.cost + : -tagTeamData.initiator.cost + : 1; + resourceUpdates.push({ key: 'hope', value: value, total: -value, enabled: true }); + } else if (rollGivesHope) { + resourceUpdates.push({ key: 'hope', value: 1, total: -1, enabled: true }); + } + if (finalRoll.isCritical) resourceUpdates.push({ key: 'stress', value: -1, total: 1, enabled: true }); + if (finalRoll.withFear) { + fearUpdate.value = fearUpdate.value === null ? 1 : fearUpdate.value + 1; + fearUpdate.total = fearUpdate.total === null ? -1 : fearUpdate.total - 1; + } + + game.actors.get(memberId).modifyResource(resourceUpdates); } - game.actors.get(memberId).modifyResource(resourceUpdates); - } - - if (fearUpdate.value) { - mainActor.modifyResource([fearUpdate]); + if (fearUpdate.value) { + mainActor.modifyResource([fearUpdate]); + } } /* Fin */ diff --git a/module/helpers/utils.mjs b/module/helpers/utils.mjs index e9b0dab0..6467edd7 100644 --- a/module/helpers/utils.mjs +++ b/module/helpers/utils.mjs @@ -886,7 +886,7 @@ export async function triggerChatRollFx(rolls, options = { whisper: false, blind } } -export function shouldUseHopeFearAutomation() { +export function shouldUseHopeFearAutomation(options = { gmAsPlayer: true }) { const { hopeFear } = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Automation); - return game.user.isGM ? hopeFear.gm : hopeFear.players; + return (!game.user.isGM || options.gmAsPlayer) ? hopeFear.players : hopeFear.gm; } \ No newline at end of file