Start importer rework
This commit is contained in:
@ -1,3 +1,6 @@
|
||||
/************************************************************************************/
|
||||
import autoTranslateItems from "./modules/import-stat-2.js";
|
||||
|
||||
/************************************************************************************/
|
||||
var compmod = "wfrp4e";
|
||||
|
||||
@ -10,7 +13,8 @@ Hooks.once('init', () => {
|
||||
compmod = "wfrp4e-core";
|
||||
}
|
||||
} );
|
||||
|
||||
game.wfrp4efr = { compmod: compmod };
|
||||
|
||||
//WFRP_Tables = game.wfrp4e.tables;
|
||||
//WFRP4E = game.wfrp4e.config;
|
||||
//CONFIG.Actor.entityClass = ActorWfrp4e_fr;
|
||||
@ -134,8 +138,7 @@ Hooks.once('init', () => {
|
||||
//console.log("calculateSpellAttributes -> " + formula );
|
||||
return formula.capitalize();
|
||||
}
|
||||
|
||||
console.log("PROTO", game.wfrp4e.entities.ActorWfrp4e.prototype);
|
||||
//1console.log("PROTO", game.wfrp4e.entities.ActorWfrp4e.prototype);
|
||||
|
||||
// Babele stuff
|
||||
if(typeof Babele !== 'undefined') {
|
||||
@ -224,118 +227,7 @@ Hooks.once('init', () => {
|
||||
return chars;
|
||||
},
|
||||
"bestiary_traits": (beast_traits, translations) => {
|
||||
var fulltraits = game.packs.get(compmod+'.traits');
|
||||
var fullskills = game.packs.get(compmod+'.skills');
|
||||
var fulltalents = game.packs.get(compmod+'.talents');
|
||||
var fullcareers = game.packs.get(compmod+'.careers');
|
||||
var fulltrappings = game.packs.get(compmod+'.trappings');
|
||||
var fullspells = game.packs.get(compmod+'.spells');
|
||||
var fullprayers = game.packs.get(compmod+'.prayers');
|
||||
var eisitems = game.packs.get('eis.eisitems');
|
||||
var eisspells = game.packs.get('eis.eisspells');
|
||||
var ugtalents = game.packs.get('wfrp4e-unofficial-grimoire.ug-careerstalentstraits');
|
||||
var ugspells = game.packs.get('wfrp4e-unofficial-grimoire.ug-spells');
|
||||
//console.log("Comp :", compmod, fulltraits);
|
||||
|
||||
for (let trait_en of beast_traits)
|
||||
{
|
||||
var special = "";
|
||||
var nbt = "";
|
||||
var name_en = trait_en.name.trim(); // strip \r in some traits name
|
||||
|
||||
if ( trait_en.type == "trait") {
|
||||
if ( name_en.includes("Tentacles") ) { // Process specific Tentacles case
|
||||
var re = /(.d*)x Tentacles/i;
|
||||
var res = re.exec( name_en );
|
||||
if ( res && res[1] )
|
||||
nbt = res[1] + "x ";
|
||||
name_en = "Tentacles";
|
||||
} else if ( name_en.includes("(") && name_en.includes(")") ) { // Then process specific traits name with (xxxx) inside
|
||||
var re = /(.*) \((.*)\)/i;
|
||||
var res = re.exec( name_en );
|
||||
name_en = res[1]; // Get the root traits name
|
||||
special = " (" + game.i18n.localize( res[2].trim() ) + ")"; // And the special keyword
|
||||
}
|
||||
var trait_fr = fulltraits.translate( { name: name_en } );
|
||||
//console.log(">>>>> Trait ?", name_en, nbt, trait_fr.name, special);
|
||||
trait_en.name = nbt + trait_fr.name + special;
|
||||
if ( trait_fr.data && trait_fr.data.description && trait_fr.data.description.value ) {
|
||||
trait_en.data.description.value = trait_fr.data.description.value;
|
||||
} else if ( eisitems ) { // No description in the FR compendium -> test other compendium if presenr
|
||||
trait_fr = eisitems.translate( { name: name_en } );
|
||||
trait_en.name = nbt + trait_fr.name + special;
|
||||
if ( trait_fr.data && trait_fr.data.description && trait_fr.data.description.value )
|
||||
trait_en.data.description.value = trait_fr.data.description.value;
|
||||
}
|
||||
if ( isNaN(trait_en.data.specification.value) ) { // This is a string, so translate it
|
||||
//console.log("Translating : ", trait_en.data.specification.value);
|
||||
trait_en.data.specification.value = game.i18n.localize( trait_en.data.specification.value.trim() );
|
||||
}
|
||||
} else if ( trait_en.type == "skill") {
|
||||
if ( name_en.includes("(") && name_en.includes(")") ) { // Then process specific skills name with (xxxx) inside
|
||||
var re = /(.*) +\((.*)\)/i;
|
||||
var res = re.exec( name_en );
|
||||
name_en = res[1].trim(); // Get the root skill name
|
||||
special = " (" + game.i18n.localize( res[2].trim() ) + ")"; // And the special keyword
|
||||
}
|
||||
var trait_fr = fullskills.translate( { name: name_en } );
|
||||
//console.log(">>>>> Skill ?", name_en, special, trait_fr.name, trait_fr);
|
||||
if (trait_fr.translated) {
|
||||
trait_en.name = trait_fr.name + special;
|
||||
if ( trait_fr.data ) {
|
||||
trait_en.data.description.value = trait_fr.data.description.value;
|
||||
}
|
||||
}
|
||||
} else if ( trait_en.type == "prayer") {
|
||||
var trait_fr = fullprayers.translate( { name: name_en } );
|
||||
//console.log(">>>>> Prayer ?", name_en, special, trait_fr.name );
|
||||
trait_en.name = trait_fr.name + special;
|
||||
if ( trait_fr.data && trait_fr.data.description && trait_fr.data.description.value )
|
||||
trait_en.data.description.value = trait_fr.data.description.value;
|
||||
} else if ( trait_en.type == "spell") {
|
||||
var trait_fr = fullspells.translate( { name: name_en } );
|
||||
if ( (!trait_fr.data || !trait_fr.data.description || !trait_fr.data.description.value) && eisspells) { // If no translation, test eisspells
|
||||
trait_fr = eisspells.translate( { name: name_en } );
|
||||
}
|
||||
if ( (!trait_fr.data || !trait_fr.data.description || !trait_fr.data.description.value) && ugspells) { // If no translation, test eisspells
|
||||
trait_fr = ugspells.translate( { name: name_en } );
|
||||
}
|
||||
//console.log(">>>>> Spell ?", name_en, special, trait_fr.name );
|
||||
trait_en.name = trait_fr.name + special;
|
||||
if ( trait_fr.data && trait_fr.data.description && trait_fr.data.description.value )
|
||||
trait_en.data.description.value = trait_fr.data.description.value;
|
||||
} else if ( trait_en.type == "talent") {
|
||||
if ( name_en.includes("(") && name_en.includes(")") ) { // Then process specific skills name with (xxxx) inside
|
||||
var re = /(.*) +\((.*)\)/i;
|
||||
var res = re.exec( name_en );
|
||||
name_en = res[1].trim(); // Get the root talent name, no parenthesis this time...
|
||||
special = " (" + game.i18n.localize( res[2].trim() ) + ")"; // And the special keyword
|
||||
}
|
||||
var trait_fr = fulltalents.translate( { name: name_en } );
|
||||
//console.log(">>>>> Talent ?", name_en, special, trait_fr.name);
|
||||
if ( (!trait_fr.data || !trait_fr.data.description || !trait_fr.data.description.value) && ugtalents) { // If no translation, test ugtalents
|
||||
trait_fr = ugtalents.translate( { name: name_en } );
|
||||
}
|
||||
if ( trait_fr.translated) {
|
||||
trait_en.name = trait_fr.name + special;
|
||||
if ( trait_fr.data ) { // Why ???
|
||||
trait_en.data.description.value = trait_fr.data.description.value;
|
||||
}
|
||||
}
|
||||
} else if ( trait_en.type == "career") {
|
||||
var career_fr = fullcareers.translate( trait_en );
|
||||
//console.log(">>>>> Career ?", name_en, career_fr.name);
|
||||
trait_en = career_fr;
|
||||
} else if ( trait_en.type == "trapping" || trait_en.type == "weapon" || trait_en.type == "armour" || trait_en.type == "container" || trait_en.type == "money") {
|
||||
var trapping_fr = fulltrappings.translate( trait_en );
|
||||
//console.log(">>>>> Trapping ?", name_en, trapping_fr.name);
|
||||
trait_en.name = trapping_fr.name;
|
||||
if ( trapping_fr.data) {
|
||||
trait_en.data.description = trapping_fr.data.description;
|
||||
}
|
||||
}
|
||||
}
|
||||
return beast_traits;
|
||||
return autoTranslateItems(beast_traits, translations );
|
||||
},
|
||||
// To avoid duplicateing class for all careers
|
||||
"generic_localization": (value) => {
|
||||
|
Reference in New Issue
Block a user