Fixed migration, Spell Skill

pull/2/head
Erebus 2020-12-01 06:30:17 +01:00
parent 6f6a1e7e2d
commit d94636bbe6
8 changed files with 92 additions and 14 deletions

View File

@ -81,6 +81,9 @@
"SPELL.DIFFICULTY": "Difficulty",
"SPELL.ROLL": "Roll",
"SPELL.COST": "Cost",
"SPELL.ATTACKROLL": "Attack roll",
"SPELL.OPPOSITE": "Opposite",
"SPELL.RITUAL": "Ritual",
"STATS.HEALTH": "Health",
"STATS.MANA": "Mana",

View File

@ -81,8 +81,12 @@
"SKILL.LANGUAGE": "Språk",
"SPELL.DIFFICULTY": "Svårighet",
"SPELL.ROLL": "Slag",
"SPELL.ROLLTITLE": "Slag",
"SPELL.COST": "Kostnad",
"SPELL.ROLL": "Färdighetsslag",
"SPELL.ATTACKROLL": "Anfallsslag",
"SPELL.OPPOSITE": "Motsatt",
"SPELL.RITUAL": "Ritual",
"STATS.HEALTH": "Hälsa",
"STATS.MANA": "Skuld",

View 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 });
}

View File

@ -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;

View File

@ -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();
}
}

View File

@ -2,10 +2,10 @@
"name": "kopparhavet",
"title": "Kopparhavets Hjältar",
"description": "The Molten Sea is a dangerous but exciting place, where pirates, sorcerers and secretive orders of knighthood struggle for power, wealth and ancient lore.",
"version": "0.0.2",
"version": "0.1",
"minimumCoreVersion": "0.7.5",
"compatibleCoreVersion": "0.7.7",
"templateVersion": 3,
"templateVersion": 4,
"author": "Erebus",
"scripts": [],
"esmodules": [
@ -53,6 +53,6 @@
"url": "https://pi.rikspolisen.se/foundryvtt/kopparhavet",
"socket": true,
"manifest": "https://pi.rikspolisen.se/foundryvtt/kopparhavet/raw/branch/master/system.json",
"download": "https://pi.rikspolisen.se/foundryvtt/kopparhavet/archive/v0.0.2.zip",
"download": "https://pi.rikspolisen.se/foundryvtt/kopparhavet/archive/v0.1.zip",
"license": ""
}

View File

@ -230,9 +230,10 @@
"core"
],
"roll": {
"value": "",
"value": "roll",
"type": "String",
"label": "SPELL.ROLL"
"label": "SPELL.ROLLTITLE",
"skill": "Trolldom"
},
"cost": {
"value": "",

View File

@ -26,7 +26,22 @@
</div>
<div style="grid-column-start: 1; grid-column-end: 3;">
<label>{{localize data.roll.label}}</label>
<input name="data.roll.value" type="text" value="{{data.roll.value}}" />
<select class="item-weapon-cat-select" name="data.roll.value">
{{#select data.roll.value}}
<option value="roll">{{localize "SPELL.ROLL"}}</option>
<option value="attackroll">{{localize "SPELL.ATTACKROLL"}}</option>
<option value="opposite">{{localize "SPELL.OPPOSITE"}}</option>
<option value="ritual">{{localize "SPELL.RITUAL"}}</option>
{{/select}}
</select>
<label>{{localize "ITEM.SKILL"}}</label>
<select class="item-weapon-skill-select" name="data.roll.skill">
{{#select data.roll.skill}}
{{#each this.khskills as |t|}}
<option value="{{t.name}}">{{t.name}}</option>
{{/each}}
{{/select}}
</select>
</div>
</div>
<div class="item">