Fix spell damage parsing + EiS actors
This commit is contained in:
@@ -22,13 +22,82 @@ const vo_conditions = {
|
||||
}
|
||||
|
||||
const __SELECT_BONUS_PREFIX_D = {
|
||||
"initiative" : 1,
|
||||
"intelligence" : 1,
|
||||
"endurance" : 1,
|
||||
"initiative": 1,
|
||||
"intelligence": 1,
|
||||
"endurance": 1,
|
||||
"agilite": 1,
|
||||
"agilité": 1
|
||||
}
|
||||
|
||||
/************************************************************************************/
|
||||
export class WFRP4FrTranslation {
|
||||
|
||||
static parseSpellContent(spell) {
|
||||
if (spell.system.range?.value) {
|
||||
spell.system.range.value = this.processSpellContent(spell.system.range.value)
|
||||
}
|
||||
if (spell.system.damage?.value) {
|
||||
spell.system.damage.value = this.processSpellContent(spell.system.damage.value)
|
||||
}
|
||||
if (spell.system.duration?.value) {
|
||||
spell.system.duration.value = this.processSpellContent(spell.system.duration?.value)
|
||||
}
|
||||
if ( spell.system.range?.value) {
|
||||
spell.system.range.value = this.processSpellContent(spell.system.range?.value)
|
||||
}
|
||||
if (spell.system.target?.value ) {
|
||||
spell.system.target.value = this.processSpellContent(spell.system.target?.value)
|
||||
}
|
||||
}
|
||||
|
||||
static processSpellContent(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 !
|
||||
let translw = value;
|
||||
let re = /(.*)\s+[Bb]onus\s*(\w*)/i;
|
||||
let res = re.exec(value);
|
||||
//console.log("RES1:", res);
|
||||
let unit = "";
|
||||
if (res) { // Test "<charac> Bonus <unit>" pattern
|
||||
if (res[1]) { // We have char name, then convert it
|
||||
translw = game.i18n.localize(res[1].trim());
|
||||
let bonusPrefix = (translw.toLowerCase() in __SELECT_BONUS_PREFIX_D) ? "Bonus d'" : "Bonus de ";
|
||||
translw = bonusPrefix + translw
|
||||
}
|
||||
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";
|
||||
if (unit == "Bonus") { // Another weird management
|
||||
console.log("Translating bonus", unit);
|
||||
translw = "Bonus de " + translw;
|
||||
} else {
|
||||
translw += " " + unit;
|
||||
}
|
||||
return translw;
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************************/
|
||||
Hooks.once('init', () => {
|
||||
|
||||
@@ -267,7 +336,7 @@ Hooks.once('init', () => {
|
||||
console.log("Search talent name:", compData.metadata.id, s1, translw);
|
||||
if (translw && translw != s1) {
|
||||
transl = translw + " (" + subword + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
talents_list[i] = transl;
|
||||
@@ -358,6 +427,7 @@ Hooks.once('init', () => {
|
||||
let trait_fr = game.babele.translate(compData.metadata.id, { name: name_en }, true)
|
||||
if (trait_fr?.system) {
|
||||
//DEBUG : console.log(">>>>> Prayer ?", name_en, special, trait_fr.name );
|
||||
WFRP4FrTranslation.parseSpellContent(trait_en)
|
||||
trait_fr.name = trait_fr.name || name_en
|
||||
trait_en.name = trait_fr.name + special;
|
||||
if (trait_fr.system?.description?.value) {
|
||||
@@ -370,9 +440,10 @@ Hooks.once('init', () => {
|
||||
let validCompendiums = game.wfrp4e.tags.getPacksWithTag("spell")
|
||||
for (let compData of validCompendiums) {
|
||||
let trait_fr = game.babele.translate(compData.metadata.id, { name: name_en }, true)
|
||||
if (trait_fr?.system) {
|
||||
if (trait_fr?.system) {
|
||||
//DEBUG : console.log(">>>>> Spell ?", name_en, special, trait_fr);
|
||||
WFRP4FrTranslation.parseSpellContent(trait_en)
|
||||
trait_fr.name = trait_fr.name || name_en
|
||||
//DEBUG : console.log(">>>>> Spell ?", name_en, special, trait_fr.name );
|
||||
trait_en.name = trait_fr.name + special;
|
||||
if (trait_fr.system?.description?.value) {
|
||||
trait_en.system.description.value = trait_fr.system.description.value;
|
||||
@@ -544,52 +615,9 @@ Hooks.once('init', () => {
|
||||
},
|
||||
// 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 !
|
||||
let translw = value;
|
||||
let re = /(.*)\s+Bonus\s*(\w*)/i;
|
||||
let res = re.exec(value);
|
||||
// DEBUG : console.log("RES1:", res);
|
||||
let unit = "";
|
||||
if (res) { // Test "<charac> Bonus <unit>" pattern
|
||||
if (res[1]) { // We have char name, then convert it
|
||||
translw = game.i18n.localize(res[1].trim());
|
||||
let bonusPrefix = (translw.toLowerCase() in __SELECT_BONUS_PREFIX_D) ? "Bonus d'" : "Bonus de ";
|
||||
translw = bonusPrefix + translw
|
||||
}
|
||||
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";
|
||||
if (unit == "Bonus") { // Another weird management
|
||||
console.log("Translating bonus", unit);
|
||||
translw = "Bonus de " + translw;
|
||||
} else {
|
||||
translw += " " + unit;
|
||||
}
|
||||
return translw;
|
||||
return WFRP4FrTranslation.processSpellContent(value);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
@@ -598,10 +626,10 @@ Hooks.once('init', () => {
|
||||
/*---------------------------------------------------------------------*/
|
||||
Hooks.once('ready', () => {
|
||||
|
||||
import("https://www.uberwald.me/fvtt_appcount/count-class-ready.js").then(moduleCounter=>{
|
||||
import("https://www.uberwald.me/fvtt_appcount/count-class-ready.js").then(moduleCounter => {
|
||||
console.log("ClassCounter loaded", moduleCounter)
|
||||
moduleCounter.ClassCounter.registerUsageCount("wh4-fr-translation")
|
||||
}).catch(err=>
|
||||
}).catch(err =>
|
||||
console.log("No stats available, giving up.")
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user