Fixed migration, Spell Skill
This commit is contained in:
23
module/helpers/migration-helper.js
Normal file
23
module/helpers/migration-helper.js
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* Perform a system migration for the entire World, applying migrations for Actors, Items, and Compendium packs
|
||||
* @return {Promise} A Promise which resolves once the migration is completed
|
||||
*/
|
||||
export const migrateWorld = async function () {
|
||||
ui.notifications.info(
|
||||
`Applying System Migration for version ${game.system.data.version}. Please be patient and do not close your game or shut down your server.`,
|
||||
{permanent: true}
|
||||
);
|
||||
|
||||
console.log(game.system.data.version)
|
||||
|
||||
game.items.forEach((item) => {
|
||||
// Migrate to v0.1 from v0.0.1 and v0.0.1
|
||||
if (item.data.type === "spell") {
|
||||
item.update({"data.roll.label": "SPELL.ROLLTITLE"});
|
||||
}
|
||||
});
|
||||
|
||||
// Set the migration as complete
|
||||
game.settings.set("kopparhavet", "worldSchemaVersion", game.system.data.version);
|
||||
ui.notifications.info(`System Migration to version ${game.system.data.version} completed!`, { permanent: true });
|
||||
}
|
||||
@@ -72,6 +72,28 @@ export class ItemSheetKH extends ItemSheet {
|
||||
this.position.width = 405;
|
||||
this.position.height = 570;
|
||||
break;
|
||||
case "spell":
|
||||
// Load Skills Compendium skills
|
||||
let skillList3
|
||||
|
||||
if(game.settings.get("kopparhavet", "gameSystem") === "hjaltarnas-tid") {
|
||||
skillList3 = await game.packs.get("kopparhavet.skills-ht").getContent();
|
||||
} else {
|
||||
skillList3 = await game.packs.get("kopparhavet.skills").getContent();
|
||||
}
|
||||
|
||||
for (let item of skillList3) {
|
||||
if(item.data.type === "skill") {
|
||||
skillList.push(item)
|
||||
}
|
||||
}
|
||||
|
||||
// Retrieve any created skills as well
|
||||
for (let item of game.items.entities) {
|
||||
if(item.data.type === "skill") {
|
||||
skillList.push(item)
|
||||
}
|
||||
}
|
||||
default:
|
||||
this.position.width = 450;
|
||||
this.position.height = 605;
|
||||
|
||||
@@ -4,6 +4,7 @@ import KHHooks from "./kh-hooks.js";
|
||||
import { ActorKH } from "./actors/actor.js";
|
||||
import { ActorSheetKH } from "./actors/actor-sheet.js";
|
||||
import { KH } from "./kh-config.js";
|
||||
import * as migrations from "./helpers/migration-helper.js";
|
||||
|
||||
Hooks.once("init", () => {
|
||||
CONFIG.Combat.initiative = { formula: "(@combat.init)d6kh2", decimals: 0 };
|
||||
@@ -177,12 +178,21 @@ function registerHandlebarsHelpers() {
|
||||
}
|
||||
|
||||
function migrateWorld() {
|
||||
game.actors.forEach((actor) => {
|
||||
// Migrate to v0.0.2 from v0.0.1
|
||||
if(actor.data.type === "character") {
|
||||
if(!actor.data?.data?.bio?.appearance) {
|
||||
actor.update({"data.bio.appearance.label": "BIO.APPEARANCE", "data.bio.appearance.value": ""});
|
||||
}
|
||||
// Determine whether a system migration is required and feasible
|
||||
const currentVersion = game.settings.get("kopparhavet", "worldSchemaVersion");
|
||||
const NEEDS_MIGRATION_VERSION = 0.1;
|
||||
const COMPATIBLE_MIGRATION_VERSION = 0;
|
||||
let needMigration = currentVersion < NEEDS_MIGRATION_VERSION || currentVersion === null;
|
||||
|
||||
// Perform the migration
|
||||
if (needMigration && game.user.isGM) {
|
||||
if (currentVersion && currentVersion < COMPATIBLE_MIGRATION_VERSION) {
|
||||
ui.notifications.error(
|
||||
`Your system data is from a version that cannot be reliably migrated to the latest version. The process will be attempted, but errors may occur.`,
|
||||
{ permanent: true }
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
migrations.migrateWorld();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user