Added migration for overleveled companions

This commit is contained in:
WBHarry 2026-01-24 20:40:17 +01:00
parent 2fcad0ff25
commit b52bfa8a87

View file

@ -212,6 +212,7 @@ export async function runMigrations() {
} }
if (foundry.utils.isNewerVersion('1.5.5', lastMigrationVersion)) { if (foundry.utils.isNewerVersion('1.5.5', lastMigrationVersion)) {
/* Clear out Environments that were added directly from compendium */
for (const scene of game.scenes) { for (const scene of game.scenes) {
if (!scene.flags.daggerheart) continue; if (!scene.flags.daggerheart) continue;
const systemData = new game.system.api.data.scenes.DHScene(scene.flags.daggerheart); const systemData = new game.system.api.data.scenes.DHScene(scene.flags.daggerheart);
@ -224,6 +225,21 @@ export async function runMigrations() {
ui.nav.render(true); ui.nav.render(true);
/* Delevel any companions that are higher level than their partner character */
for (const companion of game.actors.filter(x => x.type === 'companion')) {
if (companion.system.levelData.level.current <= 1) continue;
if (!companion.system.partner) {
await companion.updateLevel(1);
} else {
const endLevel = companion.system.partner.system.levelData.level.current;
if (endLevel < companion.system.levelData.level.current) {
companion.system.levelData.level.changed = companion.system.levelData.level.current;
await companion.updateLevel(endLevel);
}
}
}
lastMigrationVersion = '1.5.5'; lastMigrationVersion = '1.5.5';
} }
//#endregion //#endregion