Fix character import

This commit is contained in:
2024-10-22 13:20:02 +02:00
parent 5451698163
commit bfe160cc00
16 changed files with 15 additions and 25 deletions
+2 -2
View File
@@ -8,7 +8,7 @@
} }
], ],
"url": "https://www.uberwald.me/gitea/public/foundryvtt-wh4-lang-fr-fr", "url": "https://www.uberwald.me/gitea/public/foundryvtt-wh4-lang-fr-fr",
"version": "8.2.0", "version": "8.2.1",
"esmodules": [ "esmodules": [
"modules/babele-register.js", "modules/babele-register.js",
"modules/addon-register.js", "modules/addon-register.js",
@@ -117,7 +117,7 @@
} }
], ],
"manifest": "https://www.uberwald.me/gitea/public/foundryvtt-wh4-lang-fr-fr/raw/v10/module.json", "manifest": "https://www.uberwald.me/gitea/public/foundryvtt-wh4-lang-fr-fr/raw/v10/module.json",
"download": "https://www.uberwald.me/gitea/public/foundryvtt-wh4-lang-fr-fr/archive/foundryvtt-wh4-lang-fr-8.2.0.zip", "download": "https://www.uberwald.me/gitea/public/foundryvtt-wh4-lang-fr-fr/archive/foundryvtt-wh4-lang-fr-8.2.1.zip",
"id": "wh4-fr-translation", "id": "wh4-fr-translation",
"compatibility": { "compatibility": {
"minimum": "12", "minimum": "12",
+1 -1
View File
@@ -257,7 +257,7 @@ const __check_fix_wrong_modules = (chatFlag, patchFinished) => {
}); });
if (game.user.isGM && patchFinished) { if (game.user.isGM && patchFinished) {
ChatMessage.create({ ChatMessage.create({
content: "<div>Les modules WFRP4E ont été <strong>patchés avec succés</strong>. Vous pouvez y aller et que <strong>Shallya vous garde !</strong></div><div>Derniers changements : correction pour acteurs de RNHD et ajout des traductions des items de Aventures à Ubesreik 1 (François Cheminade)</div></ul>", content: "<div>Les modules WFRP4E ont été <strong>patchés avec succés</strong>. Vous pouvez y aller et que <strong>Shallya vous garde !</strong></div><div>Derniers changements : Support wfrp4 v8.X, import de personnage OK</div></ul>",
user: game.user.id, user: game.user.id,
whisper: ChatMessage.getWhisperRecipients("GM") whisper: ChatMessage.getWhisperRecipients("GM")
}); });
+1 -1
View File
@@ -364,7 +364,7 @@ Hooks.once('init', () => {
let s1 = res[1].trim(); // No () in talents table let s1 = res[1].trim(); // No () in talents table
translItem = game.babele.translate(compData.metadata.id, { name: s1 }, true) translItem = game.babele.translate(compData.metadata.id, { name: s1 }, true)
let translw = translItem?.name || undefined let translw = translItem?.name || undefined
console.log("Search talent name:", compData.metadata.id, s1, translw); //console.log("Search talent name:", compData.metadata.id, s1, translw);
if (translw && translw != s1) { if (translw && translw != s1) {
transl = translw + " (" + subword + ")"; transl = translw + " (" + subword + ")";
} }
+11 -21
View File
@@ -1,18 +1,8 @@
/************************************************************************************/ /************************************************************************************/
// Some internal test strings // Some internal test strings
let strfr = `LA TERREUR DE LA TEUFEL, TROLL DE RIVIÈRE RUSÉ let strfr = `LA TERREUR DE LA TEUFEL, TROLL DE RIVIÈRE RUSÉ
M M CC CT F E I Ag Dex Int FM Soc B
CC CT 4 40 15 55 45 20 15 15 30 20 5 38
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 Traits : Amphibie, Arme +9, Armure (2), Dur à Cuire, Insensible
à la douleur, Morsure +8, Régénération, Taille (Grande), Vision à la douleur, Morsure +8, Régénération, Taille (Grande), Vision
Nocturne, Vomissement` 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 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 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 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 = [ let sectionDataFR = [
{ name: "trait", toFind: "Traits\\s*:", secondParse: '(?<name>[a-zöàéè\\s]*)[\\s\\+]*(?<value>.*|[\\+0-9]+)', index: -1 }, { 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 }, { 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") { 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 // Patch wront/strange carac value before processing
statString = statString.replace(/ /g, " 0") 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 let resCarac = XRegExp.exec(statString, reg2) // resr contains all carac found
// Setup carac // Setup carac
//console.log("CARAC", resCarac) console.log("CARAC", resCarac)
if (resCarac["Agi"]) resCarac["Ag"] = resCarac["Agi"] // Auto patch if (resCarac["Agi"]) resCarac["Ag"] = resCarac["Agi"] // Auto patch
model.details.move.value = Number(resCarac["m"]) model.details.move.value = Number(resCarac["m"])
for (let key in model.characteristics) { for (let key in model.characteristics) {
if (resCarac[key] === '-') resCarac[key] = 0 if (resCarac[key] === '-') resCarac[key] = 0
model.characteristics[key].initial = Number(resCarac[key]) model.characteristics[key].initial = Number(resCarac[key])
} }
//console.log("CARAC", model.characteristics); console.log("CARAC", model.characteristics);
// Search position of skills/talents/... // Search position of skills/talents/...
for (let def of sectionData) { for (let def of sectionData) {
@@ -424,11 +414,11 @@ export default async function statParserFR(statString, type = "npc") {
} }
if (!itemFound && name) { if (!itemFound && name) {
if (name.toLowerCase().includes("armor") || name.toLowerCase().includes("armure") || name.toLowerCase().includes("armour")) { 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")) { } 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 { } 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" itemFound.system.trappingType.value = "misc"
if (name.toLowerCase().includes("cloth")) { if (name.toLowerCase().includes("cloth")) {
itemFound.system.trappingType.value = "clothingAccessories" itemFound.system.trappingType.value = "clothingAccessories"
@@ -457,7 +447,7 @@ export default async function statParserFR(statString, type = "npc") {
itemFound = await __findItem(name, "spell"); itemFound = await __findItem(name, "spell");
} }
if (!itemFound && name) { // Auto-create the spell name 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(); itemFound = itemFound.toObject();
} }
} else if (def.name == 'mutation') { } else if (def.name == 'mutation') {
@@ -507,7 +497,7 @@ export default async function statParserFR(statString, type = "npc") {
} }
//DEBUG : console.log("EFFECTS", effects) //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 // If the carac string has not been found
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.