2021-06-26 22:02:00 +02:00
|
|
|
// SPDX-FileCopyrightText: 2021 Johannes Loher
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
2023-07-09 20:53:18 +02:00
|
|
|
import { getSceneMigrator, migrateCollection, migrateCompendiums, getCompendiumMigrator } from "./migrationHelpers.js";
|
2021-06-26 14:32:40 +02:00
|
|
|
|
2023-07-09 20:53:18 +02:00
|
|
|
/** @type {import("./migration.js").Migration["migrate"]} */
|
2022-11-17 00:12:29 +01:00
|
|
|
async function migrate() {
|
2023-07-09 20:53:18 +02:00
|
|
|
await migrateCollection(game.actors, migrateActor);
|
|
|
|
await migrateCollection(game.scenes, migrateScene);
|
2021-07-08 02:32:25 +02:00
|
|
|
await migrateCompendiums(migrateCompendium);
|
2021-01-19 03:31:40 +01:00
|
|
|
}
|
|
|
|
|
2023-07-09 20:53:18 +02:00
|
|
|
/** @type {import('./migrationHelpers.js').Migrator<Actor>} */
|
|
|
|
async function migrateActor(actor) {
|
|
|
|
await actor.update({
|
2022-11-21 03:00:46 +01:00
|
|
|
system: {
|
2021-01-19 03:31:40 +01:00
|
|
|
combatValues: [
|
|
|
|
"hitPoints",
|
|
|
|
"defense",
|
|
|
|
"initiative",
|
|
|
|
"movement",
|
|
|
|
"meleeAttack",
|
|
|
|
"rangedAttack",
|
|
|
|
"spellcasting",
|
|
|
|
"targetedSpellcasting",
|
2022-11-17 00:12:29 +01:00
|
|
|
].reduce((acc, curr) => {
|
2021-01-19 03:31:40 +01:00
|
|
|
acc[curr] = { "-=base": null };
|
|
|
|
return acc;
|
|
|
|
}, {}),
|
|
|
|
},
|
2023-07-09 20:53:18 +02:00
|
|
|
});
|
2021-01-19 03:31:40 +01:00
|
|
|
}
|
2021-07-08 02:32:25 +02:00
|
|
|
|
2023-07-09 20:53:18 +02:00
|
|
|
const migrateScene = getSceneMigrator(migrateActor);
|
2022-02-14 00:58:23 +01:00
|
|
|
|
2023-07-09 20:53:18 +02:00
|
|
|
const migrateCompendium = getCompendiumMigrator({ migrateActor, migrateScene });
|
|
|
|
|
|
|
|
/** @type {import("./migration.js").Migration} */
|
2022-02-14 00:58:23 +01:00
|
|
|
export const migration = {
|
|
|
|
migrate,
|
|
|
|
migrateCompendium,
|
|
|
|
};
|