From 35c92ffcf4b38969e64948b0dff8e1d312dc9437 Mon Sep 17 00:00:00 2001 From: WBHarry Date: Tue, 16 Sep 2025 16:27:57 +0200 Subject: [PATCH] Fixed migration of countdowns --- module/systemRegistration/migrations.mjs | 34 +++++++++++++++++++----- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/module/systemRegistration/migrations.mjs b/module/systemRegistration/migrations.mjs index e4a2abc4..684e9795 100644 --- a/module/systemRegistration/migrations.mjs +++ b/module/systemRegistration/migrations.mjs @@ -150,12 +150,34 @@ export async function runMigrations() { } /* Migrate old countdown structure */ - const { narrative, encounter } = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Countdowns); - if (narrative) { - narrative.countdowns; - } - if (encounter) { - } + const countdownSettings = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Countdowns); + const getCountdowns = (data, type) => { + return Object.keys(data.countdowns).reduce((acc, key) => { + const countdown = data.countdowns[key]; + acc[key] = { + ...countdown, + type: type, + ownership: Object.keys(countdown.ownership.players).reduce((acc, key) => { + acc[key] = countdown.ownership.players[key].type; + return acc; + }, {}), + progress: { + ...countdown.progress, + type: countdown.progress.value + } + }; + + return acc; + }); + }; + + await countdownSettings.updateSource({ + countdowns: { + ...getCountdowns(countdownSettings.narrative, CONFIG.DH.GENERAL.countdownBaseTypes.narrative.id), + ...getCountdowns(countdownSettings.encounter, CONFIG.DH.GENERAL.countdownBaseTypes.encounter.id) + } + }); + await game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Countdowns, countdownSettings); lastMigrationVersion = '1.2.0'; }