Fixed migration, Spell Skill
							parent
							
								
									6f6a1e7e2d
								
							
						
					
					
						commit
						d94636bbe6
					
				|  | @ -81,6 +81,9 @@ | ||||||
|     "SPELL.DIFFICULTY": "Difficulty", |     "SPELL.DIFFICULTY": "Difficulty", | ||||||
|     "SPELL.ROLL": "Roll", |     "SPELL.ROLL": "Roll", | ||||||
|     "SPELL.COST": "Cost", |     "SPELL.COST": "Cost", | ||||||
|  |     "SPELL.ATTACKROLL": "Attack roll", | ||||||
|  |     "SPELL.OPPOSITE": "Opposite", | ||||||
|  |     "SPELL.RITUAL": "Ritual", | ||||||
| 
 | 
 | ||||||
|     "STATS.HEALTH": "Health", |     "STATS.HEALTH": "Health", | ||||||
|     "STATS.MANA": "Mana", |     "STATS.MANA": "Mana", | ||||||
|  |  | ||||||
|  | @ -81,8 +81,12 @@ | ||||||
|     "SKILL.LANGUAGE": "Språk", |     "SKILL.LANGUAGE": "Språk", | ||||||
| 
 | 
 | ||||||
|     "SPELL.DIFFICULTY": "Svårighet", |     "SPELL.DIFFICULTY": "Svårighet", | ||||||
|     "SPELL.ROLL": "Slag", |     "SPELL.ROLLTITLE": "Slag", | ||||||
|     "SPELL.COST": "Kostnad", |     "SPELL.COST": "Kostnad", | ||||||
|  |     "SPELL.ROLL": "Färdighetsslag", | ||||||
|  |     "SPELL.ATTACKROLL": "Anfallsslag", | ||||||
|  |     "SPELL.OPPOSITE": "Motsatt", | ||||||
|  |     "SPELL.RITUAL": "Ritual", | ||||||
| 
 | 
 | ||||||
|     "STATS.HEALTH": "Hälsa", |     "STATS.HEALTH": "Hälsa", | ||||||
|     "STATS.MANA": "Skuld", |     "STATS.MANA": "Skuld", | ||||||
|  |  | ||||||
|  | @ -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.width = 405; | ||||||
|                 this.position.height = 570; |                 this.position.height = 570; | ||||||
|                 break; |                 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: |             default: | ||||||
|                 this.position.width = 450; |                 this.position.width = 450; | ||||||
|                 this.position.height = 605; |                 this.position.height = 605; | ||||||
|  |  | ||||||
|  | @ -4,6 +4,7 @@ import KHHooks from "./kh-hooks.js"; | ||||||
| import { ActorKH } from "./actors/actor.js"; | import { ActorKH } from "./actors/actor.js"; | ||||||
| import { ActorSheetKH } from "./actors/actor-sheet.js"; | import { ActorSheetKH } from "./actors/actor-sheet.js"; | ||||||
| import { KH } from "./kh-config.js"; | import { KH } from "./kh-config.js"; | ||||||
|  | import * as migrations from "./helpers/migration-helper.js"; | ||||||
| 
 | 
 | ||||||
| Hooks.once("init", () => { | Hooks.once("init", () => { | ||||||
|     CONFIG.Combat.initiative = { formula: "(@combat.init)d6kh2", decimals: 0 }; |     CONFIG.Combat.initiative = { formula: "(@combat.init)d6kh2", decimals: 0 }; | ||||||
|  | @ -177,12 +178,21 @@ function registerHandlebarsHelpers() { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function migrateWorld() { | function migrateWorld() { | ||||||
|     game.actors.forEach((actor) => { |     // Determine whether a system migration is required and feasible
 | ||||||
|         // Migrate to v0.0.2 from v0.0.1
 |     const currentVersion = game.settings.get("kopparhavet", "worldSchemaVersion"); | ||||||
|         if(actor.data.type === "character") { |     const NEEDS_MIGRATION_VERSION = 0.1; | ||||||
|             if(!actor.data?.data?.bio?.appearance) { |     const COMPATIBLE_MIGRATION_VERSION = 0; | ||||||
|                 actor.update({"data.bio.appearance.label": "BIO.APPEARANCE", "data.bio.appearance.value": ""}); |     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(); | ||||||
|     } |     } | ||||||
|     }); |  | ||||||
| } | } | ||||||
|  | @ -2,10 +2,10 @@ | ||||||
|     "name": "kopparhavet", |     "name": "kopparhavet", | ||||||
|     "title": "Kopparhavets Hjältar", |     "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.", |     "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", |     "minimumCoreVersion": "0.7.5", | ||||||
|     "compatibleCoreVersion": "0.7.7", |     "compatibleCoreVersion": "0.7.7", | ||||||
|     "templateVersion": 3, |     "templateVersion": 4, | ||||||
|     "author": "Erebus", |     "author": "Erebus", | ||||||
|     "scripts": [], |     "scripts": [], | ||||||
|     "esmodules": [ |     "esmodules": [ | ||||||
|  | @ -53,6 +53,6 @@ | ||||||
|     "url": "https://pi.rikspolisen.se/foundryvtt/kopparhavet", |     "url": "https://pi.rikspolisen.se/foundryvtt/kopparhavet", | ||||||
|     "socket": true, |     "socket": true, | ||||||
|     "manifest": "https://pi.rikspolisen.se/foundryvtt/kopparhavet/raw/branch/master/system.json", |     "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": "" |     "license": "" | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -230,9 +230,10 @@ | ||||||
|                 "core" |                 "core" | ||||||
|             ], |             ], | ||||||
|             "roll": { |             "roll": { | ||||||
|                 "value": "", |                 "value": "roll", | ||||||
|                 "type": "String", |                 "type": "String", | ||||||
|                 "label": "SPELL.ROLL" |                 "label": "SPELL.ROLLTITLE", | ||||||
|  |                 "skill": "Trolldom" | ||||||
|             }, |             }, | ||||||
|             "cost": { |             "cost": { | ||||||
|                 "value": "", |                 "value": "", | ||||||
|  |  | ||||||
|  | @ -26,7 +26,22 @@ | ||||||
|         </div> |         </div> | ||||||
|         <div style="grid-column-start: 1; grid-column-end: 3;"> |         <div style="grid-column-start: 1; grid-column-end: 3;"> | ||||||
|             <label>{{localize data.roll.label}}</label> |             <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> |     </div> | ||||||
|     <div class="item"> |     <div class="item"> | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue