2020-11-08 00:22:04 +01:00
/************************************************************************************/
2020-11-08 23:12:52 +01:00
import statParserFR from "./modules/import-stat-2.js" ;
2020-11-08 00:22:04 +01:00
2020-06-29 08:12:31 +02:00
/************************************************************************************/
var compmod = "wfrp4e" ;
2020-11-13 14:52:23 +01:00
const vo _conditions = {
"ablaze" : "Ablaze" ,
"bleeding" : "Bleeding" ,
"blinded" : "Blinded" ,
"broken" : "Broken" ,
"deafened" : "Deafened" ,
"entangled" : "Entangled" ,
"fatigued" : "Fatigued" ,
"poisoned" : "Poisoned" ,
"prone" : "Prone" ,
"stunned" : "Stunned" ,
"surprised" : "Surprised" ,
"unconscious" : "Unconscious" ,
"grappling" : "Grappling" ,
"fear" : "Fear" ,
"defeated" : "Defeated"
}
2020-06-03 18:30:03 +02:00
2020-04-26 18:38:43 +02:00
/************************************************************************************/
2020-03-25 20:37:09 +01:00
Hooks . once ( 'init' , ( ) => {
2020-04-26 18:38:43 +02:00
2020-07-03 11:38:38 +02:00
// Check various settings in the installation
2020-06-29 07:44:16 +02:00
game . modules . forEach ( ( module , name ) => {
2020-11-05 21:53:12 +01:00
if ( name == "wfrp4e-core" && module . active ) {
compmod = "wfrp4e-core" ;
}
2020-06-29 07:47:22 +02:00
} ) ;
2020-11-13 14:52:23 +01:00
game . wfrp4efr = { compmod : compmod ,
vo _conditions : vo _conditions }
2020-11-08 00:22:04 +01:00
2020-11-08 23:12:52 +01:00
game . wfrp4e . apps . StatBlockParser . parseStatBlock = async function ( statString , type = "npc" ) {
2021-07-26 23:54:21 +02:00
return statParserFR ( statString , type ) ;
}
/*---------------------------------------------------------------------*/
game . wfrp4e . utility . handleConditionClick = function ( event ) {
let cond = $ ( event . currentTarget ) . attr ( "data-cond" )
if ( ! cond )
cond = event . target . text ;
cond = cond . trim ( ) ;
let condkey
// En vo, les noms d'états sont égaux aux clés en minuscules
if ( game . wfrp4e . config . conditions [ cond . toLowerCase ( ) ] ) {
condkey = cond . toLowerCase ( ) ;
} else {
try {
condkey = game . wfrp4e . utility . findKey ( cond . toLowerCase ( ) , game . wfrp4e . config . conditions , { caseInsensitive : true } ) ;
}
catch {
ui . notifications . error ( "L'état est inconnu : " + cond ) ;
}
}
let condName = game . wfrp4e . config . conditions [ condkey ] ;
let condDescr = game . wfrp4e . config . conditionDescriptions [ condkey ] ;
let messageContent = ` <b> ${ condName } </b><br> ${ condDescr } `
let chatData = game . wfrp4e . utility . chatDataSetup ( messageContent )
ChatMessage . create ( chatData ) ;
2020-11-08 23:12:52 +01:00
}
2021-07-26 23:54:21 +02:00
2020-11-13 14:52:23 +01:00
/*---------------------------------------------------------------------*/
2021-07-25 10:05:59 +02:00
game . wfrp4e . entities . ItemWfrp4e . prototype . computeSpellDamage = function ( formula , isMagicMissile ) {
try {
2020-11-13 14:52:23 +01:00
2020-11-07 13:46:15 +01:00
formula = formula . toLowerCase ( ) ;
2020-11-13 14:52:23 +01:00
2020-11-07 13:46:15 +01:00
if ( isMagicMissile ) // If it's a magic missile, damage includes willpower bonus
{
2021-07-25 10:05:59 +02:00
formula += "+ " + this . actor . characteristics [ "wp" ] . bonus
2020-11-07 13:46:15 +01:00
}
2021-07-25 10:05:59 +02:00
2021-02-06 21:50:08 +01:00
// Specific case, to avoid wrong matching with "Force"
if ( formula . includes ( "toughness bonus" ) ) {
2021-07-28 10:46:59 +02:00
formula = formula . replace ( "toughness bonus" , this . actor . characteristics [ "t" ] . bonus ) ;
2021-02-06 21:50:08 +01:00
}
2021-07-25 10:05:59 +02:00
2020-11-07 13:46:15 +01:00
// Specific case, to avoid wrong matching with "Force"
if ( formula . includes ( "force mentale" ) )
{
// Determine if it's looking for the bonus or the value
if ( formula . includes ( 'bonus' ) ) {
2021-07-28 10:46:59 +02:00
formula = formula . replace ( "bonus de force mentale" , this . actor . characteristics [ "wp" ] . bonus ) ;
formula = formula . replace ( "force mentale bonus" , this . actor . characteristics [ "wp" ] . bonus ) ;
2020-11-07 13:46:15 +01:00
} else
2021-07-28 10:46:59 +02:00
formula = formula . replace ( "force mentale" , this . actor . characteristics [ "wp" ] . value ) ;
2020-11-07 13:46:15 +01:00
}
2021-07-25 10:05:59 +02:00
2020-11-07 13:46:15 +01:00
// Iterate through characteristics
2021-07-28 10:46:59 +02:00
for ( let ch in this . actor . characteristics )
2020-11-07 13:46:15 +01:00
{
// If formula includes characteristic name
2021-07-28 10:46:59 +02:00
while ( formula . includes ( this . actor . characteristics [ ch ] . label . toLowerCase ( ) ) )
2020-11-07 13:46:15 +01:00
{
// Determine if it's looking for the bonus or the value
if ( formula . includes ( 'bonus' ) ) {
2021-07-28 10:46:59 +02:00
formula = formula . replace ( "bonus de " + game . wfrp4e . config . characteristics [ ch ] . toLowerCase ( ) , this . actor . characteristics [ ch ] . bonus ) ;
formula = formula . replace ( game . wfrp4e . config . characteristics [ ch ] . toLowerCase ( ) + " bonus" , this . actor . characteristics [ ch ] . bonus ) ;
2020-11-07 13:46:15 +01:00
}
else
2021-07-28 10:46:59 +02:00
formula = formula . replace ( game . wfrp4e . config . characteristics [ ch ] . toLowerCase ( ) , this . actor . characteristics [ ch ] . value ) ;
2020-11-07 13:46:15 +01:00
}
}
2021-07-25 10:05:59 +02:00
return eval ( formula ) ;
}
catch ( e ) {
throw ui . notifications . error ( "Error: could not parse spell damage. See console for details" )
}
}
2020-11-13 14:52:23 +01:00
/*---------------------------------------------------------------------*/
2021-07-25 10:05:59 +02:00
game . wfrp4e . entities . ItemWfrp4e . prototype . computeSpellPrayerFormula = function ( type , aoe = false , formulaOverride ) {
let formula = formulaOverride || this [ type ] ? . value
if ( Number . isNumeric ( formula ) )
return formula
2020-11-07 13:46:15 +01:00
//console.log("Compute FR")
formula = formula . toLowerCase ( ) ;
// Do not process these special values
if ( formula != game . i18n . localize ( "You" ) . toLowerCase ( ) && formula != game . i18n . localize ( "Special" ) . toLowerCase ( ) && formula != game . i18n . localize ( "Instant" ) . toLowerCase ( ) )
{
// Specific case, to avoid wrong matching with "Force"
if ( formula . includes ( "force mentale" ) )
{
// Determine if it's looking for the bonus or the value
if ( formula . includes ( 'bonus' ) ) {
2021-07-28 10:46:59 +02:00
formula = formula . replace ( "bonus de force mentale" , this . actor . characteristics [ "wp" ] . bonus ) ;
formula = formula . replace ( "force mentale bonus" , this . actor . characteristics [ "wp" ] . bonus ) ;
2020-11-07 13:46:15 +01:00
}
else
2021-07-28 10:46:59 +02:00
formula = formula . replace ( "force mentale" , this . actor . characteristics [ "wp" ] . value ) ;
2020-11-07 13:46:15 +01:00
}
if ( formula . includes ( "yard" ) )
formula = formula . replace ( 'yard' , "mètre" ) ;
if ( formula . includes ( "yds" ) )
formula = formula . replace ( 'yds' , "m." ) ;
// Iterate through remaining characteristics
2021-07-28 10:46:59 +02:00
for ( let ch in this . actor . characteristics )
2020-11-07 13:46:15 +01:00
{
// If formula includes characteristic name
//console.log("Testing :", ch, WFRP4E.characteristics[ch].toLowerCase());
if ( formula . includes ( game . wfrp4e . config . characteristics [ ch ] . toLowerCase ( ) ) )
{
// Determine if it's looking for the bonus or the value
if ( formula . includes ( 'bonus' ) ) {
2021-07-28 10:46:59 +02:00
formula = formula . replace ( "bonus de " + game . wfrp4e . config . characteristics [ ch ] . toLowerCase ( ) , this . actor . characteristics [ ch ] . bonus ) ;
formula = formula . replace ( game . wfrp4e . config . characteristics [ ch ] . toLowerCase ( ) + " bonus" , this . actor . characteristics [ ch ] . bonus ) ;
2020-11-07 13:46:15 +01:00
}
else
2021-07-28 10:46:59 +02:00
formula = formula . replace ( game . wfrp4e . config . characteristics [ ch ] . toLowerCase ( ) , this . actor . characteristics [ ch ] . value ) ;
2020-11-07 13:46:15 +01:00
}
}
}
// If AoE - wrap with AoE ( )
if ( aoe )
formula = "AoE (" + formula . capitalize ( ) + ")" ;
2021-02-06 21:50:08 +01:00
//console.log("calculateSpellAttributes -> " + formula );
2020-11-07 13:46:15 +01:00
return formula . capitalize ( ) ;
}
2020-11-13 14:52:23 +01:00
/*---------------------------------------------------------------------*/
// Converters area
2020-03-25 20:37:09 +01:00
if ( typeof Babele !== 'undefined' ) {
Babele . get ( ) . register ( {
module : 'WH4-fr-translation' ,
lang : 'fr' ,
dir : 'compendium'
} ) ;
2020-07-04 21:48:40 +02:00
2020-03-30 23:23:21 +02:00
Babele . get ( ) . registerConverters ( {
2021-06-29 09:57:36 +02:00
2020-03-31 09:03:19 +02:00
"career_skills" : ( skills _list ) => {
2020-11-10 15:01:06 +01:00
//console.log( "Thru here ...", compendium, skills_list);
2020-05-05 09:21:03 +02:00
if ( skills _list ) {
var i ;
var len = skills _list . length ;
var re = /(.*)\((.*)\)/i ;
for ( i = 0 ; i < len ; i ++ ) {
2021-04-29 09:01:22 +02:00
skills _list [ i ] = skills _list [ i ] . trim ( ) ;
2021-06-29 09:57:36 +02:00
var transl = game . babele . translate ( compmod + '.skills' , { name : skills _list [ i ] } , true ) . name ;
2020-05-05 09:21:03 +02:00
//console.log("List ...", skills_list[i]);
if ( transl == skills _list [ i ] ) {
2021-04-29 09:01:22 +02:00
var res = re . exec ( skills _list [ i ] ) ;
2020-05-05 09:21:03 +02:00
if ( res ) {
//console.log("Matched/split:", res[1], res[2]);
var subword = game . i18n . localize ( res [ 2 ] . trim ( ) ) ;
var s1 = res [ 1 ] . trim ( ) + " ()" ;
2021-06-29 09:57:36 +02:00
var translw = game . babele . translate ( compmod + '.skills' , { name : s1 } , true ) . name ;
2020-05-05 09:21:03 +02:00
if ( translw != s1 ) {
var res2 = re . exec ( translw ) ;
transl = res2 [ 1 ] + "(" + subword + ")" ;
} else {
s1 = res [ 1 ] . trim ( ) + " ( )" ;
2021-06-29 09:57:36 +02:00
translw = game . babele . translate ( compmod + '.skills' , { name : s1 } , true ) . name ;
2020-05-05 09:21:03 +02:00
var res2 = re . exec ( translw ) ;
transl = res2 [ 1 ] + "(" + subword + ")" ;
}
}
2020-03-30 23:23:21 +02:00
}
2020-05-05 09:21:03 +02:00
skills _list [ i ] = transl ;
2020-03-30 23:23:21 +02:00
}
}
2020-04-26 18:38:43 +02:00
return skills _list ;
2020-03-30 23:23:21 +02:00
} ,
2021-06-29 09:57:36 +02:00
2020-11-10 15:01:06 +01:00
"npc_details" : ( details ) => {
//console.log("DETAILS: ", details);
let newDetails = duplicate ( details ) ;
2020-11-12 16:35:30 +01:00
if ( details . species && details . species . value )
2020-11-11 19:08:20 +01:00
newDetails . species . value = game . i18n . localize ( details . species . value ) ;
2020-11-12 16:35:30 +01:00
if ( details . gender && details . gender . value )
2020-11-11 19:08:20 +01:00
newDetails . gender . value = game . i18n . localize ( details . gender . value ) ;
if ( details . class && details . class . value )
newDetails . class . value = game . i18n . localize ( details . class . value ) ;
2020-11-10 15:01:06 +01:00
return newDetails ;
} ,
2021-06-29 09:57:36 +02:00
2020-03-30 23:23:21 +02:00
"career_talents" : ( talents _list ) => {
2020-06-30 18:37:02 +02:00
var compendium = game . packs . find ( p => p . collection === compmod + '.talents' ) ;
2020-03-30 23:23:21 +02:00
var i ;
2020-05-05 09:21:03 +02:00
if ( talents _list ) {
var len = talents _list . length ;
var re = /(.*)\((.*)\)/i ;
for ( i = 0 ; i < len ; i ++ ) {
2021-06-29 09:57:36 +02:00
var transl = game . babele . translate ( compmod + '.talents' , { name : talents _list [ i ] } , true ) . name ;
2020-05-05 09:21:03 +02:00
if ( transl == talents _list [ i ] ) {
var res = re . exec ( talents _list [ i ] ) ;
if ( res ) {
//console.log("Matched/split:", res[1], res[2]);
var subword = game . i18n . localize ( res [ 2 ] . trim ( ) ) ;
var s1 = res [ 1 ] . trim ( ) ; // No () in talents table
2021-06-29 09:57:36 +02:00
var translw = game . babele . translate ( compmod + '.talents' , { name : s1 } , true ) . name ;
2020-05-05 09:21:03 +02:00
if ( translw != s1 ) {
transl = translw + "(" + subword + ")" ;
} else {
s1 = res [ 1 ] . trim ( ) + " ( )" ;
2021-06-29 09:57:36 +02:00
translw = game . babele . translate ( compmod + '.talents' , { name : s1 } , true ) . name ;
2020-05-05 09:21:03 +02:00
var res2 = re . exec ( translw ) ;
transl = res2 [ 1 ] + "(" + subword + ")" ;
}
}
2020-03-30 23:23:21 +02:00
}
2020-05-05 09:21:03 +02:00
talents _list [ i ] = transl ;
2020-03-30 23:23:21 +02:00
}
}
return talents _list ;
2020-03-31 09:27:04 +02:00
} ,
2020-04-23 11:52:39 +02:00
"npc_characteristics" : ( chars ) => { // Auto-convert char names in the sheet
for ( var key in chars ) {
2020-06-03 18:30:03 +02:00
var char = chars [ key ] ;
//console.log("Was here !", key, char );
2020-04-23 11:52:39 +02:00
var abrev = char [ "abrev" ] ;
2020-06-06 13:27:59 +02:00
let toTransl = "CHAR." + abrev ;
if ( game . i18n . localize ( toTransl ) != toTransl ) { // Manages unknown language
char [ "label" ] = game . i18n . localize ( "CHAR." + abrev ) ;
char [ "abrev" ] = game . i18n . localize ( "CHARAbbrev." + abrev ) ;
}
2020-04-23 11:52:39 +02:00
}
return chars ;
} ,
2020-11-08 23:12:52 +01:00
"bestiary_traits" : ( beast _traits , translations ) => {
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
}
2021-06-29 09:57:36 +02:00
var trait _fr = game . babele . translate ( compmod + '.traits' , { name : name _en } , true ) ;
//console.log(">>>>> Trait ?", name_en, nbt, trait_fr, trait_fr.name, special);
2020-11-08 23:12:52 +01:00
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 ;
2021-10-22 15:21:12 +02:00
} else if ( game . modules . get ( 'wfrp4e-eis' ) ) { // No description in the FR compendium -> test other compendium if presenr
trait _fr = game . babele . translate ( 'wfrp4e-eis.eisitems' , { name : name _en } , true ) ;
2020-12-02 22:15:26 +01:00
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 ;
2020-11-08 23:12:52 +01:00
}
if ( trait _en . data && trait _en . data . specification && 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
}
2021-06-29 09:57:36 +02:00
var trait _fr = game . babele . translate ( compmod + '.skills' , { name : name _en } , true ) ;
2020-11-08 23:12:52 +01:00
//console.log(">>>>> Skill ?", name_en, special, trait_fr.name, trait_fr);
2021-06-29 09:57:36 +02:00
if ( trait _fr . name != name _en ) { // Translation OK
2020-11-08 23:12:52 +01:00
trait _en . name = trait _fr . name + special ;
if ( trait _fr . data ) {
trait _en . data . description . value = trait _fr . data . description . value ;
}
}
2021-06-29 09:57:36 +02:00
2020-11-08 23:12:52 +01:00
} else if ( trait _en . type == "prayer" ) {
2021-06-29 09:57:36 +02:00
var trait _fr = game . babele . translate ( compmod + '.prayers' , { name : name _en } , true ) ;
2020-11-08 23:12:52 +01:00
//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 ;
2021-06-29 09:57:36 +02:00
2020-11-08 23:12:52 +01:00
} else if ( trait _en . type == "spell" ) {
2021-06-29 09:57:36 +02:00
var trait _fr = game . babele . translate ( compmod + '.spells' , { name : name _en } , true ) ;
if ( trait _fr . name == name _en ) { // If no translation, test eisspells
2021-10-22 15:21:12 +02:00
trait _fr = game . babele . translate ( 'wfrp4e-eis.eisspells' , { name : name _en } , true ) ;
2020-11-08 23:12:52 +01:00
}
2021-06-29 09:57:36 +02:00
if ( trait _fr . name == name _en ) { // If no translation, test unofficial grimoire
trait _fr = game . babele . translate ( 'wfrp4e-unofficial-grimoire.ug-spells' , { name : name _en } , true ) ;
2020-11-08 23:12:52 +01:00
}
//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
}
2021-06-29 09:57:36 +02:00
var trait _fr = game . babele . translate ( compmod + '.talents' , { name : name _en } , true ) ;
2020-11-08 23:12:52 +01:00
//console.log(">>>>> Talent ?", name_en, special, trait_fr.name);
2021-06-29 09:57:36 +02:00
if ( trait _fr . name == name _en ) { // If no translation, test ugtalents
trait _fr = game . babele . translate ( 'wfrp4e-unofficial-grimoire.ug-careerstalentstraits' , { name : name _en } , true ) ;
2020-11-08 23:12:52 +01:00
}
2021-06-29 09:57:36 +02:00
if ( trait _fr . name != name _en ) { // Talent translated!
2020-11-08 23:12:52 +01:00
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" ) {
2021-06-29 09:57:36 +02:00
var career _fr = game . babele . translate ( compmod + '.careers' , trait _en , true ) ;
2020-11-10 15:01:06 +01:00
console . log ( ">>>>> Career ?" , name _en , career _fr . name ) ;
trait _en . name = career _fr . name ;
trait _en . data = duplicate ( career _fr . data ) ;
2020-11-08 23:12:52 +01:00
} else if ( trait _en . type == "trapping" || trait _en . type == "weapon" || trait _en . type == "armour" || trait _en . type == "container" || trait _en . type == "money" ) {
2021-06-29 09:57:36 +02:00
var trapping _fr = game . babele . translate ( compmod + '.trappings' , trait _en , true ) ;
2020-11-08 23:12:52 +01:00
//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 ;
2020-04-21 21:47:05 +02:00
} ,
2020-03-31 09:27:04 +02:00
// To avoid duplicateing class for all careers
2020-03-31 17:44:46 +02:00
"generic_localization" : ( value ) => {
2020-04-01 00:41:20 +02:00
if ( value )
return game . i18n . localize ( value . trim ( ) ) ;
2020-04-10 15:11:26 +02:00
} ,
2020-04-01 00:41:20 +02:00
"trapping_qualities_flaws" : ( value ) => {
if ( value ) {
2021-07-08 13:46:30 +02:00
let newQF = [ ] ;
2021-07-29 22:53:35 +02:00
//console.log("ATOUTS", value);
2020-04-01 00:41:20 +02:00
var i = 0 ;
2021-07-08 13:46:30 +02:00
//var re = /(.*) (\d+)/i;
for ( i = 0 ; i < value . length ; i ++ ) {
newQF [ i ] = duplicate ( value [ i ] ) ;
if ( newQF [ i ] . name == "Trap Blade" ) {
newQF [ i ] . name = "TrapBlade" ; // Auto-patch, without space!
2020-06-19 00:26:15 +02:00
//console.log("PATCHED", trim);
2020-04-01 00:41:20 +02:00
}
2021-07-08 13:46:30 +02:00
newQF [ i ] . name = game . i18n . localize ( newQF [ i ] . name ) ;
2020-03-31 17:44:46 +02:00
}
2021-07-08 13:46:30 +02:00
return newQF ;
2020-03-31 17:44:46 +02:00
}
} ,
2020-03-31 09:27:04 +02:00
// Search back in careers the translated name of the groupe (as it is the name of the level career itself)
"career_careergroup" : ( value ) => {
2020-10-06 08:25:51 +02:00
// Manage exception - Dirty hack
2020-07-03 11:38:38 +02:00
if ( value == 'Slayer' ) {
2021-06-10 21:27:40 +02:00
return "Tueur Nains" ;
2020-07-03 11:38:38 +02:00
}
2020-10-06 08:25:51 +02:00
if ( value == 'Druidic Priest' ) {
return "Druide" ;
}
2020-07-03 11:38:38 +02:00
// Per default
2020-06-29 07:44:16 +02:00
var compendium = game . packs . find ( p => p . collection === compmod + '.careers' ) ;
2020-11-08 23:12:52 +01:00
if ( compendium )
2021-06-29 09:57:36 +02:00
return game . babele . translate ( compmod + '.careers' , { name : value } ) . name ;
2020-11-08 23:12:52 +01:00
else
ui . notifications . error ( "Impossible de trouver la carrière " + value + ". Elle n'est probablement pas traduite." , { permanent : true } )
2020-04-10 15:11:26 +02:00
} ,
2020-06-21 22:28:51 +02:00
"mutations_modifier" : ( value ) => { // This is really UGLYYYY i know, but i started like this and discovered afterward that many strings were not easy to automate... Sorry :)
2020-06-14 21:22:07 +02:00
//console.log("Parsing mutation :", value);
2020-06-13 23:09:11 +02:00
value = value . toLowerCase ( ) ;
2020-06-21 22:28:51 +02:00
value = value . replace ( "gain a broken condition if you fail a test derived from " , "Gagnez un état Brisé si vous échouez à un test dérivé de " ) ;
2020-06-13 23:09:11 +02:00
value = value . replace ( "weapon skill" , "Capacité de Combat" ) ;
value = value . replace ( "ballistic skill" , "Capacité de Tir" ) ;
value = value . replace ( "strength" , "Force" ) ;
value = value . replace ( "toughness" , "Endurance" ) ;
value = value . replace ( "agility" , "Agilité" ) ;
value = value . replace ( "dexterity" , "Dextérité" ) ;
value = value . replace ( "willpower" , "Force Mentale" ) ;
value = value . replace ( "fellowship" , "Sociabilité" ) ;
value = value . replace ( "initiative" , "Initiative" ) ;
value = value . replace ( "intelligence" , "Intelligence" ) ;
2020-06-21 22:28:51 +02:00
value = value . replace ( "armor points to the head" , "PA à la Tête" ) ;
value = value . replace ( "subject to frenzy" , "Sujet à la Frénésie" ) ;
value = value . replace ( "you do not scar" , "Aucune cicatrice" ) ;
value = value . replace ( "movement" , "Mouvement" ) ;
value = value . replace ( "armor points to all locations" , "PA sur tout le corps" ) ;
value = value . replace ( "to any test when alone" , "à tout les tests lorsque seul" ) ;
value = value . replace ( "track" , "Pistage" ) ;
value = value . replace ( "to any test not hurting another" , "à tout les Tests n'aggressant pas autrui" ) ;
value = value . replace ( "on tests to hurt" , "pour les tests impliquant une agression" )
value = value . replace ( "to all language tests when speaking" , "à tout les Tests de Langue lorsque vous parlez" ) ;
value = value . replace ( "on perception tests involving sight" , "aux Tests de Perception impliquant la Vue" ) ;
value = value . replace ( "to all Sociabilité tests" , "à tout les Tests de Sociabilité" ) ;
2020-06-13 23:09:11 +02:00
return value ;
} ,
2021-02-06 21:50:08 +01:00
"talent_name" : ( name , translation ) => {
console . log ( "NAME !!!" , name , translation ) ;
} ,
"effects" : ( effects , translations ) => {
2021-02-08 22:03:29 +01:00
if ( ! effects ) return ;
2021-05-06 21:51:06 +02:00
if ( ! translations ) return ;
2021-02-06 21:50:08 +01:00
for ( let i = 0 ; i < effects . length ; i ++ ) {
let effect = effects [ i ] ;
2021-05-06 21:51:06 +02:00
//console.log("EFFECT LABEL1:", effect );
2021-02-06 21:50:08 +01:00
effect . label = translations [ 'label' + i ] ;
}
return effects
} ,
"diseases_effects" : ( effects , translations ) => {
2021-02-08 22:03:29 +01:00
if ( ! effects ) return ;
2021-02-06 21:50:08 +01:00
for ( let i = 0 ; i < effects . length ; i ++ ) {
let effect = effects [ i ] ;
let label = effect . label ;
let gravity = "" ;
if ( label . includes ( "(" ) && label . includes ( ")" ) ) { // Then process specific skills name with (xxxx) inside
var re = /(.*) +\((.*)\)/i ;
var res = re . exec ( label ) ;
label = res [ 1 ] . trim ( ) ; // Get the gravity
gravity = " (" + game . i18n . localize ( res [ 2 ] . trim ( ) ) + ")" ; // And the special keyword
}
effect . label = game . i18n . localize ( label ) + gravity ;
}
} ,
2020-04-10 15:11:26 +02:00
// Auto-translate duration
"spells_duration_range_target_damage" : ( value ) => {
2020-04-10 17:36:32 +02:00
//console.log("Spell duration/range/damage/target :", value);
2020-04-10 15:11:26 +02:00
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 ;
2020-03-31 17:44:46 +02:00
}
2020-03-30 23:23:21 +02:00
} ) ;
2020-03-27 23:12:43 +01:00
}
2020-03-25 21:03:36 +01:00
} ) ;
2020-04-12 08:59:47 +02:00