diff --git a/src/fxmaster.js b/src/fxmaster.js index c965291a..7e32150b 100644 --- a/src/fxmaster.js +++ b/src/fxmaster.js @@ -102,6 +102,7 @@ Hooks.once("init", function () { ]), ); + CONFIG.originalWeatherEffects = CONFIG.weatherEffects; CONFIG.weatherEffects = { ...CONFIG.weatherEffects, ...weatherEffects }; }); diff --git a/src/migration/world/4.js b/src/migration/world/4.js new file mode 100644 index 00000000..9447da7f --- /dev/null +++ b/src/migration/world/4.js @@ -0,0 +1,21 @@ +import { migrate } from "../helpers"; + +export async function migrate4() { + return migrate(migrationConfiguration4); +} + +/** @type {import('../helpers').MigrationConfiguration} */ +export const migrationConfiguration4 = { + Scene: migrateScene, +}; + +async function migrateScene(scene) { + const originalWeatherEffectKeys = Object.keys(CONFIG.originalWeatherEffects); + const weatherEffectsToMigrate = Object.keys(CONFIG.fxmaster.particleEffects).filter( + (effect) => !originalWeatherEffectKeys.includes(effect), // only migrate effects where we are certain they are ours + ); + + if (weatherEffectsToMigrate.includes(scene.weather)) { + await scene.update({ weather: `fxmaster.${scene.weather}` }); + } +} diff --git a/src/migration/world/migration.js b/src/migration/world/migration.js index be357389..e1bc54b7 100644 --- a/src/migration/world/migration.js +++ b/src/migration/world/migration.js @@ -2,8 +2,9 @@ import { packageId } from "../../constants.js"; import { migrate2, migrationConfiguration2 } from "./2.js"; import { migrate3, migrationConfiguration3 } from "./3.js"; +import { migrate4, migrationConfiguration4 } from "./4.js"; -export const targetServerMigration = 3; +export const targetServerMigration = 4; export async function migrateWorld() { const migration = game.settings.get(packageId, "migration"); @@ -21,6 +22,8 @@ export async function migrateWorld() { isError |= await migrate2(); case 2: isError |= await migrate3(); + case 3: + isError |= await migrate4(); } if (isError) { @@ -46,4 +49,8 @@ export const worldMigrations = { migrate: migrate3, config: migrationConfiguration3, }, + 4: { + migrate: migrate4, + config: migrationConfiguration4, + }, };