diff --git a/lang/en.json b/lang/en.json index 3433f91..0530a81 100644 --- a/lang/en.json +++ b/lang/en.json @@ -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", diff --git a/lang/sv.json b/lang/sv.json index 7216551..4448010 100644 --- a/lang/sv.json +++ b/lang/sv.json @@ -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", diff --git a/module/helpers/migration-helper.js b/module/helpers/migration-helper.js new file mode 100644 index 0000000..e23a271 --- /dev/null +++ b/module/helpers/migration-helper.js @@ -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 }); +} \ No newline at end of file diff --git a/module/items/item-sheet.js b/module/items/item-sheet.js index 0d765bd..76fa16d 100644 --- a/module/items/item-sheet.js +++ b/module/items/item-sheet.js @@ -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; diff --git a/module/kh-main.js b/module/kh-main.js index 763e905..44f33a1 100644 --- a/module/kh-main.js +++ b/module/kh-main.js @@ -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(); + } } \ No newline at end of file diff --git a/system.json b/system.json index ebc97d9..0047383 100644 --- a/system.json +++ b/system.json @@ -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": "" } diff --git a/template.json b/template.json index 5806e21..ef81933 100644 --- a/template.json +++ b/template.json @@ -230,9 +230,10 @@ "core" ], "roll": { - "value": "", + "value": "roll", "type": "String", - "label": "SPELL.ROLL" + "label": "SPELL.ROLLTITLE", + "skill": "Trolldom" }, "cost": { "value": "", diff --git a/templates/items/spell-sheet.html b/templates/items/spell-sheet.html index 1dc9ee6..9eab423 100644 --- a/templates/items/spell-sheet.html +++ b/templates/items/spell-sheet.html @@ -26,7 +26,22 @@
- + + +