diff --git a/module/apps/rdd-import-stats.js b/module/apps/rdd-import-stats.js index cd109e4d..bb0b9509 100644 --- a/module/apps/rdd-import-stats.js +++ b/module/apps/rdd-import-stats.js @@ -491,21 +491,27 @@ export class RdDStatBlockParser { } static extractName(actorType, statString) { - switch (actorType) { - case "personnage": - // Check if ',né le' is present - let namePersonnage = "Importé" - if (statString.includes(", né")) { - // Name is all string before first comma ',' - namePersonnage = XRegExp.exec(statString, XRegExp("(?[\\p{Letter}\\'\\-\\s\\d]+),", 'giu')); - } else { - namePersonnage = XRegExp.exec(statString, XRegExp("(?[\\p{Letter}\\'\\-\\s\\d]+)\\s+TAILLE", 'giu')); - } - if (namePersonnage?.value) { - return Misc.upperFirst(namePersonnage?.value.toLowerCase()); - } + if (actorType == "personnage") { + // Check if ',né le' is present + let namePersonnage = "Importé" + if (statString.includes(", né")) { + // Name is all string before first comma ',' + namePersonnage = XRegExp.exec(statString, XRegExp("(?[\\p{Letter}\\'\\-\\s\\d]+),", 'giu')); + } else { + namePersonnage = XRegExp.exec(statString, XRegExp("(?[\\p{Letter}\\'\\-\\s\\d]+)\\s+TAILLE", 'giu')); + } + if (namePersonnage?.value) { + return Misc.upperFirst(namePersonnage?.value.toLowerCase()); + } } + const name = XRegExp.exec(statString, XRegExp("(?.+)\\s+taille", 'giu')); + if (actorType == "entite") { + if (!(name?.value)) { + const nameEntiteReve = XRegExp.exec(statString, XRegExp("(?.+)\\s+rêve", 'giu')); + return Misc.upperFirst(nameEntiteReve?.value || "Importé"); + } + } return Misc.upperFirst(name?.value || "Importé"); }