Enhance auto-translate, add shield management and minor fixes
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
/************************************************************************************/
|
||||
/* Override some methods of the WFRP4 actor class, mainly to compute spells/weapons */
|
||||
class ActorWfrp4e_fr extends ActorWfrp4e {
|
||||
|
||||
/**
|
||||
@ -143,48 +145,14 @@ class ActorWfrp4e_fr extends ActorWfrp4e {
|
||||
//console.log("calculateSpellAttributes -> " + formula );
|
||||
return formula.capitalize();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Hooks.on("chatMessage", async (html, content, msg) => {
|
||||
// Split input into arguments
|
||||
let command = content.split(" ").map(function(item) {
|
||||
return item.trim();
|
||||
})
|
||||
|
||||
if (command[0] == "/auberge")
|
||||
{
|
||||
msg["type"] = 0;
|
||||
msg["rollMode"] = "gmroll";
|
||||
var compendium = game.packs.find(p => p.collection === 'WH4-fr-translation.plats-dauberges');
|
||||
let rollList = [];
|
||||
await compendium.getIndex().then(index => rollList = index);
|
||||
//console.log("Got compendium...", rollList.length);
|
||||
for (var i=0; i< rollList.length; i++) {
|
||||
var rollTab = rollList[i];
|
||||
if ( rollTab.name.toLowerCase().includes(command[1].toLowerCase()) ) {
|
||||
let my_rollTable;
|
||||
await compendium.getEntity(rollTab._id).then(mytab => my_rollTable = mytab);
|
||||
var result = my_rollTable.roll();
|
||||
console.log("RES: ", result[0], result[1] );
|
||||
msg.content = my_rollTable.name + " : " + result[1].text;
|
||||
//my_rollTable.draw();
|
||||
ChatMessage.create(msg);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
msg["content"] = "Syntaxe : /auberge MOT_CLE, avec MOT_CLE parmi:<br>BoissonsBase, BoissonsFortes, Desserts, PlatsCommuns, PlatsExcellents, PlatsMaritimes, PlatsMédiocres, PlatsQualité, PlatsRivières<br>Des raccourcis sont possibles avec une partie du nom : /auberge Base (correspond à BoissonBase) ou /auberge Mari (correspond à PlatsMaritimes), etc."
|
||||
ChatMessage.create(msg);
|
||||
return false;
|
||||
}
|
||||
} );
|
||||
|
||||
var __mywait = ms => new Promise((r, j)=>setTimeout(r, ms))
|
||||
|
||||
/************************************************************************************/
|
||||
Hooks.once('init', () => {
|
||||
|
||||
|
||||
// Replace to manage specific bonuses/char. computations
|
||||
CONFIG.Actor.entityClass = ActorWfrp4e_fr;
|
||||
CONFIG.Actor.entityClass = ActorWfrp4e_fr;
|
||||
|
||||
WFRP4E.talentBonuses = {
|
||||
"perspicace": "int",
|
||||
"affable": "fel",
|
||||
@ -346,7 +314,7 @@ Hooks.once('init', () => {
|
||||
}
|
||||
skills_list[i] = transl;
|
||||
}
|
||||
return skills_list;
|
||||
return skills_list;
|
||||
},
|
||||
"career_talents": (talents_list) => {
|
||||
var compendium = game.packs.find(p => p.collection === 'wfrp4e.talents');
|
||||
@ -387,30 +355,72 @@ Hooks.once('init', () => {
|
||||
return chars;
|
||||
},
|
||||
"bestiary_traits": (beast_traits, translations) => {
|
||||
var compendium = game.packs.find(p => p.collection === 'wfrp4e.traits');
|
||||
var fulltraits = game.packs.find(p => p.collection === 'wfrp4e.traits');
|
||||
var fullskills = game.packs.find(p => p.collection === 'wfrp4e.skills');
|
||||
var fulltalents = game.packs.find(p => p.collection === 'wfrp4e.talents');
|
||||
var fullcareers = game.packs.find(p => p.collection === 'wfrp4e.careers');
|
||||
var fulltrappings = game.packs.find(p => p.collection === 'wfrp4e.trappings');
|
||||
|
||||
for (let trait_en of beast_traits)
|
||||
{
|
||||
var nbt = "";
|
||||
var special = "";
|
||||
var nbt = "";
|
||||
var name_en = trait_en.name.trim(); // strip \r in some traits name
|
||||
if ( name_en.includes("Tentacles") ) { // Process specific Tentacles case
|
||||
var re = /(.d*)x Tentacles/i;
|
||||
var res = re.exec( name_en );
|
||||
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;
|
||||
|
||||
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 );
|
||||
name_en = res[1]; // Get the root traits name
|
||||
special = " (" + res[2] + ")"; // And the special keyword
|
||||
}
|
||||
var trait_fr = compendium.translate( { name: name_en } );
|
||||
//console.log(">>>>> Trait ?", name_en, nbt, trait_fr.name);
|
||||
trait_en.name = nbt + trait_fr.name + special;
|
||||
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() );
|
||||
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_en.data.description && trait_en.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_en.name = trait_fr.name + special;
|
||||
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);
|
||||
trait_en.name = trait_fr.name + special;
|
||||
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;
|
||||
trait_en.data.description = trapping_fr.data.description;
|
||||
}
|
||||
}
|
||||
return beast_traits;
|
||||
|
Reference in New Issue
Block a user