Fix SWID again

This commit is contained in:
LeRatierBretonnien 2023-10-25 21:27:00 +02:00
parent b5ec752537
commit 00bc950479
2 changed files with 38 additions and 4 deletions

View File

@ -57,7 +57,7 @@
} }
], ],
"url": "https://www.uberwald.me/gitea/public/swade-fr-content", "url": "https://www.uberwald.me/gitea/public/swade-fr-content",
"version": "3.2.0", "version": "3.2.2",
"esmodules": [ "esmodules": [
"modules/swade-fr-init.js" "modules/swade-fr-init.js"
], ],
@ -73,7 +73,7 @@
} }
], ],
"manifest": "https://www.uberwald.me/gitea/public/swade-fr-content/raw/branch/master/module.json", "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", "id": "swade-fr-content",
"relationships": { "relationships": {
"requires": [ "requires": [

View File

@ -90,8 +90,8 @@ Hooks.once('init', () => {
return transl return transl
}, },
"skill_swid": (swid) => { "skill_swid": (swid) => {
if (swid == "fighting") return "combat"; if (swid == "combat") return "fighting";
if (swid == "shooting") return "tir"; if (swid == "tir") return "shooting";
return swid return swid
}, },
"category_converter": (category) => { "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', () => { Hooks.once('ready', () => {
console.log(">>>>>>>>>>") console.log(">>>>>>>>>>")
@ -409,6 +441,8 @@ Hooks.once('ready', () => {
}) })
SwadeFRContentCommands.init() SwadeFRContentCommands.init()
migrateSwid()
checkSwidSettings()
//FolderTranslate.translateFolders() //FolderTranslate.translateFolders()
registerUsageCount("swade-fr-content") registerUsageCount("swade-fr-content")