ds4/src/migrations/003.ts
Johannes Loher da1f6999eb feat: only allow specific selectable values for the cooldown duration of spells
World data (including compendium packs) is migrated automatically. In order to also migrate packs
provided by modules, you can use the following macro:
```js
const pack = game.packs.get("<name-of-the-module>.<name-of-the-pack>");
game.ds4.migration.migrateCompendiumFromTo(pack, 4, 5);
```
2022-02-16 01:58:21 +01:00

41 lines
1.1 KiB
TypeScript

// SPDX-FileCopyrightText: 2021 Johannes Loher
//
// SPDX-License-Identifier: MIT
import {
getActorUpdateDataGetter,
getCompendiumMigrator,
getSceneUpdateDataGetter,
migrateActors,
migrateCompendiums,
migrateItems,
migrateScenes,
} from "./migrationHelpers";
async function migrate(): Promise<void> {
await migrateItems(getItemUpdateData);
await migrateActors(getActorUpdateData);
await migrateScenes(getSceneUpdateData);
await migrateCompendiums(migrateCompendium);
}
function getItemUpdateData(itemData: Partial<foundry.data.ItemData["_source"]>) {
if (!["loot"].includes(itemData.type ?? "")) return undefined;
return {
data: {
"-=equipped": null,
},
};
}
const getActorUpdateData = getActorUpdateDataGetter(getItemUpdateData);
const getSceneUpdateData = getSceneUpdateDataGetter(getActorUpdateData);
const migrateCompendium = getCompendiumMigrator(
{ getItemUpdateData, getActorUpdateData },
{ migrateToTemplateEarly: false },
);
export const migration = {
migrate,
migrateCompendium,
};