From 714d4edc1605df434776d6c37d3660511fb48fe8 Mon Sep 17 00:00:00 2001 From: WBHarry Date: Mon, 30 Mar 2026 22:47:28 +0200 Subject: [PATCH] Fixed TagTeamDialog --- module/applications/dialogs/tagTeamDialog.mjs | 60 ++++++++++--------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/module/applications/dialogs/tagTeamDialog.mjs b/module/applications/dialogs/tagTeamDialog.mjs index 33ddfbc0..2d363471 100644 --- a/module/applications/dialogs/tagTeamDialog.mjs +++ b/module/applications/dialogs/tagTeamDialog.mjs @@ -452,8 +452,12 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio const dieIndex = diceType === 'hope' ? 0 : diceType === 'fear' ? 1 : 2; const newRoll = game.system.api.dice.DualityRoll.fromData(memberData.rollData); const dice = newRoll.dice[dieIndex]; - await dice.reroll(`/r1=${dice.total}`, { liveRoll: true }); - await newRoll._evaluate(); + await dice.reroll(`/r1=${dice.total}`, { + liveRoll: { + roll: newRoll, + isReaction: true + } + }); const rollData = newRoll.toJSON(); this.updatePartyData( { @@ -694,6 +698,7 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio const joinedRoll = await this.getJoinedRoll(); const mainRoll = joinedRoll.rollData; + const finalRoll = foundry.utils.deepClone(joinedRoll.roll); const mainActor = this.party.system.partyMembers.find(x => x.uuid === mainRoll.options.source.actor); mainRoll.options.title = game.i18n.localize('DAGGERHEART.APPLICATIONS.TagTeamSelect.chatMessageRollTitle'); @@ -712,34 +717,33 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio await cls.create(msgData); /* 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 = mainRoll.options.roll.isCritical || mainRoll.options.roll.result.duality === 1; - // 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 (mainRoll.options.roll.isCritical) - // resourceUpdates.push({ key: 'stress', value: -1, total: 1, enabled: true }); - // if (mainRoll.options.roll.result.duality === -1) { - // fearUpdate.value = fearUpdate.value === null ? 1 : fearUpdate.value + 1; - // fearUpdate.total = fearUpdate.total === null ? -1 : fearUpdate.total - 1; - // } + 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 */ this.cancelRoll({ confirm: false });