Better spells handling

This commit is contained in:
LeRatierBretonnien 2020-04-10 15:11:26 +02:00
parent 9bc414c8a2
commit 3e242bf0a4
4 changed files with 91 additions and 12 deletions

View File

@ -11,7 +11,7 @@ Hooks.once('init', () => {
Babele.get().registerConverters({
"career_skills": (skills_list) => {
console.log( game.i18n.localize( "Any" ) );
console.log( "Thru here ..." );
var compendium = game.packs.find(p => p.collection === 'wfrp4e.skills');
var i;
var len = skills_list.length;
@ -25,7 +25,7 @@ Hooks.once('init', () => {
var subword = game.i18n.localize(res[2].trim() );
var s1 = res[1].trim() + " ()";
var translw = compendium.i18nName( s1 );
if (translw != transl) {
if (translw != s1) {
var res2 = re.exec(translw);
transl = res2[1] + "(" + subword + ")";
} else {
@ -54,7 +54,7 @@ Hooks.once('init', () => {
var subword = game.i18n.localize(res[2].trim() );
var s1 = res[1].trim(); // No () in talents table
var translw = compendium.i18nName( s1 );
if (translw != transl) {
if (translw != s1) {
transl = translw + "(" + subword + ")";
} else {
s1 = res[1].trim() + " ( )";
@ -94,6 +94,45 @@ Hooks.once('init', () => {
"career_careergroup": (value) => {
var compendium = game.packs.find(p => p.collection === 'wfrp4e.careers');
return compendium.i18nName( value );
},
// Auto-translate duration
"spells_duration_range_target_damage": (value) => {
--console.log("Spell duration/range/damage/target :", value);
if ( value == "" ) return ""; // Hop !
if ( value == "Touch" ) return "Contact"; // Hop !
if ( value == "You" ) return "Vous"; // Hop !
if ( value == "Instant" ) return "Instantané"; // Hop !
var translw = value;
var re = /(.*) Bonus (\w*)/i;
var res = re.exec( value );
var unit = "";
if ( res ) { // Test "<charac> Bonus <unit>" pattern
if ( res[1] ) { // We have char name, then convert it
translw = "Bonus de " + game.i18n.localize( res[1].trim() );
}
unit = res[2];
} else {
re = /(\d+) (\w+)/i;
res = re.exec( value );
if (res) { // Test : "<number> <unit>" pattern
translw = res[1];
unit = res[2];
} else { // Test
re = /(\w+) (\w+)/i;
res = re.exec( value );
if (res) { // Test : "<charac> <unit>" pattern
translw = game.i18n.localize( res[1].trim() );
unit = res[2];
}
}
}
if ( unit == "hour") unit = "heure";
if ( unit == "hours") unit = "heures";
if ( unit == "days") unit = "jours";
if ( unit == "yard") unit = "mètre";
if ( unit == "yards") unit = "mètres";
translw += " " + unit;
return translw;
}
});
}

View File

@ -1,5 +1,23 @@
{
"label": "Spells",
"label": "Sorts",
"mapping": {
"sduration": {
"path": "data.duration.value",
"converter": "spells_duration_range_target_damage"
},
"srange": {
"path": "data.range.value",
"converter": "spells_duration_range_target_damage"
},
"starget": {
"path": "data.target.value",
"converter": "spells_duration_range_target_damage"
},
"sdamage": {
"path": "data.damage.value",
"converter": "spells_duration_range_target_damage"
}
},
"entries": [
{
"id": "Acquiescence",

24
fr.json
View File

@ -652,6 +652,26 @@
"Entangling": "Entraves",
"Sling": "Fronde",
"Petty": "Mineure",
"Beasts": "Bêtes",
"Death": "Mort",
"Fire": "Feu",
"Heavens": "Cieux",
"Metal": "Métal",
"Life": "Vie",
"Light": "Lumière",
"Shadow": "Ombres",
"Hedgecraft": "Sauvage",
"Witchcraft": "Sorcellerie",
"Daemonology": "Démonologie",
"Necromancy": "Nécromancie",
"Nurgle": "Nurgle",
"Slaanesh": "Slaanesh",
"Tzeentch": "Tzeentch",
"Cast Skill": "Compétence d'incantation",
"Language" : "Langue",
"Magick" : "Magick",
"AP": "PA",
"yards": "mètres",
"yds": "m.",
@ -736,7 +756,7 @@
"TIER.Brass" : "Bronze",
"NAME.Pray" : "Prière",
"NAME.Language" : "Language",
"NAME.Language" : "Langue",
"SPEC.Magick" : "Magick",
"NAME.Channelling" : "Focalisation",
"NAME.Melee" : "Corps à Corps",
@ -844,6 +864,7 @@
"ITEM.NoSpec" : "Pas de spécialisation",
"Instant" : "Immédiat",
"Casting Number": "Niveau d'Incantation",
"ClassTrappings.Academics": "Vêtements, Dague, Bourse, Besace contenant un nécessaire d'écriture et 1d10 feuilles de parchemin",
"ClassTrappings.Burghers": "Cape, Vêtements, Dague, Chapeau, Bourse, Besace contenant 1 repas",
@ -857,4 +878,5 @@
"NAME.Stealth" : "Discrétion",
"AP" : "PA",
"Scatter" : "Dispersion"
}