This commit is contained in:
WBHarry 2026-06-19 16:19:09 +02:00
parent 3115e96c17
commit 9eeadba046
3 changed files with 42 additions and 41 deletions

View file

@ -481,22 +481,23 @@ export default class GroupRollDialog extends HandlebarsApplicationMixin(Applicat
await cls.create(msgData); 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); resourceMap.updateResources();
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();
/* Fin */ /* Fin */
this.cancelRoll({ confirm: false }); this.cancelRoll({ confirm: false });
} }

View file

@ -750,35 +750,35 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
await cls.create(msgData); await cls.create(msgData);
if (!shouldUseHopeFearAutomation()) return this.cancelRoll({ confirm: false });
/* Handle resource updates from the finished TagTeamRoll */ /* Handle resource updates from the finished TagTeamRoll */
const tagTeamData = this.party.system.tagTeam; if (shouldUseHopeFearAutomation({ gmAsPlayer: true })) {
const fearUpdate = { key: 'fear', value: null, total: null, enabled: true }; const tagTeamData = this.party.system.tagTeam;
for (let memberId in tagTeamData.members) { const fearUpdate = { key: 'fear', value: null, total: null, enabled: true };
const resourceUpdates = []; for (let memberId in tagTeamData.members) {
const rollGivesHope = finalRoll.isCritical || finalRoll.withHope; const resourceUpdates = [];
if (memberId === tagTeamData.initiator.memberId) { const rollGivesHope = finalRoll.isCritical || finalRoll.withHope;
const value = tagTeamData.initiator.cost if (memberId === tagTeamData.initiator.memberId) {
? rollGivesHope const value = tagTeamData.initiator.cost
? 1 - tagTeamData.initiator.cost ? rollGivesHope
: -tagTeamData.initiator.cost ? 1 - tagTeamData.initiator.cost
: 1; : -tagTeamData.initiator.cost
resourceUpdates.push({ key: 'hope', value: value, total: -value, enabled: true }); : 1;
} else if (rollGivesHope) { resourceUpdates.push({ key: 'hope', value: value, total: -value, enabled: true });
resourceUpdates.push({ key: 'hope', value: 1, total: -1, 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) { if (finalRoll.isCritical) resourceUpdates.push({ key: 'stress', value: -1, total: 1, enabled: true });
fearUpdate.value = fearUpdate.value === null ? 1 : fearUpdate.value + 1; if (finalRoll.withFear) {
fearUpdate.total = fearUpdate.total === null ? -1 : fearUpdate.total - 1; 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 */ /* Fin */

View file

@ -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); 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;
} }