Initialisation valeurs actuelles
Prise encompte de l'endutrance et vie actuelles
This commit is contained in:
parent
f13677106e
commit
d9af32b168
@ -224,10 +224,38 @@ export class RdDStatBlockParser {
|
||||
|
||||
let newActor = await RdDBaseActorReve.create({ name, type: type, system: actorData, items });
|
||||
await newActor.remiseANeuf()
|
||||
await RdDStatBlockParser.setValActuelle(newActor, statString)
|
||||
// DUmp....
|
||||
console.log(actorData);
|
||||
}
|
||||
|
||||
static async setValActuelle(newActor, statString) {
|
||||
const updates = {
|
||||
}
|
||||
const endurance = XRegExp.exec(statString, XRegExp("endurance\\s+(?<value>\\d+)\\s+(\\(actuelle\\s*:\\s+(?<actuelle>\\d+)\\))?", 'giu'));
|
||||
if (endurance?.value) {
|
||||
if (newActor.getEnduranceMax() != endurance.value) {
|
||||
const message = `Vérifier le calcul de l'endurance, calcul: ${newActor.getEnduranceMax()} / import: ${endurance.value}`;
|
||||
RdDStatBlockParser.warning(message);
|
||||
}
|
||||
}
|
||||
if (endurance?.actuelle) {
|
||||
updates['system.sante.endurance.value'] = Number(endurance?.actuelle)
|
||||
}
|
||||
|
||||
const vie = XRegExp.exec(statString, XRegExp("vie\\s+(?<value>\\d+)\\s+(\\(actuelle\\s*:\\s+(?<actuelle>\\d+)\\))?", 'giu'));
|
||||
if (vie?.value) {
|
||||
if (newActor.getVieMax() != vie.value) {
|
||||
const message = `Vérifier le calcul de la vie, calcul: ${newActor.getVieMax()} / import: ${vie.value}`;
|
||||
RdDStatBlockParser.warning(message);
|
||||
}
|
||||
}
|
||||
if (vie?.actuelle) {
|
||||
updates['system.sante.vie.value'] = Number(vie?.actuelle)
|
||||
}
|
||||
await newActor.update(updates)
|
||||
}
|
||||
|
||||
static async parseHautReve(statString, actorData, items) {
|
||||
let hautRevant = false;
|
||||
// Attemp to detect spell
|
||||
@ -249,8 +277,7 @@ export class RdDStatBlockParser {
|
||||
items.push(sort);
|
||||
}
|
||||
else {
|
||||
ui.notifications.warn(`Impossible de trouver le sort ${matchSort.name} / ${sortName}`)
|
||||
console.warn(`Impossible de trouver le sort ${matchSort.name} / ${sortName}`)
|
||||
RdDStatBlockParser.warning(`Impossible de trouver le sort ${matchSort.name} / ${sortName}`)
|
||||
}
|
||||
});
|
||||
|
||||
@ -312,24 +339,10 @@ export class RdDStatBlockParser {
|
||||
}
|
||||
|
||||
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;
|
||||
@ -337,11 +350,6 @@ export class RdDStatBlockParser {
|
||||
}
|
||||
|
||||
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'));
|
||||
@ -381,6 +389,11 @@ export class RdDStatBlockParser {
|
||||
return Misc.upperFirst(name?.value || "Importé");
|
||||
}
|
||||
|
||||
static warning(message) {
|
||||
ui.notifications.warn(message);
|
||||
console.warn(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/************************************************************************************/
|
||||
|
Loading…
Reference in New Issue
Block a user