From bbfac286a6c76500d97683b2da780f1427376663 Mon Sep 17 00:00:00 2001 From: LeRatierBretonnien Date: Sun, 1 Dec 2024 14:22:40 +0100 Subject: [PATCH] Amelioration parser : heures, cheveux, yeux et sorts --- module/apps/rdd-import-stats.js | 50 ++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/module/apps/rdd-import-stats.js b/module/apps/rdd-import-stats.js index f199bbaa..a6c6494a 100644 --- a/module/apps/rdd-import-stats.js +++ b/module/apps/rdd-import-stats.js @@ -265,6 +265,15 @@ export class RdDStatBlockParser { } + static getHeureKey(heure) { + for (let h of game.system.rdd.config.heuresRdD) { + if (h.label.toLowerCase() == heure.toLowerCase()) { + return h.value; + } + } + return "vaisseau"; + } + static async parseStatBlock(statString, type = "npc") { //statString = statBlock03; @@ -394,14 +403,36 @@ export class RdDStatBlockParser { } } + // Attemp to detect spell + let hautRevant = false + let sorts = await SystemCompendiums.getWorldOrCompendiumItems("sort", "sorts-oniros") + sorts = sorts.concat(await SystemCompendiums.getWorldOrCompendiumItems("sort", "sorts-hypnos")) + sorts = sorts.concat(await SystemCompendiums.getWorldOrCompendiumItems("sort", "sorts-narcos")) + sorts = sorts.concat(await SystemCompendiums.getWorldOrCompendiumItems("sort", "sorts-thanatos")) + XRegExp.forEach(statString, XRegExp("[OHNT]\\s+(?[A-Za-zÀ-ÖØ-öø-ÿ\\s\\-]+)\\s+\\((?[A-Za-zÀ-ÖØ-öø-ÿ\\s\\-]+)\\)\\s+R(?[\\-\\d]+)\\s+r(?\\d+)", 'giu'), + function (match, i) { + let sortCompendium = sorts.find(s => Grammar.equalsInsensitive(s.name, match.name)) + if (sortCompendium) { + hautRevant = true + let sort = sortCompendium.toObject(); + items.push(sort); + } + }); + if (hautRevant) { + let tetes = await SystemCompendiums.getWorldOrCompendiumItems("tete", "tetes-de-dragon-pour-tous-personnages") + let donHR = tetes.find(t => Grammar.equalsInsensitive(t.name, "Don de Haut-Rêve")) + if (donHR) { + items.push(donHR.toObject()); + } + } + let feminin = XRegExp.exec(statString, XRegExp("né(?e?) à", 'giu')); actorData.sexe = (feminin?.value == 'e') ? 'féminin' : 'masculin' // Get hour name : heure du XXXXX - let heure = XRegExp.exec(statString, XRegExp("heure (du|de la|des|de l\')\\s*(?[\\p{Letter}\s]+),", 'giu')); - if (heure?.value) { - actorData.heure = heure.value; - } + let heure = XRegExp.exec(statString, XRegExp("heure (du|de la|des|de l\')\\s*(?[A-Za-zÀ-ÖØ-öø-ÿ\\s]+),", 'giu')); + actorData.heure = this.getHeureKey(heure?.value || "Vaisseau"); + // Get age let age = XRegExp.exec(statString, XRegExp("(?\\d+) ans", 'giu')); if (age?.value) { @@ -417,6 +448,17 @@ export class RdDStatBlockParser { if (poids?.value) { actorData.poids = poids.value; } + // Get cheveux + let cheveux = XRegExp.exec(statString, XRegExp("kg,\\s+(?[A-Za-zÀ-ÖØ-öø-ÿ\\s\\-]+),\\s+yeux", 'giu')); + if (cheveux?.value) { + actorData.cheveux = cheveux.value; + } + // Get yeux + let yeux = XRegExp.exec(statString, XRegExp("yeux\\s+(?[A-Za-zÀ-ÖØ-öø-ÿ\\s\\-]+), Beau", 'giu')); + if (yeux?.value) { + actorData.yeux = yeux.value; + } + // Get beauty let beaute = XRegExp.exec(statString, XRegExp("beauté\\s+(?\\d+)", 'giu')); if (beaute?.value) {