2021-06-26 22:02:00 +02:00
|
|
|
// SPDX-FileCopyrightText: 2021 Johannes Loher
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
2021-07-08 02:32:25 +02:00
|
|
|
import {
|
|
|
|
getCompendiumMigrator,
|
|
|
|
getSceneUpdateDataGetter,
|
|
|
|
migrateActors,
|
|
|
|
migrateCompendiums,
|
|
|
|
migrateScenes,
|
|
|
|
} from "./migrationHelpers";
|
2021-06-26 14:32:40 +02:00
|
|
|
|
2022-02-14 00:58:23 +01:00
|
|
|
async function migrate(): Promise<void> {
|
2021-07-08 02:32:25 +02:00
|
|
|
await migrateActors(getActorUpdateData);
|
|
|
|
await migrateScenes(getSceneUpdateData);
|
|
|
|
await migrateCompendiums(migrateCompendium);
|
2021-01-19 03:31:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function getActorUpdateData(): Record<string, unknown> {
|
|
|
|
const updateData = {
|
|
|
|
data: {
|
|
|
|
combatValues: [
|
|
|
|
"hitPoints",
|
|
|
|
"defense",
|
|
|
|
"initiative",
|
|
|
|
"movement",
|
|
|
|
"meleeAttack",
|
|
|
|
"rangedAttack",
|
|
|
|
"spellcasting",
|
|
|
|
"targetedSpellcasting",
|
2021-02-07 13:51:20 +01:00
|
|
|
].reduce((acc: Partial<Record<string, { "-=base": null }>>, curr) => {
|
2021-01-19 03:31:40 +01:00
|
|
|
acc[curr] = { "-=base": null };
|
|
|
|
return acc;
|
|
|
|
}, {}),
|
|
|
|
},
|
|
|
|
};
|
|
|
|
return updateData;
|
|
|
|
}
|
2021-07-08 02:32:25 +02:00
|
|
|
|
|
|
|
const getSceneUpdateData = getSceneUpdateDataGetter(getActorUpdateData);
|
|
|
|
const migrateCompendium = getCompendiumMigrator({ getActorUpdateData, getSceneUpdateData });
|
2022-02-14 00:58:23 +01:00
|
|
|
|
|
|
|
export const migration = {
|
|
|
|
migrate,
|
|
|
|
migrateCompendium,
|
|
|
|
};
|