mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-07-22 18:39:55 +02:00
Fixed so that automated countdowns reverse progress from Fear when rerolling dice if the duality result changes
This commit is contained in:
parent
3840f39c97
commit
4d81509e79
5 changed files with 38 additions and 23 deletions
|
|
@ -202,11 +202,11 @@ export default class DhCombatTracker extends foundry.applications.sidebar.tabs.C
|
|||
const { updateCountdowns } = game.system.api.applications.ui.DhCountdowns;
|
||||
if (combatant.actor?.type === 'character') {
|
||||
await updateCountdowns(
|
||||
CONFIG.DH.GENERAL.countdownProgressionTypes.spotlight.id,
|
||||
CONFIG.DH.GENERAL.countdownProgressionTypes.characterSpotlight.id
|
||||
{ type: CONFIG.DH.GENERAL.countdownProgressionTypes.spotlight.id },
|
||||
{ type: CONFIG.DH.GENERAL.countdownProgressionTypes.characterSpotlight.id }
|
||||
);
|
||||
} else {
|
||||
await updateCountdowns(CONFIG.DH.GENERAL.countdownProgressionTypes.spotlight.id);
|
||||
await updateCountdowns({ type: CONFIG.DH.GENERAL.countdownProgressionTypes.spotlight.id });
|
||||
}
|
||||
|
||||
const autoPoints = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Automation).actionPoints;
|
||||
|
|
|
|||
|
|
@ -342,7 +342,7 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
|
|||
* Sends updates of the countdowns to the GM player. Since this is asynchronous, be sure to
|
||||
* update all the countdowns at the same time.
|
||||
*
|
||||
* @param {...any} progressTypes Countdowns to be updated
|
||||
* @param {...{ type: <key>, reverseDirection: boolean }} progressTypes Countdowns to be updated
|
||||
*/
|
||||
static async updateCountdowns(...progressTypes) {
|
||||
const { countdownAutomation } = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Automation);
|
||||
|
|
@ -351,20 +351,21 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
|
|||
const countdownSetting = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Countdowns);
|
||||
const updatedCountdowns = Object.keys(countdownSetting.countdowns).reduce((acc, key) => {
|
||||
const countdown = countdownSetting.countdowns[key];
|
||||
if (progressTypes.indexOf(countdown.progress.type) !== -1 && countdown.progress.current > 0) {
|
||||
acc.push(key);
|
||||
const progressData = progressTypes.find(x => x.type === countdown.progress.type);
|
||||
if (progressData && countdown.progress.current > 0) {
|
||||
acc[key] = { value: progressData.reverseDirection ? 1 : -1 };
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, []);
|
||||
}, {});
|
||||
|
||||
const countdownData = countdownSetting.toObject();
|
||||
const settings = {
|
||||
...countdownData,
|
||||
countdowns: Object.keys(countdownData.countdowns).reduce((acc, key) => {
|
||||
const countdown = foundry.utils.deepClone(countdownData.countdowns[key]);
|
||||
if (updatedCountdowns.includes(key)) {
|
||||
countdown.progress.current -= 1;
|
||||
if (updatedCountdowns[key]) {
|
||||
countdown.progress.current += updatedCountdowns[key].value;
|
||||
}
|
||||
|
||||
acc[key] = countdown;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue