diff --git a/module/apps/rdd-import-stats.js b/module/apps/rdd-import-stats.js index bf6c23bc..db3180c1 100644 --- a/module/apps/rdd-import-stats.js +++ b/module/apps/rdd-import-stats.js @@ -216,22 +216,21 @@ export class RdDStatBlockParser { if (type == "personnage") { - // Attemp to detect spell await RdDStatBlockParser.parseHautReve(statString, items); - RdDStatBlockParser.parsePersonnage(statString, actorData); } let name = RdDStatBlockParser.extractName(type, statString); - let newActor = RdDBaseActorReve.create({ name, type: type, system: actorData, items }); - + let newActor = await RdDBaseActorReve.create({ name, type: type, system: actorData, items }); + await newActor.remiseANeuf() // DUmp.... console.log(actorData); } static async parseHautReve(statString, items) { let hautRevant = false; + // Attemp to detect spell 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")); @@ -255,45 +254,53 @@ export class RdDStatBlockParser { if (donHR) { items.push(donHR.toObject()); } + + const demiReve = XRegExp.exec(statString, XRegExp("Demi-rêve\\s+(?[A-M]\\d{1,2})", 'giu')) + actorData.reve.tmrpos.coord = demiReve?.value ?? 'A1' } } - + static parsePersonnage(statString, actorData) { - let feminin = XRegExp.exec(statString, XRegExp("né(?e?) à", 'giu')); + actorData.reve.seuil.value = actorData.carac.reve.value + + const reveActuel = XRegExp.exec(statString, XRegExp("Rêve actuel\\s+(?\\d+)", 'giu')) + actorData.reve.reve.value = reveActuel?.value ? Number(reveActuel.value) : actorData.reve.seuil.value + + const 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*(?[A-Za-zÀ-ÖØ-öø-ÿ\\s]+),", 'giu')); + const 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')); + const age = XRegExp.exec(statString, XRegExp("(?\\d+) ans", 'giu')); if (age?.value) { actorData.age = Number(age.value); } // Get height - let taille = XRegExp.exec(statString, XRegExp("(?\\d+m\\d+)", 'giu')); + const taille = XRegExp.exec(statString, XRegExp("(?\\d+m\\d+)", 'giu')); if (taille?.value) { actorData.taille = taille.value; } // Get weight - let poids = XRegExp.exec(statString, XRegExp("(?\\d+) kg", 'giu')); + const poids = XRegExp.exec(statString, XRegExp("(?\\d+) kg", 'giu')); if (poids?.value) { actorData.poids = poids.value; } // Get cheveux - let cheveux = XRegExp.exec(statString, XRegExp("kg,\\s+(?[A-Za-zÀ-ÖØ-öø-ÿ\\s\\-]+),\\s+yeux", 'giu')); + const 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')); + const 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')); + const beaute = XRegExp.exec(statString, XRegExp("beauté\\s+(?\\d+)", 'giu')); if (beaute?.value) { actorData.beaute = Number(beaute.value); }