Divers fixes

This commit is contained in:
sladecraven 2021-11-02 21:03:04 +01:00
parent ab65901c38
commit 6f0173b14e
3 changed files with 38 additions and 9 deletions

View File

@ -482,7 +482,7 @@
"tests": "Commandement"
},
{
"description": "Vous êtes doué pour la fabrication de potions, de philtres et de décoctions. Vous pouvez effectuer gratuitement une Activité Artisanat pour utiliser Savoir (Apothicaire) sans avoir besoin d'Atelier. Les autres Activités Artisanat suivent les règles normales.",
"description": "Vous êtes doué pour la fabrication de potions, de philtres et de décoctions. Vous pouvez effectuer gratuitement une Activité Artisanat pour utiliser Métier (Apothicaire) sans avoir besoin d'Atelier. Les autres Activités Artisanat suivent les règles normales.",
"effects": [],
"id": "Concoct",
"name": "Concocter",

View File

@ -2,7 +2,7 @@
"name": "WH4-fr-translation",
"title": "WFRP4e - Core Module en français.",
"description": "Traduction Française pour Warhammer v4.",
"version": "4.2.3",
"version": "4.2.4",
"minimumCoreVersion" : "0.8.0",
"compatibleCoreVersion": "0.8.9",
"author": "LeRatierBretonnien",

View File

@ -37,9 +37,10 @@ const fr_carac = 'm\\s+ws\\s+bs\\s+s\\s+t\\s+i\\s+agi?\\s+dex\\s+int\\s+\\wp\\s+
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]+)';
let sectionData = [
{ 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: "Skills\\s*:", secondParse: '(?<name>[a-z\\s\\(\\)]*)[\\s\\+]*(?<value>.*|[0-9]+)', index: -1 },
{ name: "talent", toFind: "Talents\\s*:", secondParse: '(?<name>[a-z\\-\\s!/]*)[\\s\\+]*(?<value>.*|[0-9]+)', index: -1 },
{ name: "mutation", toFind: "Mutations\\s*:", secondParse: '(?<name>[a-z\\s]*)[\\s\\+]*(?<value>.*|[0-9]+)', index: -1 },
{ name: "trapping", toFind: "Trappings\\s*:", secondParse: '(?<name>[a-z\\s]*)[\\s\\+]*(?<value>.*|[0-9]+)', index: -1 }
];
let regSep = XRegExp('\\s*,\\s*', 'gi'); // Term separator, with auto trim
@ -152,6 +153,13 @@ async function __findTalent(talentName) {
throw "Could not find talent (or specialization of) " + talentName + " in compendium or world"
}
/************************************************************************************/
function __patchName ( name) {
if (name.toLowerCase == 'magic sense')
name = 'Magical Sense';
return name;
}
/************************************************************************************/
export default async function statParserFR(statString, type = "npc") {
let model = duplicate(game.system.model.Actor[type]);
@ -225,17 +233,24 @@ export default async function statParserFR(statString, type = "npc") {
let itemFound, subres, value;
if (def.secondParse) {
subres = XRegExp.exec(name, XRegExp(def.secondParse, 'gi'));
name = subres.name.trim();
name = subres.name.trim().replace("\n", "").replace("\r", "");
value = XRegExp.replace(subres.value, "(", "");
value = XRegExp.replace(subres.value, ")", "");
}
}
name = __patchName(name);
if (def.name == 'trait') {
try {
itemFound = await __findItem(name, "trait");
}
catch { }
if (itemFound)
itemFound = itemFound.toObject();
if (itemFound && subres && subres.value.length > 0) {
itemFound.data.data.specification.value = game.i18n.localize(value);
if (name.toLowerCase == 'weapon') {
itemFound.data.specification.value = Number(value) - Math.floor( Number(model.characteristics.s.initial) / 10);
} else {
itemFound.data.specification.value = game.i18n.localize(value);
}
}
if (!itemFound)
ui.notifications.error("Trait non trouvé, à ajouter manuellement : " + name, { permanent: true })
@ -244,8 +259,10 @@ export default async function statParserFR(statString, type = "npc") {
itemFound = await __findSkill(name, value);
}
catch { }
if (itemFound)
itemFound = itemFound.toObject();
if (itemFound && subres && value) {
itemFound.data.data.advances.value = Number(value) - Number(model.characteristics[itemFound.data.data.characteristic.value].initial);
itemFound.data.advances.value = Number(value) - Number(model.characteristics[itemFound.data.characteristic.value].initial);
}
if (!itemFound)
ui.notifications.error("Compétence non trouvée, à ajouter manuellement : " + name, { permanent: true })
@ -254,8 +271,10 @@ export default async function statParserFR(statString, type = "npc") {
itemFound = await __findTalent(name);
}
catch { }
if (itemFound)
itemFound = itemFound.toObject();
if (itemFound && subres && value)
itemFound.data.data.advances.value = Number(value);
itemFound.data.advances.value = Number(value);
if (!itemFound)
ui.notifications.error("Talent non trouvé, à ajouter manuellement : " + name, { permanent: true })
} else if (def.name == 'trapping') {
@ -263,11 +282,21 @@ export default async function statParserFR(statString, type = "npc") {
itemFound = await __findItem(name, "trapping");
}
catch { }
if (!itemFound) {
if (!itemFound && name) {
itemFound = new ItemWfrp4e({ img: "systems/wfrp4e/icons/blank.png", name: name, type: "trapping", data: game.system.model.Item.trapping })
itemFound.data.data.trappingType.value = "misc"
}
if (itemFound)
itemFound = itemFound.toObject();
} else if (def.name == 'mutation') {
try {
itemFound = await __findItem(name, "mutation");
}
catch { }
if (itemFound)
itemFound = itemFound.toObject();
}
if (itemFound)
globalItemList.push(itemFound);
}