Fixed so that automated countdowns reverse progress from Fear when rerolling dice if the duality result changes

This commit is contained in:
WBHarry 2026-06-21 16:08:46 +02:00
parent 3840f39c97
commit 4d81509e79
5 changed files with 38 additions and 23 deletions

View file

@ -362,11 +362,11 @@ export default class DualityRoll extends D20Roll {
if (config.roll.result.duality === -1) {
await updateCountdowns(
CONFIG.DH.GENERAL.countdownProgressionTypes.actionRoll.id,
CONFIG.DH.GENERAL.countdownProgressionTypes.fear.id
{ type: CONFIG.DH.GENERAL.countdownProgressionTypes.actionRoll.id },
{ type: CONFIG.DH.GENERAL.countdownProgressionTypes.fear.id }
);
} else {
await updateCountdowns(CONFIG.DH.GENERAL.countdownProgressionTypes.actionRoll.id);
await updateCountdowns({ type: CONFIG.DH.GENERAL.countdownProgressionTypes.actionRoll.id });
}
}

View file

@ -1,19 +1,33 @@
import { ResourceUpdateMap } from '../data/action/baseAction.mjs';
export function updateResourcesForDualityReroll(oldDuality, newDuality, actor) {
const { hopeFear } = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Automation);
if (game.user.isGM ? !hopeFear.gm : !hopeFear.players) return;
const updates = [];
const hope = (newDuality >= 0 ? 1 : 0) - (oldDuality >= 0 ? 1 : 0);
const stress = (newDuality === 0 ? 1 : 0) - (oldDuality === 0 ? 1 : 0);
const fear = (newDuality === -1 ? 1 : 0) - (oldDuality === -1 ? 1 : 0);
if (hope !== 0) updates.push({ key: 'hope', value: hope, enabled: true });
if (stress !== 0) updates.push({ key: 'stress', value: -1 * stress, enabled: true });
if (fear !== 0) updates.push({ key: 'fear', value: fear, enabled: true });
const { hopeFear, countdownAutomation } =
game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Automation);
const resourceUpdates = new ResourceUpdateMap(actor);
resourceUpdates.addResources(updates);
resourceUpdates.updateResources();
if (game.user.isGM ? hopeFear.gm : hopeFear.players) {
const updates = [];
if (hope !== 0) updates.push({ key: 'hope', value: hope, enabled: true });
if (stress !== 0) updates.push({ key: 'stress', value: -1 * stress, enabled: true });
if (fear !== 0) updates.push({ key: 'fear', value: fear, enabled: true })
const resourceUpdates = new ResourceUpdateMap(actor);
resourceUpdates.addResources(updates);
resourceUpdates.updateResources();
}
if (countdownAutomation) {
const updates = [];
if (fear !== 0) {
updates.push({
type: CONFIG.DH.GENERAL.countdownProgressionTypes.fear.id,
reverseDirection: fear === 1 ? false : true
});
}
game.system.api.applications.ui.DhCountdowns.updateCountdowns(...updates);
}
}