Fix character import
This commit is contained in:
@ -1,18 +1,8 @@
|
||||
/************************************************************************************/
|
||||
// Some internal test strings
|
||||
let strfr = `LA TERREUR DE LA TEUFEL, TROLL DE RIVIÈRE RUSÉ
|
||||
M
|
||||
CC CT
|
||||
F
|
||||
E
|
||||
I
|
||||
Ag Dex Int FM Soc B
|
||||
4
|
||||
40 15
|
||||
55
|
||||
45
|
||||
20
|
||||
15 15 30 20 5 38
|
||||
M CC CT F E I Ag Dex Int FM Soc B
|
||||
4 40 15 55 45 20 15 15 30 20 5 38
|
||||
Traits : Amphibie, Arme +9, Armure (2), Dur à Cuire, Insensible
|
||||
à la douleur, Morsure +8, Régénération, Taille (Grande), Vision
|
||||
Nocturne, Vomissement`
|
||||
@ -52,7 +42,7 @@ import "./xregexp-all.js";
|
||||
const us_carac = 'm\\s+ws\\s+bs\\s+s\\s+t\\s+i\\s+agi?\\s+dex\\s+int\\s+\\wp\\s+fel\\s+w';
|
||||
const fr_carac = 'm\\s+cc\\s+ct\\s+f\\s+e\\s+i\\s+agi?\\s+dex\\s+int\\s+fm\\s+soc\\s+b';
|
||||
const carac_val = '(?<m>[0-9\\-]+)\\s+(?<ws>[0-9\\-]+)\\s+(?<bs>[0-9\\-]+)\\s+(?<s>[0-9\\-]+)\\s+(?<t>[0-9\\-]+)\\s+(?<i>[0-9\\-]+)\\s+(?<ag>[0-9\\-]+)\\s+(?<dex>[0-9\\-]+)\\s+(?<int>[0-9\\-]+)\\s+(?<wp>[0-9\\-]+)\\s+(?<fel>[0-9\\-]+)\\s+(?<w>[0-9\\-\*]+)';
|
||||
const name_val = '(?<name>[a-zA-Z\\s\\-,\']*)[\\s\\r\\na-zA-Z]*(?<tiers>.*|[\\(\\)a-z0-9]+)';
|
||||
const name_val = '(?<name>[a-zA-Zéèêâôïäüù\\s\\-,\']*)[\\s\\r\\na-zA-Zéèêâôïäüù]*(?<tiers>.*|[\\(\\)a-z0-9]+)';
|
||||
let sectionDataFR = [
|
||||
{ name: "trait", toFind: "Traits\\s*:", secondParse: '(?<name>[a-zöàéè\\s]*)[\\s\\+]*(?<value>.*|[\\+0-9]+)', index: -1 },
|
||||
{ name: "skill", toFind: "Compétences\\s*:", secondParse: '(?<name>[a-zàéè\\s\\(\\)]*)[\\s\\+]*(?<value>.*|[0-9]+)', index: -1 },
|
||||
@ -246,7 +236,7 @@ function __patchName(name) {
|
||||
|
||||
/************************************************************************************/
|
||||
export default async function statParserFR(statString, type = "npc") {
|
||||
let model = foundry.utils.duplicate(game.system.model.Actor[type]);
|
||||
let model = foundry.utils.duplicate(game.model.Actor[type]);
|
||||
|
||||
// Patch wront/strange carac value before processing
|
||||
statString = statString.replace(/ –/g, " 0")
|
||||
@ -308,14 +298,14 @@ export default async function statParserFR(statString, type = "npc") {
|
||||
let resCarac = XRegExp.exec(statString, reg2) // resr contains all carac found
|
||||
|
||||
// Setup carac
|
||||
//console.log("CARAC", resCarac)
|
||||
console.log("CARAC", resCarac)
|
||||
if (resCarac["Agi"]) resCarac["Ag"] = resCarac["Agi"] // Auto patch
|
||||
model.details.move.value = Number(resCarac["m"])
|
||||
for (let key in model.characteristics) {
|
||||
if (resCarac[key] === '-') resCarac[key] = 0
|
||||
model.characteristics[key].initial = Number(resCarac[key])
|
||||
}
|
||||
//console.log("CARAC", model.characteristics);
|
||||
console.log("CARAC", model.characteristics);
|
||||
|
||||
// Search position of skills/talents/...
|
||||
for (let def of sectionData) {
|
||||
@ -424,11 +414,11 @@ export default async function statParserFR(statString, type = "npc") {
|
||||
}
|
||||
if (!itemFound && name) {
|
||||
if (name.toLowerCase().includes("armor") || name.toLowerCase().includes("armure") || name.toLowerCase().includes("armour")) {
|
||||
itemFound = new ItemWfrp4e({ img: "systems/wfrp4e/icons/blank.png", name: name, type: "armour", system: game.system.model.Item.armor })
|
||||
itemFound = new ItemWfrp4e({ img: "systems/wfrp4e/icons/blank.png", name: name, type: "armour", system: game.model.Item.armour })
|
||||
} else if (name.toLowerCase().includes("weapon") || name.toLowerCase().includes("arme")) {
|
||||
itemFound = new ItemWfrp4e({ img: "systems/wfrp4e/icons/blank.png", name: name, type: "weapon", system: game.system.model.Item.weapon })
|
||||
itemFound = new ItemWfrp4e({ img: "systems/wfrp4e/icons/blank.png", name: name, type: "weapon", system: game.model.Item.weapon })
|
||||
} else {
|
||||
itemFound = new ItemWfrp4e({ img: "systems/wfrp4e/icons/blank.png", name: name, type: "trapping", system: game.system.model.Item.trapping })
|
||||
itemFound = new ItemWfrp4e({ img: "systems/wfrp4e/icons/blank.png", name: name, type: "trapping", system: game.model.Item.trapping })
|
||||
itemFound.system.trappingType.value = "misc"
|
||||
if (name.toLowerCase().includes("cloth")) {
|
||||
itemFound.system.trappingType.value = "clothingAccessories"
|
||||
@ -457,7 +447,7 @@ export default async function statParserFR(statString, type = "npc") {
|
||||
itemFound = await __findItem(name, "spell");
|
||||
}
|
||||
if (!itemFound && name) { // Auto-create the spell name
|
||||
itemFound = new ItemWfrp4e({ img: "systems/wfrp4e/icons/blank.png", name: name + "(To be checked/completed)", type: "spell", system: game.system.model.Item.spell })
|
||||
itemFound = new ItemWfrp4e({ img: "systems/wfrp4e/icons/blank.png", name: name + "(To be checked/completed)", type: "spell", system: game.model.Item.spell })
|
||||
itemFound = itemFound.toObject();
|
||||
}
|
||||
} else if (def.name == 'mutation') {
|
||||
@ -507,7 +497,7 @@ export default async function statParserFR(statString, type = "npc") {
|
||||
}
|
||||
//DEBUG : console.log("EFFECTS", effects)
|
||||
|
||||
return { name, type, data: model, items: globalItemList, effects }
|
||||
return { name, type, system: model, items: globalItemList, effects }
|
||||
}
|
||||
|
||||
// If the carac string has not been found
|
||||
|
Reference in New Issue
Block a user