Import compétences avec spécialisations
ie: Musique (Harpe) +6
This commit is contained in:
parent
a896fdb166
commit
c6feac41c6
@ -144,7 +144,7 @@ export class RdDStatBlockParser {
|
||||
let actorData = foundry.utils.deepClone(game.model.Actor[type]);
|
||||
let items = [];
|
||||
|
||||
actorData.flags = { hautRevant: false, malusArmure: 0 }
|
||||
actorData.flags = { hautRevant: false, malusArmure: 0, type }
|
||||
for (let key in actorData.carac) {
|
||||
let caracDef = actorData.carac[key];
|
||||
// Parse the stat string for each caracteristic
|
||||
@ -169,7 +169,7 @@ export class RdDStatBlockParser {
|
||||
}
|
||||
|
||||
// Get skills from compendium
|
||||
await RdDStatBlockParser.parseCompetences(type, statString, actorData, items);
|
||||
await RdDStatBlockParser.parseCompetences(statString, actorData, items);
|
||||
|
||||
|
||||
if (type == "personnage") {
|
||||
@ -191,35 +191,48 @@ export class RdDStatBlockParser {
|
||||
await newActor?.sheet.render(true)
|
||||
}
|
||||
|
||||
static async parseCompetences(type, statString, actorData, items) {
|
||||
const competences = await SystemCompendiums.getCompetences(type);
|
||||
static async parseCompetences(statString, actorData, items) {
|
||||
const competences = await SystemCompendiums.getCompetences(actorData.flags.type);
|
||||
//console.log("Competences : ", competences);
|
||||
for (let comp of competences) {
|
||||
let compNameToSearch = RdDStatBlockParser.fixCompName(comp.name);
|
||||
let compMatch = XRegExp.exec(statString, XRegExp("\\s" + compNameToSearch + compParser[type], 'giu'));
|
||||
if (compMatch) {
|
||||
comp = comp.toObject()
|
||||
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") {
|
||||
comp.system.carac_value = Number(compMatch.carac);
|
||||
if (compMatch.dommages != undefined) {
|
||||
comp.system.dommages = Number(compMatch.dommages);
|
||||
comp.system.iscombat = true;
|
||||
for (let competence of competences) {
|
||||
let pushed = actorData.flags.type != "personnage"
|
||||
let compNameToSearch = RdDStatBlockParser.fixCompName(competence.name)
|
||||
XRegExp.forEach(statString, XRegExp("\\s" + compNameToSearch + compParser[actorData.flags.type], 'giu'),
|
||||
function (compMatch, i) {
|
||||
items.push(RdDStatBlockParser.prepareCompetence(actorData, competence, compMatch))
|
||||
if (!compMatch.special) {
|
||||
pushed = true
|
||||
}
|
||||
}
|
||||
items.push(comp);
|
||||
})
|
||||
if (!pushed) {
|
||||
// ajout niveau de base
|
||||
items.push(competence.toObject())
|
||||
}
|
||||
else if (type == "personnage") {
|
||||
comp = comp.toObject();
|
||||
items.push(comp);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static prepareCompetence(actorData, competence, compMatch) {
|
||||
const comp = competence.toObject();
|
||||
if (compMatch.special) {
|
||||
comp._id = undefined
|
||||
comp.name = `${comp.name} (${compMatch.special})`
|
||||
}
|
||||
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 (["creature", "entite"].includes(actorData.flags.type)) {
|
||||
comp.system.carac_value = Number(compMatch.carac);
|
||||
if (compMatch.dommages != undefined) {
|
||||
comp.system.dommages = Number(compMatch.dommages)
|
||||
comp.system.iscombat = true
|
||||
}
|
||||
}
|
||||
return comp
|
||||
}
|
||||
|
||||
static async parseArmors(statString, actorData, items) {
|
||||
|
Loading…
Reference in New Issue
Block a user