48 lines
1.5 KiB
JavaScript
48 lines
1.5 KiB
JavaScript
// SPDX-FileCopyrightText: 2021 Johannes Loher
|
|
//
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
import {
|
|
getActorUpdateDataGetter,
|
|
getCompendiumMigrator,
|
|
getSceneUpdateDataGetter,
|
|
migrateActors,
|
|
migrateCompendiums,
|
|
migrateItems,
|
|
migrateScenes,
|
|
} from "./migrationHelpers";
|
|
|
|
/** @type {import("./migration").Migration["migrate"]} */
|
|
async function migrate() {
|
|
await migrateItems(getItemUpdateData);
|
|
await migrateActors(getActorUpdateData);
|
|
await migrateScenes(getSceneUpdateData);
|
|
await migrateCompendiums(migrateCompendium);
|
|
}
|
|
|
|
/** @type {import("./migrationHelpers").ItemUpdateDataGetter} */
|
|
function getItemUpdateData(itemData) {
|
|
if (itemData.type !== "spell") return;
|
|
const cooldownDurationUnit = itemData.system?.cooldownDuration.unit;
|
|
|
|
const updateData = {
|
|
system: {
|
|
"-=scrollPrice": null,
|
|
minimumLevels: { healer: null, wizard: null, sorcerer: null },
|
|
cooldownDuration: {
|
|
unit: cooldownDurationUnit === "custom" ? "rounds" : cooldownDurationUnit,
|
|
},
|
|
},
|
|
};
|
|
return updateData;
|
|
}
|
|
|
|
const getActorUpdateData = getActorUpdateDataGetter(getItemUpdateData);
|
|
const getSceneUpdateData = getSceneUpdateDataGetter(getActorUpdateData);
|
|
const migrateCompendium = getCompendiumMigrator({ getItemUpdateData, getActorUpdateData, getSceneUpdateData });
|
|
|
|
/** @type {import("./migration").Migration} */
|
|
export const migration = {
|
|
migrate,
|
|
migrateCompendium,
|
|
};
|