From 00bc950479e783be106b313619ddac435939b012 Mon Sep 17 00:00:00 2001 From: LeRatierBretonnien Date: Wed, 25 Oct 2023 21:27:00 +0200 Subject: [PATCH] Fix SWID again --- module.json | 4 ++-- modules/swade-fr-init.js | 38 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/module.json b/module.json index 8c0d817..44a7851 100644 --- a/module.json +++ b/module.json @@ -57,7 +57,7 @@ } ], "url": "https://www.uberwald.me/gitea/public/swade-fr-content", - "version": "3.2.0", + "version": "3.2.2", "esmodules": [ "modules/swade-fr-init.js" ], @@ -73,7 +73,7 @@ } ], "manifest": "https://www.uberwald.me/gitea/public/swade-fr-content/raw/branch/master/module.json", - "download": "https://www.uberwald.me/gitea/public/swade-fr-content/archive/swade-fr-content-3.2.0.zip", + "download": "https://www.uberwald.me/gitea/public/swade-fr-content/archive/swade-fr-content-3.2.2.zip", "id": "swade-fr-content", "relationships": { "requires": [ diff --git a/modules/swade-fr-init.js b/modules/swade-fr-init.js index eebff7d..4d07428 100644 --- a/modules/swade-fr-init.js +++ b/modules/swade-fr-init.js @@ -90,8 +90,8 @@ Hooks.once('init', () => { return transl }, "skill_swid": (swid) => { - if (swid == "fighting") return "combat"; - if (swid == "shooting") return "tir"; + if (swid == "combat") return "fighting"; + if (swid == "tir") return "shooting"; return swid }, "category_converter": (category) => { @@ -394,6 +394,38 @@ async function loadSecretCompendiums() { } } +/************************************************************************************/ +function processItemSwid(actor, item) { + let swid = item.system.swid + let newSwid = swid + if (swid == "combat") newSwid = "fighting"; + if (swid == "tir") newSwid = "shooting"; + if (swid != newSwid) { + console.log("Item to update", item.name, swid, newSwid) + actor.updateEmbeddedDocuments('Item', [{ _id: item.id, "system.swid": newSwid }]) + } +} + +/************************************************************************************/ +function migrateSwid() { + for (let actor of game.actors) { + for (let item of actor.items) { + if (item.system?.swid) { + processItemSwid(actor, item) + } + } + } +} + +/************************************************************************************/ +function checkSwidSettings() { + let swidFighting = game.settings.get('swade', 'parryBaseSwid') + if (swidFighting != "fighting") { + ui.notifications.warn("Votre compétence de parade n'est pas positionnée à 'fighting' dans les paramètres de SWADE. Nous vous recommandons de le faire pour éviter des problèmes de calcul de la parade.") + //game.settings.set('swade', 'parryBaseSwid', "fighting") + } +} + /************************************************************************************/ Hooks.once('ready', () => { console.log(">>>>>>>>>>") @@ -409,6 +441,8 @@ Hooks.once('ready', () => { }) SwadeFRContentCommands.init() + migrateSwid() + checkSwidSettings() //FolderTranslate.translateFolders() registerUsageCount("swade-fr-content")