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" "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": [], "effects": [],
"id": "Concoct", "id": "Concoct",
"name": "Concocter", "name": "Concocter",

View File

@ -2,7 +2,7 @@
"name": "WH4-fr-translation", "name": "WH4-fr-translation",
"title": "WFRP4e - Core Module en français.", "title": "WFRP4e - Core Module en français.",
"description": "Traduction Française pour Warhammer v4.", "description": "Traduction Française pour Warhammer v4.",
"version": "4.2.3", "version": "4.2.4",
"minimumCoreVersion" : "0.8.0", "minimumCoreVersion" : "0.8.0",
"compatibleCoreVersion": "0.8.9", "compatibleCoreVersion": "0.8.9",
"author": "LeRatierBretonnien", "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 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 sectionData = [ 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: "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: "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 } { 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 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" 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") { export default async function statParserFR(statString, type = "npc") {
let model = duplicate(game.system.model.Actor[type]); let model = duplicate(game.system.model.Actor[type]);
@ -225,17 +233,24 @@ export default async function statParserFR(statString, type = "npc") {
let itemFound, subres, value; let itemFound, subres, value;
if (def.secondParse) { if (def.secondParse) {
subres = XRegExp.exec(name, XRegExp(def.secondParse, 'gi')); 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, "(", "");
value = XRegExp.replace(subres.value, ")", ""); value = XRegExp.replace(subres.value, ")", "");
} }
name = __patchName(name);
if (def.name == 'trait') { if (def.name == 'trait') {
try { try {
itemFound = await __findItem(name, "trait"); itemFound = await __findItem(name, "trait");
} }
catch { } catch { }
if (itemFound)
itemFound = itemFound.toObject();
if (itemFound && subres && subres.value.length > 0) { 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) if (!itemFound)
ui.notifications.error("Trait non trouvé, à ajouter manuellement : " + name, { permanent: true }) 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); itemFound = await __findSkill(name, value);
} }
catch { } catch { }
if (itemFound)
itemFound = itemFound.toObject();
if (itemFound && subres && value) { 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) if (!itemFound)
ui.notifications.error("Compétence non trouvée, à ajouter manuellement : " + name, { permanent: true }) 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); itemFound = await __findTalent(name);
} }
catch { } catch { }
if (itemFound)
itemFound = itemFound.toObject();
if (itemFound && subres && value) if (itemFound && subres && value)
itemFound.data.data.advances.value = Number(value); itemFound.data.advances.value = Number(value);
if (!itemFound) if (!itemFound)
ui.notifications.error("Talent non trouvé, à ajouter manuellement : " + name, { permanent: true }) ui.notifications.error("Talent non trouvé, à ajouter manuellement : " + name, { permanent: true })
} else if (def.name == 'trapping') { } else if (def.name == 'trapping') {
@ -263,11 +282,21 @@ export default async function statParserFR(statString, type = "npc") {
itemFound = await __findItem(name, "trapping"); itemFound = await __findItem(name, "trapping");
} }
catch { } 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 = new ItemWfrp4e({ img: "systems/wfrp4e/icons/blank.png", name: name, type: "trapping", data: game.system.model.Item.trapping })
itemFound.data.data.trappingType.value = "misc" 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) if (itemFound)
globalItemList.push(itemFound); globalItemList.push(itemFound);
} }