Compare commits
1 Commits
3739519610
...
970008d3ae
Author | SHA1 | Date | |
---|---|---|---|
970008d3ae |
module/apps
packs_src
@ -17,20 +17,12 @@ const XREGEXP_COMP_CREATURE = WHITESPACES + "(?<carac>\\d+)"
|
|||||||
|
|
||||||
// Skill parser depending on the type of actor
|
// Skill parser depending on the type of actor
|
||||||
const compParser = {
|
const compParser = {
|
||||||
personnage: "(\\s+\\((?<special>[^\\)]+)\\))?(,\\s*\\p{Letter}+)*(\\s+(?<malus>avec armure))?" + WHITESPACES + NUMERIC_VALUE,
|
//personnage: "(\\D+)*" + WHITESPACES + NUMERIC_VALUE,
|
||||||
|
personnage: WHITESPACES + NUMERIC_VALUE,
|
||||||
creature: XREGEXP_COMP_CREATURE,
|
creature: XREGEXP_COMP_CREATURE,
|
||||||
entite: XREGEXP_COMP_CREATURE
|
entite: XREGEXP_COMP_CREATURE
|
||||||
}
|
}
|
||||||
|
|
||||||
const MANIEMENTS = {
|
|
||||||
'de lancer': (weapon) => { return { name: weapon.system.lancer, categorie: 'lancer' } },
|
|
||||||
'de jet': (weapon) => { return { name: weapon.system.lancer, categorie: 'lancer' } },
|
|
||||||
'à une main': (weapon) => { return { name: weapon.system.competence, categorie: 'melee' } },
|
|
||||||
'à deux main': (weapon) => { return { name: weapon.system.competence.replace("à 1 main", "à 2 main"), categorie: 'melee' } },
|
|
||||||
'mêlée': (weapon) => { return { name: weapon.system.competence, categorie: 'melee' } },
|
|
||||||
}
|
|
||||||
const XREGEXP_WEAPON_MANIEMENT = "(?<maniement>(" + Misc.join(Object.keys(MANIEMENTS), '|') + "))"
|
|
||||||
|
|
||||||
const XREGEXP_SORT_VOIE = "(?<voies>[OHNT](\\/[OHNT])*)"
|
const XREGEXP_SORT_VOIE = "(?<voies>[OHNT](\\/[OHNT])*)"
|
||||||
const XREGEXP_SORT_NAME = "(?<name>[^\\(]+)"
|
const XREGEXP_SORT_NAME = "(?<name>[^\\(]+)"
|
||||||
const XREGEXP_SORT_CASE = "\\((?<case>([A-Za-zÀ-ÖØ-öø-ÿ\\s\\-]+|[A-M]\\d{1,2})+)\\)";
|
const XREGEXP_SORT_CASE = "\\((?<case>([A-Za-zÀ-ÖØ-öø-ÿ\\s\\-]+|[A-M]\\d{1,2})+)\\)";
|
||||||
@ -142,9 +134,6 @@ export class RdDStatBlockParser {
|
|||||||
|
|
||||||
// Now start carac
|
// Now start carac
|
||||||
let actorData = foundry.utils.deepClone(game.model.Actor[type]);
|
let actorData = foundry.utils.deepClone(game.model.Actor[type]);
|
||||||
let items = [];
|
|
||||||
|
|
||||||
actorData.flags = { hautRevant: false, malusArmure: 0 }
|
|
||||||
for (let key in actorData.carac) {
|
for (let key in actorData.carac) {
|
||||||
let caracDef = actorData.carac[key];
|
let caracDef = actorData.carac[key];
|
||||||
// Parse the stat string for each caracteristic
|
// Parse the stat string for each caracteristic
|
||||||
@ -163,49 +152,17 @@ export class RdDStatBlockParser {
|
|||||||
RdDStatBlockParser.parseEntite(statString, actorData)
|
RdDStatBlockParser.parseEntite(statString, actorData)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if (type == "personnage") {
|
|
||||||
// Now process armors
|
|
||||||
await RdDStatBlockParser.parseArmors(statString, actorData, items);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
let items = [];
|
||||||
// Get skills from compendium
|
// Get skills from compendium
|
||||||
await RdDStatBlockParser.parseCompetences(type, statString, actorData, items);
|
|
||||||
|
|
||||||
|
|
||||||
if (type == "personnage") {
|
|
||||||
// Now process weapons
|
|
||||||
await RdDStatBlockParser.parseWeapons(statString, items);
|
|
||||||
|
|
||||||
await RdDStatBlockParser.parseHautReve(statString, actorData, items);
|
|
||||||
RdDStatBlockParser.parsePersonnage(statString, actorData);
|
|
||||||
}
|
|
||||||
|
|
||||||
const name = RdDStatBlockParser.extractName(type, statString);
|
|
||||||
|
|
||||||
actorData.flags = undefined
|
|
||||||
console.log(actorData);
|
|
||||||
|
|
||||||
let newActor = await RdDBaseActorReve.create({ name, type, system: actorData, items });
|
|
||||||
await newActor.remiseANeuf()
|
|
||||||
await RdDStatBlockParser.setValeursActuelles(newActor, statString)
|
|
||||||
await newActor?.sheet.render(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
static async parseCompetences(type, statString, actorData, items) {
|
|
||||||
const competences = await SystemCompendiums.getCompetences(type);
|
const competences = await SystemCompendiums.getCompetences(type);
|
||||||
//console.log("Competences : ", competences);
|
//console.log("Competences : ", competences);
|
||||||
for (let comp of competences) {
|
for (let comp of competences) {
|
||||||
let compNameToSearch = RdDStatBlockParser.fixCompName(comp.name);
|
let compNameToSearch = RdDStatBlockParser.fixCompName(comp.name)
|
||||||
let compMatch = XRegExp.exec(statString, XRegExp("\\s" + compNameToSearch + compParser[type], 'giu'));
|
let compMatch = XRegExp.exec(statString, XRegExp(compNameToSearch + compParser[type], 'giu'));
|
||||||
if (compMatch) {
|
if (compMatch) {
|
||||||
comp = comp.toObject()
|
comp = comp.toObject()
|
||||||
comp.system.niveau = Number(compMatch.value)
|
comp.system.niveau = Number(compMatch.value);
|
||||||
if (compMatch.malus) {
|
|
||||||
comp.system.niveau = Number(compMatch.value) - actorData.flags.malusArmure
|
|
||||||
}
|
|
||||||
if (comp.system.categorie == 'draconic' && comp.system.niveau > -11) {
|
|
||||||
actorData.flags.hautRevant = true
|
|
||||||
}
|
|
||||||
if (type == "creature" || type == "entite") {
|
if (type == "creature" || type == "entite") {
|
||||||
comp.system.carac_value = Number(compMatch.carac);
|
comp.system.carac_value = Number(compMatch.carac);
|
||||||
if (compMatch.dommages != undefined) {
|
if (compMatch.dommages != undefined) {
|
||||||
@ -213,71 +170,74 @@ export class RdDStatBlockParser {
|
|||||||
comp.system.iscombat = true;
|
comp.system.iscombat = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
items.push(comp);
|
items.push(comp)
|
||||||
}
|
}
|
||||||
else if (type == "personnage") {
|
else if (type == "personnage") {
|
||||||
comp = comp.toObject();
|
comp = comp.toObject()
|
||||||
items.push(comp);
|
items.push(comp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static async parseArmors(statString, actorData, items) {
|
// Now process weapons
|
||||||
const armors = await SystemCompendiums.getWorldOrCompendiumItems("armure", "equipement");
|
const weapons = await SystemCompendiums.getWorldOrCompendiumItems("arme", "equipement")
|
||||||
|
//console.log("Equipement : ", equipment);
|
||||||
|
// TODO: les noms d'armes peuvent avoir un suffixe (à une main, lancée) qui détermine la compétence correspondante
|
||||||
|
// TODO: une arme peut être spécifique ("fourche"), ajouter une compétence dans ces cas là?
|
||||||
|
for (let weapon of weapons) {
|
||||||
|
let weapMatch = XRegExp.exec(statString, XRegExp(weapon.name + "\\s+(?<value>\\+\\d+)", 'giu'));
|
||||||
|
if (weapMatch) {
|
||||||
|
weapon = weapon.toObject()
|
||||||
|
weapon.system.equipe = 'true'
|
||||||
|
items.push(weapon)
|
||||||
|
// now process the skill
|
||||||
|
if (weapon.system?.competence != "") {
|
||||||
|
let wComp = items.find(i => Grammar.equalsInsensitive(i.name, weapon.system.competence))
|
||||||
|
if (wComp) {
|
||||||
|
wComp.system.niveau = Number(weapMatch.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (weapon.system?.tir != "") {
|
||||||
|
let wComp = items.find(i => Grammar.equalsInsensitive(i.name, weapon.system.tir))
|
||||||
|
if (wComp) {
|
||||||
|
wComp.system.niveau = Number(weapMatch.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (weapon.system?.lancer != "") {
|
||||||
|
let wComp = items.find(i => Grammar.equalsInsensitive(i.name, weapon.system.lancer))
|
||||||
|
if (wComp) {
|
||||||
|
wComp.system.niveau = Number(weapMatch.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now process armors
|
||||||
|
const armors = await SystemCompendiums.getWorldOrCompendiumItems("armure", "equipement")
|
||||||
for (let armor of armors) {
|
for (let armor of armors) {
|
||||||
let matchArmor = XRegExp.exec(statString, XRegExp(armor.name, 'giu'));
|
let matchArmor = XRegExp.exec(statString, XRegExp(armor.name, 'giu'));
|
||||||
if (matchArmor) {
|
if (matchArmor) {
|
||||||
armor = armor.toObject()
|
armor = armor.toObject()
|
||||||
armor.system.equipe = true
|
armor.system.equipe = true
|
||||||
actorData.flags.malusArmure = armor.system.malus
|
items.push(armor);
|
||||||
items.push(armor)
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static async parseWeapons(statString, items) {
|
|
||||||
const weapons = await SystemCompendiums.getWorldOrCompendiumItems("arme", "equipement");
|
|
||||||
//console.log("Equipement : ", equipment);
|
|
||||||
// TODO: les noms d'armes peuvent avoir un suffixe (à une main, lancée) qui détermine la compétence correspondante
|
|
||||||
// TODO: une arme peut être spécifique ("fourche"), ajouter une compétence dans ces cas là?
|
|
||||||
for (let weapon of weapons) {
|
|
||||||
let nomArmeManiement = XRegExp.exec(weapon.name, XRegExp(".*" + XREGEXP_WEAPON_MANIEMENT));
|
|
||||||
if (nomArmeManiement) {
|
|
||||||
continue // ignore les objets 'Dague de jet" ou "dague mêlée"
|
|
||||||
}
|
|
||||||
let weapMatch = XRegExp.exec(statString, XRegExp(weapon.name
|
|
||||||
+ "(\\s*" + XREGEXP_WEAPON_MANIEMENT + ")?"
|
|
||||||
+ "\\s+(?<value>\\+\\d+)", 'giu'));
|
|
||||||
if (weapMatch) {
|
|
||||||
weapon = weapon.toObject();
|
|
||||||
weapon.system.equipe = 'true';
|
|
||||||
items.push(weapon);
|
|
||||||
|
|
||||||
const niveau = Number(weapMatch.value);
|
if (type == "personnage") {
|
||||||
// now process the skill
|
await RdDStatBlockParser.parseHautReve(statString, actorData, items);
|
||||||
if (weapMatch?.maniement) {
|
RdDStatBlockParser.parsePersonnage(statString, actorData);
|
||||||
RdDStatBlockParser.setNiveauCompetenceArme(items, MANIEMENTS[weapMatch.maniement](weapon), niveau)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
RdDStatBlockParser.setNiveauCompetenceArme(items, { name: weapon.system.competence, categorie: 'melee' }, niveau)
|
|
||||||
RdDStatBlockParser.setNiveauCompetenceArme(items, { name: weapon.system.tir, categorie: 'tir' }, niveau)
|
|
||||||
RdDStatBlockParser.setNiveauCompetenceArme(items, { name: weapon.system.lancer, categorie: 'lancer' }, niveau)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let name = RdDStatBlockParser.extractName(type, statString);
|
||||||
|
|
||||||
|
let newActor = await RdDBaseActorReve.create({ name, type: type, system: actorData, items });
|
||||||
|
await newActor.remiseANeuf()
|
||||||
|
await RdDStatBlockParser.setValActuelle(newActor, statString)
|
||||||
|
// DUmp....
|
||||||
|
console.log(actorData);
|
||||||
}
|
}
|
||||||
|
|
||||||
static setNiveauCompetenceArme(items, competence, niveau) {
|
static async setValActuelle(newActor, statString) {
|
||||||
if (competence != "") {
|
|
||||||
const item = items.find(i => i.system.categorie == competence.categorie && Grammar.equalsInsensitive(i.name, competence.name))
|
|
||||||
if (item) {
|
|
||||||
item.system.niveau = niveau
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static async setValeursActuelles(newActor, statString) {
|
|
||||||
const updates = {
|
const updates = {
|
||||||
}
|
}
|
||||||
const endurance = XRegExp.exec(statString, XRegExp("endurance\\s+(?<value>\\d+)\\s+(\\(actuelle\\s*:\\s+(?<actuelle>\\d+)\\))?", 'giu'));
|
const endurance = XRegExp.exec(statString, XRegExp("endurance\\s+(?<value>\\d+)\\s+(\\(actuelle\\s*:\\s+(?<actuelle>\\d+)\\))?", 'giu'));
|
||||||
@ -303,6 +263,7 @@ export class RdDStatBlockParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async parseHautReve(statString, actorData, items) {
|
static async parseHautReve(statString, actorData, items) {
|
||||||
|
let hautRevant = false;
|
||||||
// Attemp to detect spell
|
// Attemp to detect spell
|
||||||
let sorts = await SystemCompendiums.getWorldOrCompendiumItems("sort", "sorts-oniros");
|
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-hypnos"));
|
||||||
@ -314,7 +275,7 @@ export class RdDStatBlockParser {
|
|||||||
const sortName = Grammar.toLowerCaseNoAccent(matchSort.name).trim().replace("’", "'");
|
const sortName = Grammar.toLowerCaseNoAccent(matchSort.name).trim().replace("’", "'");
|
||||||
let sort = sorts.find(s => Grammar.toLowerCaseNoAccent(s.name) == sortName)
|
let sort = sorts.find(s => Grammar.toLowerCaseNoAccent(s.name) == sortName)
|
||||||
if (sort) {
|
if (sort) {
|
||||||
actorData.flags.hautRevant = true
|
hautRevant = true;
|
||||||
sort = sort.toObject();
|
sort = sort.toObject();
|
||||||
if (matchSort.bonus && matchSort.bonuscase) {
|
if (matchSort.bonus && matchSort.bonuscase) {
|
||||||
sort.system.bonuscase = `${matchSort.bonuscase}:${matchSort.bonus}`;
|
sort.system.bonuscase = `${matchSort.bonuscase}:${matchSort.bonus}`;
|
||||||
@ -326,7 +287,7 @@ export class RdDStatBlockParser {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (actorData.flags.hautRevant) {
|
if (hautRevant) {
|
||||||
const donHR = await RdDItemTete.teteDonDeHautReve();
|
const donHR = await RdDItemTete.teteDonDeHautReve();
|
||||||
if (donHR) {
|
if (donHR) {
|
||||||
items.push(donHR.toObject());
|
items.push(donHR.toObject());
|
||||||
@ -361,7 +322,7 @@ export class RdDStatBlockParser {
|
|||||||
actorData.taille = taille.value;
|
actorData.taille = taille.value;
|
||||||
}
|
}
|
||||||
// Get weight
|
// Get weight
|
||||||
const poids = XRegExp.exec(statString, XRegExp("(?<value>\\d+ kg)", 'giu'));
|
const poids = XRegExp.exec(statString, XRegExp("(?<value>\\d+) kg", 'giu'));
|
||||||
if (poids?.value) {
|
if (poids?.value) {
|
||||||
actorData.poids = poids.value;
|
actorData.poids = poids.value;
|
||||||
}
|
}
|
||||||
@ -426,7 +387,7 @@ export class RdDStatBlockParser {
|
|||||||
case "personnage":
|
case "personnage":
|
||||||
// Check if ',né le' is present
|
// Check if ',né le' is present
|
||||||
let namePersonnage = "Importé"
|
let namePersonnage = "Importé"
|
||||||
if (statString.includes(", né")) {
|
if ( statString.includes(", né") ) {
|
||||||
// Name is all string before first comma ','
|
// Name is all string before first comma ','
|
||||||
namePersonnage = XRegExp.exec(statString, XRegExp("(?<value>[\\p{Letter}\\s\\d]+),", 'giu'));
|
namePersonnage = XRegExp.exec(statString, XRegExp("(?<value>[\\p{Letter}\\s\\d]+),", 'giu'));
|
||||||
} else {
|
} else {
|
||||||
|
@ -1400,7 +1400,7 @@ items:
|
|||||||
coreVersion: '12.331'
|
coreVersion: '12.331'
|
||||||
_key: '!actors.items!1Nng9d8r6lrPHCaJ.MxFDPQmm1900bWin'
|
_key: '!actors.items!1Nng9d8r6lrPHCaJ.MxFDPQmm1900bWin'
|
||||||
- _id: bNUVmIoLEROEIOIm
|
- _id: bNUVmIoLEROEIOIm
|
||||||
name: Cuir / Métal
|
name: Cuir / Metal
|
||||||
type: armure
|
type: armure
|
||||||
img: systems/foundryvtt-reve-de-dragon/icons/armes_armures/cuir_metal.webp
|
img: systems/foundryvtt-reve-de-dragon/icons/armes_armures/cuir_metal.webp
|
||||||
effects: []
|
effects: []
|
||||||
|
@ -2297,7 +2297,7 @@ items:
|
|||||||
coreVersion: '12.331'
|
coreVersion: '12.331'
|
||||||
_key: '!actors.items!JQCwAOK64Yijwtch.9mOVjXVNdvnf7isr'
|
_key: '!actors.items!JQCwAOK64Yijwtch.9mOVjXVNdvnf7isr'
|
||||||
- _id: ISONFNOaWkW2TaE8
|
- _id: ISONFNOaWkW2TaE8
|
||||||
name: Cuir / Métal
|
name: Cuir / Metal
|
||||||
type: armure
|
type: armure
|
||||||
sort: 8400000
|
sort: 8400000
|
||||||
img: systems/foundryvtt-reve-de-dragon/icons/armes_armures/cuir_metal.webp
|
img: systems/foundryvtt-reve-de-dragon/icons/armes_armures/cuir_metal.webp
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
_id: fDwsTMuug0Z5BdaA
|
_id: fDwsTMuug0Z5BdaA
|
||||||
name: Cuir / Métal
|
name: Cuir / Metal
|
||||||
type: armure
|
type: armure
|
||||||
img: systems/foundryvtt-reve-de-dragon/icons/armes_armures/cuir_metal.webp
|
img: systems/foundryvtt-reve-de-dragon/icons/armes_armures/cuir_metal.webp
|
||||||
effects: []
|
effects: []
|
||||||
|
@ -814,7 +814,7 @@ pages:
|
|||||||
Epais}</td><td style="width:25%;height:10px">2</td><td
|
Epais}</td><td style="width:25%;height:10px">2</td><td
|
||||||
style="width:15%;height:10px">10s</td></tr><tr style="height:10px"><td
|
style="width:15%;height:10px">10s</td></tr><tr style="height:10px"><td
|
||||||
style="width:60%;height:10px">@Compendium[foundryvtt-reve-de-dragon.equipement.fDwsTMuug0Z5BdaA]{Cuir
|
style="width:60%;height:10px">@Compendium[foundryvtt-reve-de-dragon.equipement.fDwsTMuug0Z5BdaA]{Cuir
|
||||||
/ Métal}</td><td style="width:25%;height:10px">4</td><td
|
/ Metal}</td><td style="width:25%;height:10px">4</td><td
|
||||||
style="width:15%;height:10px">20s</td></tr><tr style="height:10px"><td
|
style="width:15%;height:10px">20s</td></tr><tr style="height:10px"><td
|
||||||
style="width:60%;height:10px">@Compendium[foundryvtt-reve-de-dragon.equipement.KQZIK8ltQ3sQiDGe]{Mailles
|
style="width:60%;height:10px">@Compendium[foundryvtt-reve-de-dragon.equipement.KQZIK8ltQ3sQiDGe]{Mailles
|
||||||
de Fer}</td><td style="width:25%;height:10px">6</td><td
|
de Fer}</td><td style="width:25%;height:10px">6</td><td
|
||||||
|
Loading…
x
Reference in New Issue
Block a user