forked from public/foundryvtt-wh4-lang-fr-fr
New fixes for v7.0.0
This commit is contained in:
@ -3,17 +3,23 @@ export class WH4FRPatchConfig {
|
||||
|
||||
/************************************************************************************/
|
||||
static translateSkillList( skillList) {
|
||||
|
||||
let compendiumName = 'wfrp4e-core.skills' // Per default
|
||||
if (game.system.version.match("7.")) {
|
||||
compendiumName = 'wfrp4e-core.items'
|
||||
}
|
||||
|
||||
let newList = [];
|
||||
for( let compName of skillList) {
|
||||
let special = "";
|
||||
let newName = compName;
|
||||
if ( compName.includes("(") && compName.includes(")") ) { // Then process specific skills name with (xxxx) inside
|
||||
var re = /(.*) +\((.*)\)/i;
|
||||
var res = re.exec( compName );
|
||||
let re = /(.*) +\((.*)\)/i;
|
||||
let res = re.exec( compName );
|
||||
compName = res[1].trim(); // Get the root skill name
|
||||
special = " (" + game.i18n.localize( res[2].trim() ) + ")"; // And the special keyword
|
||||
}
|
||||
var compNameFR = game.babele.translate( 'wfrp4e-core.skills', { name: compName }, true );
|
||||
let compNameFR = game.babele.translate( compendiumName, { name: compName }, true );
|
||||
//console.log(">>>>> Skill ?", compName, special, compNameFR);
|
||||
if (compNameFR.name != compName) { // Translation OK
|
||||
newName = compNameFR.name + special;
|
||||
@ -25,6 +31,12 @@ export class WH4FRPatchConfig {
|
||||
|
||||
/************************************************************************************/
|
||||
static translateTalentList( talentList) {
|
||||
|
||||
let compendiumName = 'wfrp4e-core.talents' // Per default
|
||||
if (game.system.version.match("7.")) {
|
||||
compendiumName = 'wfrp4e-core.items'
|
||||
}
|
||||
|
||||
let newList = [];
|
||||
for( let talentLine of talentList) {
|
||||
let special = "";
|
||||
@ -36,12 +48,12 @@ export class WH4FRPatchConfig {
|
||||
talentName = talentName.trim();
|
||||
let newName2 = talentName;
|
||||
if ( talentName.includes("(") && talentName.includes(")") ) { // Then process specific skills name with (xxxx) inside
|
||||
var re = /(.*) +\((.*)\)/i;
|
||||
var res = re.exec( talentName );
|
||||
let re = /(.*) +\((.*)\)/i;
|
||||
let res = re.exec( talentName );
|
||||
talentName = res[1].trim(); // Get the root skill name
|
||||
special = " (" + game.i18n.localize( res[2].trim() ) + ")"; // And the special keyword
|
||||
}
|
||||
var talentNameFR = game.babele.translate( 'wfrp4e-core.talents', { name: talentName }, true );
|
||||
let talentNameFR = game.babele.translate( compendiumName, { name: talentName }, true );
|
||||
//console.log(">>>>> Talent ?", talentName, special, talentNameFR);
|
||||
if (talentNameFR.name != talentName) { // Translation OK
|
||||
newName2 = talentNameFR.name + special;
|
||||
@ -90,6 +102,11 @@ export class WH4FRPatchConfig {
|
||||
|
||||
/************************************************************************************/
|
||||
static patch_career() {
|
||||
let compendiumName = 'wfrp4e-core.careers' // Per default
|
||||
if (game.system.version.match("7.")) {
|
||||
compendiumName = 'wfrp4e-core.items'
|
||||
}
|
||||
|
||||
if ( game.wfrp4e.tables.career) {
|
||||
for( let row of game.wfrp4e.tables.career.rows) {
|
||||
for ( let key in row) {
|
||||
@ -100,7 +117,7 @@ export class WH4FRPatchConfig {
|
||||
row[key].name = "Duelliste";
|
||||
//console.log(">>>>> Career ?", key, row[key].name, career_fr.name );
|
||||
} else {
|
||||
var career_fr = game.babele.translate( 'wfrp4e-core.careers', {name: row[key].name}, true );
|
||||
let career_fr = game.babele.translate( compendiumName, {name: row[key].name}, true );
|
||||
row[key].name = career_fr.name;
|
||||
}
|
||||
}
|
||||
@ -121,7 +138,7 @@ export class WH4FRPatchConfig {
|
||||
}
|
||||
|
||||
// Detect and patch as necessary
|
||||
if (game.wfrp4e.config && game.wfrp4e.config.talentBonuses && game.wfrp4e.config.talentBonuses["vivacité"] == undefined) {
|
||||
if (game.wfrp4e.config?.talentBonuses && game.wfrp4e.config.talentBonuses["vivacité"] == undefined) {
|
||||
console.log("Patching WFRP4E now ....");
|
||||
game.wfrp4e.config.qualityDescriptions["distract"] = game.i18n.localize("WFRP4E.Properties.Distract"); // Patch missing quality
|
||||
|
||||
|
@ -78,7 +78,7 @@ async function __findItem(itemName, itemType, location = null) {
|
||||
|
||||
// Search imported items first
|
||||
for (let i of items) {
|
||||
if (i.name == itemName && i.type == itemType)
|
||||
if (i.name.toLowerCase() == itemName.toLowerCase() && i.type == itemType)
|
||||
return i;
|
||||
}
|
||||
let itemList
|
||||
@ -91,7 +91,7 @@ async function __findItem(itemName, itemType, location = null) {
|
||||
})
|
||||
if (pack) {
|
||||
await pack.getIndex().then(index => itemList = index);
|
||||
let searchResult = itemList.find(t => (t.translated && t.originalName.toLowerCase() == toSearch) || (t.name.toLowerCase() == toSearch) );
|
||||
let searchResult = itemList.find(t => (t.translated && t.type == itemType && t.originalName.toLowerCase() == toSearch) || (t.type == itemType && t.name.toLowerCase() == toSearch) );
|
||||
if (searchResult)
|
||||
return await pack.getDocument(searchResult._id)
|
||||
}
|
||||
@ -100,7 +100,7 @@ async function __findItem(itemName, itemType, location = null) {
|
||||
// If all else fails, search each pack
|
||||
for (let p of game.wfrp4e.tags.getPacksWithTag(itemType)) {
|
||||
await p.getIndex().then(index => itemList = index);
|
||||
let searchResult = itemList.find(t => (t.translated && t.originalName.toLowerCase() == toSearch) || (t.name.toLowerCase() == toSearch) );
|
||||
let searchResult = itemList.find(t => (t.translated && t.type == itemType && t.originalName.toLowerCase() == toSearch) || (t.type == itemType && t.name.toLowerCase() == toSearch) );
|
||||
if (searchResult)
|
||||
return await p.getDocument(searchResult._id)
|
||||
}
|
||||
@ -134,7 +134,8 @@ async function __findSkill(skillName, value = undefined) {
|
||||
let spec = XRegExp.replace(skillSplit.specialized, "(", "");
|
||||
spec = XRegExp.replace(spec, ")", "");
|
||||
let skillSplit2 = XRegExp.exec(dbSkill.name, XRegExp(parseStr, 'gi'));
|
||||
dbSkill.update( { name: skillSplit2.name + '(' + game.i18n.localize( spec.trim() ) + ')' } );
|
||||
dbSkill.name = skillSplit2.name + '(' + game.i18n.localize( spec.trim() ) + ')'
|
||||
//dbSkill.update( { name: } );
|
||||
}
|
||||
//game.babele.translate('wfrp4e-core.skills', dbSkill);
|
||||
return dbSkill;
|
||||
@ -195,7 +196,7 @@ export default async function statParserFR(statString, type = "npc") {
|
||||
let sectionData = sectionDataUS
|
||||
// Detect French stat block
|
||||
if (statString.includes('CC') && statString.includes('CT') && statString.includes('FM')) {
|
||||
ui.notifications.warn("Le parsing de stablock en Français n'est pas encore prêt")
|
||||
//ui.notifications.warn("Le parsing de stablock en Français n'est pas encore prêt")
|
||||
statNameReg = fr_carac
|
||||
sectionData = sectionDataFR
|
||||
}
|
||||
@ -285,6 +286,7 @@ export default async function statParserFR(statString, type = "npc") {
|
||||
if (itemFound && value && value.length > 0) {
|
||||
if (name.toLowerCase() == 'weapon' || name.toLowerCase() == "bite" || name.toLowerCase() == "tail" ||
|
||||
name.toLowerCase() == 'arme' || name.toLowerCase() == "morsure" || name.toLowerCase() == "queue") {
|
||||
console.log(itemFound)
|
||||
itemFound.system.specification.value = Number(value) - Math.floor( Number(model.characteristics.s.initial) / 10)
|
||||
} else {
|
||||
itemFound.system.specification.value = game.i18n.localize(value)
|
||||
|
Reference in New Issue
Block a user