From 81d826ee2e3ae89069a523b6a25f77b2d66cc38b Mon Sep 17 00:00:00 2001 From: LeRatierBretonnien Date: Fri, 6 Dec 2024 13:29:25 +0100 Subject: [PATCH] Fix import de creatures sans heure de naissance --- module/apps/rdd-import-stats.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/module/apps/rdd-import-stats.js b/module/apps/rdd-import-stats.js index 8efa0b5d..63209789 100644 --- a/module/apps/rdd-import-stats.js +++ b/module/apps/rdd-import-stats.js @@ -106,6 +106,12 @@ export class RdDStatBlockParser { return "vaisseau"; } + static fixCompName(name) { + name = name.replace("Voie d'", ""); + name = name.replace("Voie de ", ""); + return name + } + static async parseStatBlock(statString) { //statString = statBlock03; @@ -152,7 +158,8 @@ export class RdDStatBlockParser { const competences = await SystemCompendiums.getCompetences(type); //console.log("Competences : ", competences); for (let comp of competences) { - let compMatch = XRegExp.exec(statString, XRegExp(comp.name + compParser[type], 'giu')); + let compNameToSearch = RdDStatBlockParser.fixCompName(comp.name) + let compMatch = XRegExp.exec(statString, XRegExp(compNameToSearch + compParser[type], 'giu')); if (compMatch) { comp = comp.toObject() comp.system.niveau = Number(compMatch.value); @@ -380,7 +387,7 @@ export class RdDStatBlockParser { case "personnage": // Check if ',né le' is present let namePersonnage = "Importé" - if (statString.match(/,\\s+né/)) { + if ( statString.includes(", né") ) { // Name is all string before first comma ',' namePersonnage = XRegExp.exec(statString, XRegExp("(?[\\p{Letter}\\s\\d]+),", 'giu')); } else {