// SPDX-FileCopyrightText: 2021 Johannes Loher // // SPDX-License-Identifier: MIT import { getSceneMigrator, migrateCollection, migrateCompendiums, getCompendiumMigrator, getActorMigrator, } from "./migrationHelpers.js"; /** @type {import("./migration.js").Migration["migrate"]} */ async function migrate() { await migrateCollection(game.items, migrateItem); await migrateCollection(game.actors, migrateActor); await migrateCollection(game.scenes, migrateScene); await migrateCompendiums(migrateCompendium); } /** @type {import('./migrationHelpers.js').Migrator} */ async function migrateItem(item) { if (item.type === "spell") { const cooldownDurationUnit = item.system?.cooldownDuration.unit; await item.update({ system: { "-=scrollPrice": null, minimumLevels: { healer: null, wizard: null, sorcerer: null }, cooldownDuration: { unit: cooldownDurationUnit === "custom" ? "rounds" : cooldownDurationUnit, }, }, }); } return updateData; } const migrateActor = getActorMigrator(migrateItem); const migrateScene = getSceneMigrator(migrateActor); const migrateCompendium = getCompendiumMigrator({ migrateItem, migrateActor, migrateScene }); /** @type {import("./migration.js").Migration} */ export const migration = { migrate, migrateCompendium, };