From 6f0173b14e2f20ef2d249c57362b96a8d6346770 Mon Sep 17 00:00:00 2001 From: sladecraven Date: Tue, 2 Nov 2021 21:03:04 +0100 Subject: [PATCH] Divers fixes --- compendium/wfrp4e-core.talents.json | 2 +- module.json | 2 +- modules/import-stat-2.js | 43 ++++++++++++++++++++++++----- 3 files changed, 38 insertions(+), 9 deletions(-) diff --git a/compendium/wfrp4e-core.talents.json b/compendium/wfrp4e-core.talents.json index a2668e2..849e173 100644 --- a/compendium/wfrp4e-core.talents.json +++ b/compendium/wfrp4e-core.talents.json @@ -482,7 +482,7 @@ "tests": "Commandement" }, { - "description": "Vous êtes doué pour la fabrication de potions, de philtres et de décoctions. Vous pouvez effectuer gratuitement une Activité Artisanat pour utiliser Savoir (Apothicaire) sans avoir besoin d'Atelier. Les autres Activités Artisanat suivent les règles normales.", + "description": "Vous êtes doué pour la fabrication de potions, de philtres et de décoctions. Vous pouvez effectuer gratuitement une Activité Artisanat pour utiliser Métier (Apothicaire) sans avoir besoin d'Atelier. Les autres Activités Artisanat suivent les règles normales.", "effects": [], "id": "Concoct", "name": "Concocter", diff --git a/module.json b/module.json index eee142b..41222c0 100644 --- a/module.json +++ b/module.json @@ -2,7 +2,7 @@ "name": "WH4-fr-translation", "title": "WFRP4e - Core Module en français.", "description": "Traduction Française pour Warhammer v4.", - "version": "4.2.3", + "version": "4.2.4", "minimumCoreVersion" : "0.8.0", "compatibleCoreVersion": "0.8.9", "author": "LeRatierBretonnien", diff --git a/modules/import-stat-2.js b/modules/import-stat-2.js index 5907689..4279242 100644 --- a/modules/import-stat-2.js +++ b/modules/import-stat-2.js @@ -37,9 +37,10 @@ const fr_carac = 'm\\s+ws\\s+bs\\s+s\\s+t\\s+i\\s+agi?\\s+dex\\s+int\\s+\\wp\\s+ const carac_val = '(?[0-9-]+)\\s+(?[0-9-]+)\\s+(?[0-9-]+)\\s+(?[0-9-]+)\\s+(?[0-9-]+)\\s+(?[0-9-]+)\\s+(?[0-9-]+)\\s+(?[0-9-]+)\\s+(?[0-9-]+)\\s+(?[0-9-]+)\\s+(?[0-9-]+)\\s+(?[0-9-\*]+)'; const name_val = '(?[a-zA-Z\\s\\-,]*)[\\s\\r\\na-zA-Z]*(?.*|[\\(\\)a-z0-9]+)'; let sectionData = [ - { name: "trait", toFind: "Traits\\s*:", secondParse: '(?[a-z\\s]*)[\\s\\+]*(?.*|[0-9]+)', index: -1 }, + { name: "trait", toFind: "Traits\\s*:", secondParse: '(?[a-z\\s]*)[\\s\\+]*(?.*|[\\+0-9]+)', index: -1 }, { name: "skill", toFind: "Skills\\s*:", secondParse: '(?[a-z\\s\\(\\)]*)[\\s\\+]*(?.*|[0-9]+)', index: -1 }, { name: "talent", toFind: "Talents\\s*:", secondParse: '(?[a-z\\-\\s!/]*)[\\s\\+]*(?.*|[0-9]+)', index: -1 }, + { name: "mutation", toFind: "Mutations\\s*:", secondParse: '(?[a-z\\s]*)[\\s\\+]*(?.*|[0-9]+)', index: -1 }, { name: "trapping", toFind: "Trappings\\s*:", secondParse: '(?[a-z\\s]*)[\\s\\+]*(?.*|[0-9]+)', index: -1 } ]; let regSep = XRegExp('\\s*,\\s*', 'gi'); // Term separator, with auto trim @@ -152,6 +153,13 @@ async function __findTalent(talentName) { throw "Could not find talent (or specialization of) " + talentName + " in compendium or world" } +/************************************************************************************/ +function __patchName ( name) { + if (name.toLowerCase == 'magic sense') + name = 'Magical Sense'; + return name; +} + /************************************************************************************/ export default async function statParserFR(statString, type = "npc") { let model = duplicate(game.system.model.Actor[type]); @@ -225,17 +233,24 @@ export default async function statParserFR(statString, type = "npc") { let itemFound, subres, value; if (def.secondParse) { subres = XRegExp.exec(name, XRegExp(def.secondParse, 'gi')); - name = subres.name.trim(); + name = subres.name.trim().replace("\n", "").replace("\r", ""); value = XRegExp.replace(subres.value, "(", ""); value = XRegExp.replace(subres.value, ")", ""); - } + } + name = __patchName(name); if (def.name == 'trait') { try { itemFound = await __findItem(name, "trait"); } catch { } + if (itemFound) + itemFound = itemFound.toObject(); if (itemFound && subres && subres.value.length > 0) { - itemFound.data.data.specification.value = game.i18n.localize(value); + if (name.toLowerCase == 'weapon') { + itemFound.data.specification.value = Number(value) - Math.floor( Number(model.characteristics.s.initial) / 10); + } else { + itemFound.data.specification.value = game.i18n.localize(value); + } } if (!itemFound) ui.notifications.error("Trait non trouvé, à ajouter manuellement : " + name, { permanent: true }) @@ -244,8 +259,10 @@ export default async function statParserFR(statString, type = "npc") { itemFound = await __findSkill(name, value); } catch { } + if (itemFound) + itemFound = itemFound.toObject(); if (itemFound && subres && value) { - itemFound.data.data.advances.value = Number(value) - Number(model.characteristics[itemFound.data.data.characteristic.value].initial); + itemFound.data.advances.value = Number(value) - Number(model.characteristics[itemFound.data.characteristic.value].initial); } if (!itemFound) ui.notifications.error("Compétence non trouvée, à ajouter manuellement : " + name, { permanent: true }) @@ -254,8 +271,10 @@ export default async function statParserFR(statString, type = "npc") { itemFound = await __findTalent(name); } catch { } + if (itemFound) + itemFound = itemFound.toObject(); if (itemFound && subres && value) - itemFound.data.data.advances.value = Number(value); + itemFound.data.advances.value = Number(value); if (!itemFound) ui.notifications.error("Talent non trouvé, à ajouter manuellement : " + name, { permanent: true }) } else if (def.name == 'trapping') { @@ -263,11 +282,21 @@ export default async function statParserFR(statString, type = "npc") { itemFound = await __findItem(name, "trapping"); } catch { } - if (!itemFound) { + if (!itemFound && name) { itemFound = new ItemWfrp4e({ img: "systems/wfrp4e/icons/blank.png", name: name, type: "trapping", data: game.system.model.Item.trapping }) itemFound.data.data.trappingType.value = "misc" + } + if (itemFound) + itemFound = itemFound.toObject(); + } else if (def.name == 'mutation') { + try { + itemFound = await __findItem(name, "mutation"); } + catch { } + if (itemFound) + itemFound = itemFound.toObject(); } + if (itemFound) globalItemList.push(itemFound); }