mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-07-22 02:19:54 +02:00
[Fix] Reroll Countdown Automation (#2031)
* Fixed so that automated countdowns reverse progress from Fear when rerolling dice if the duality result changes * . * Removed overprep * Apply suggestion from @CarlosFdez --------- Co-authored-by: Carlos Fernandez <CarlosFdez@users.noreply.github.com>
This commit is contained in:
parent
cc16a726bf
commit
1492491998
2 changed files with 27 additions and 16 deletions
|
|
@ -1,19 +1,28 @@
|
|||
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 && fear !== 0) {
|
||||
game.system.api.applications.ui.DhCountdowns.updateCountdowns({
|
||||
type: CONFIG.DH.GENERAL.countdownProgressionTypes.fear.id,
|
||||
undo: fear === 1 ? false : true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue