Import entités de cauchemar
This commit is contained in:
parent
bbfac286a6
commit
cbbd8ed4ba
@ -4,6 +4,7 @@ import { SystemCompendiums } from "../settings/system-compendiums.js";
|
|||||||
import { RdDBaseActorReve } from "../actor/base-actor-reve.js";
|
import { RdDBaseActorReve } from "../actor/base-actor-reve.js";
|
||||||
import { Grammar } from "../grammar.js";
|
import { Grammar } from "../grammar.js";
|
||||||
import { Misc } from "../misc.js";
|
import { Misc } from "../misc.js";
|
||||||
|
import { ENTITE_INCARNE, ENTITE_NONINCARNE } from "../constants.js";
|
||||||
|
|
||||||
/************************************************************************************/
|
/************************************************************************************/
|
||||||
// Some internal test strings
|
// Some internal test strings
|
||||||
@ -291,17 +292,13 @@ export class RdDStatBlockParser {
|
|||||||
// Remove all leading and trailing spaces
|
// Remove all leading and trailing spaces
|
||||||
statString = statString.trim();
|
statString = statString.trim();
|
||||||
|
|
||||||
let actorType = "personnage";
|
|
||||||
// TODO: check for entite
|
// TODO: check for entite
|
||||||
let perception = XRegExp.exec(statString, XRegExp("perception\\s+(?<value>\\d+)", 'giu'))
|
let actorType = RdDStatBlockParser.parseActorType(statString);
|
||||||
if (perception?.value) {
|
|
||||||
actorType = "creature";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now start carac
|
// Now start carac
|
||||||
let actorData = foundry.utils.deepClone(game.model.Actor[actorType]);
|
let actorData = foundry.utils.deepClone(game.model.Actor[actorType]);
|
||||||
for (let key in game.model.Actor.personnage.carac) {
|
for (let key in actorData.carac) {
|
||||||
let caracDef = game.model.Actor.personnage.carac[key];
|
let caracDef = actorData.carac[key];
|
||||||
// Parse the stat string for each caracteristic
|
// Parse the stat string for each caracteristic
|
||||||
let carac = XRegExp.exec(statString, XRegExp(caracDef.label + "\\s+(?<value>\\d+)", 'giu'));
|
let carac = XRegExp.exec(statString, XRegExp(caracDef.label + "\\s+(?<value>\\d+)", 'giu'));
|
||||||
if (carac?.value) {
|
if (carac?.value) {
|
||||||
@ -310,29 +307,13 @@ export class RdDStatBlockParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If creature we need to setup additionnal fields
|
// If creature we need to setup additionnal fields
|
||||||
if (actorType == "creature") {
|
switch (actorType) {
|
||||||
let plusDom = XRegExp.exec(statString, XRegExp("\\+dom\\s+(?<value>\\+\\d+)", 'giu'));
|
case "creature":
|
||||||
if (plusDom?.values) {
|
RdDStatBlockParser.parseCreature(statString, actorData)
|
||||||
actorData.attributs.plusdom.value = Number(plusDom.value);
|
break
|
||||||
}
|
case "entite":
|
||||||
let protection = XRegExp.exec(statString, XRegExp("protection\\s+(?<value>\\d+)", 'giu'));
|
RdDStatBlockParser.parseEntite(statString, actorData)
|
||||||
if (protection?.value) {
|
break
|
||||||
actorData.attributs.protection.value = Number(protection.value);
|
|
||||||
}
|
|
||||||
let endurance = XRegExp.exec(statString, XRegExp("endurance\\s+(?<value>\\d+)", 'giu'));
|
|
||||||
if (endurance?.value) {
|
|
||||||
actorData.sante.endurance.value = Number(endurance.value);
|
|
||||||
actorData.sante.endurance.max = Number(endurance.value);
|
|
||||||
}
|
|
||||||
let vie = XRegExp.exec(statString, XRegExp("vie\\s+(?<value>\\d+)", 'giu'));
|
|
||||||
if (vie.value) {
|
|
||||||
actorData.sante.vie.value = Number(vie.value);
|
|
||||||
actorData.sante.vie.max = Number(vie.value);
|
|
||||||
}
|
|
||||||
let vitesse = XRegExp.exec(statString, XRegExp("vitesse\\s+(?<value>[\\d\\/]+)", 'giu'));
|
|
||||||
if (vitesse?.value) {
|
|
||||||
actorData.attributs.vitesse.value = vitesse.value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let items = [];
|
let items = [];
|
||||||
@ -418,10 +399,10 @@ export class RdDStatBlockParser {
|
|||||||
items.push(sort);
|
items.push(sort);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (hautRevant) {
|
if (hautRevant) {
|
||||||
let tetes = await SystemCompendiums.getWorldOrCompendiumItems("tete", "tetes-de-dragon-pour-tous-personnages")
|
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"))
|
let donHR = tetes.find(t => Grammar.equalsInsensitive(t.name, "Don de Haut-Rêve"))
|
||||||
if (donHR) {
|
if (donHR) {
|
||||||
items.push(donHR.toObject());
|
items.push(donHR.toObject());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -474,6 +455,63 @@ export class RdDStatBlockParser {
|
|||||||
console.log(actorData);
|
console.log(actorData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static parseCreature(statString, actorData) {
|
||||||
|
let plusDom = XRegExp.exec(statString, XRegExp("\\+dom\\s+(?<value>\\+\\d+)", 'giu'));
|
||||||
|
if (plusDom?.values) {
|
||||||
|
actorData.attributs.plusdom.value = Number(plusDom.value);
|
||||||
|
}
|
||||||
|
let protection = XRegExp.exec(statString, XRegExp("protection\\s+(?<value>\\d+)", 'giu'));
|
||||||
|
if (protection?.value) {
|
||||||
|
actorData.attributs.protection.value = Number(protection.value);
|
||||||
|
}
|
||||||
|
let endurance = XRegExp.exec(statString, XRegExp("endurance\\s+(?<value>\\d+)", 'giu'));
|
||||||
|
if (endurance?.value) {
|
||||||
|
actorData.sante.endurance.value = Number(endurance.value);
|
||||||
|
actorData.sante.endurance.max = Number(endurance.value);
|
||||||
|
}
|
||||||
|
let vie = XRegExp.exec(statString, XRegExp("vie\\s+(?<value>\\d+)", 'giu'));
|
||||||
|
if (vie.value) {
|
||||||
|
actorData.sante.vie.value = Number(vie.value);
|
||||||
|
actorData.sante.vie.max = Number(vie.value);
|
||||||
|
}
|
||||||
|
let vitesse = XRegExp.exec(statString, XRegExp("vitesse\\s+(?<value>[\\d\\/]+)", 'giu'));
|
||||||
|
if (vitesse?.value) {
|
||||||
|
actorData.attributs.vitesse.value = vitesse.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static parseEntite(statString, actorData) {
|
||||||
|
let plusDom = XRegExp.exec(statString, XRegExp("\\+dom\\s+(?<value>\\+\\d+)", 'giu'));
|
||||||
|
if (plusDom?.values) {
|
||||||
|
actorData.attributs.plusdom.value = Number(plusDom.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
actorData.definition.categorieentite = 'cauchemar'
|
||||||
|
actorData.definition.typeentite = ENTITE_NONINCARNE
|
||||||
|
let endurance = XRegExp.exec(statString, XRegExp("endurance\\s+(?<value>\\d+)", 'giu'));
|
||||||
|
if (endurance?.value) {
|
||||||
|
actorData.sante.endurance.value = Number(endurance.value);
|
||||||
|
actorData.sante.endurance.max = Number(endurance.value);
|
||||||
|
actorData.definition.typeentite = ENTITE_INCARNE
|
||||||
|
}
|
||||||
|
let vitesse = XRegExp.exec(statString, XRegExp("vitesse\\s+(?<value>[\\d\\/]+)", 'giu'));
|
||||||
|
if (vitesse?.value) {
|
||||||
|
actorData.attributs.vitesse.value = vitesse.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static parseActorType(statString) {
|
||||||
|
let niveau = XRegExp.exec(statString, XRegExp("Niveau\\s+(?<value>[\\+\\-]?\\d+)", 'giu'))
|
||||||
|
let perception = XRegExp.exec(statString, XRegExp("perception\\s+(?<value>\\d+)", 'giu'))
|
||||||
|
if (perception?.value) {
|
||||||
|
return "creature"
|
||||||
|
}
|
||||||
|
if (niveau?.value) {
|
||||||
|
return "entite"
|
||||||
|
}
|
||||||
|
return "personnage"
|
||||||
|
}
|
||||||
|
|
||||||
static extractName(actorType, statString) {
|
static extractName(actorType, statString) {
|
||||||
switch (actorType) {
|
switch (actorType) {
|
||||||
case "personnage": return RdDStatBlockParser.extractNamePersonnage(statString);
|
case "personnage": return RdDStatBlockParser.extractNamePersonnage(statString);
|
||||||
|
Loading…
Reference in New Issue
Block a user