Fix spells computations

This commit is contained in:
sladecraven 2021-07-28 10:46:59 +02:00
parent 69551f3499
commit 4bf5b4ec0f
2 changed files with 17 additions and 18 deletions

View File

@ -76,7 +76,7 @@ Hooks.once('init', () => {
// Specific case, to avoid wrong matching with "Force"
if (formula.includes("toughness bonus")) {
formula = formula.replace( "toughness bonus", actorData.data.characteristics["t"].bonus);
formula = formula.replace( "toughness bonus", this.actor.characteristics["t"].bonus);
}
// Specific case, to avoid wrong matching with "Force"
@ -84,25 +84,25 @@ Hooks.once('init', () => {
{
// Determine if it's looking for the bonus or the value
if (formula.includes('bonus')) {
formula = formula.replace( "bonus de force mentale", actorData.data.characteristics["wp"].bonus);
formula = formula.replace( "force mentale bonus", actorData.data.characteristics["wp"].bonus);
formula = formula.replace( "bonus de force mentale", this.actor.characteristics["wp"].bonus);
formula = formula.replace( "force mentale bonus", this.actor.characteristics["wp"].bonus);
} else
formula = formula.replace("force mentale", actorData.data.characteristics["wp"].value);
formula = formula.replace("force mentale", this.actor.characteristics["wp"].value);
}
// Iterate through characteristics
for(let ch in actorData.data.characteristics)
for(let ch in this.actor.characteristics)
{
// If formula includes characteristic name
while (formula.includes(actorData.data.characteristics[ch].label.toLowerCase()))
while (formula.includes(this.actor.characteristics[ch].label.toLowerCase()))
{
// Determine if it's looking for the bonus or the value
if (formula.includes('bonus')) {
formula = formula.replace("bonus de " + game.wfrp4e.config.characteristics[ch].toLowerCase(), actorData.data.characteristics[ch].bonus);
formula = formula.replace(game.wfrp4e.config.characteristics[ch].toLowerCase() + " bonus", actorData.data.characteristics[ch].bonus);
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);
}
else
formula = formula.replace(game.wfrp4e.config.characteristics[ch].toLowerCase(), actorData.data.characteristics[ch].value);
formula = formula.replace(game.wfrp4e.config.characteristics[ch].toLowerCase(), this.actor.characteristics[ch].value);
}
}
@ -120,7 +120,6 @@ Hooks.once('init', () => {
return formula
//console.log("Compute FR")
let actorData = this.data
formula = formula.toLowerCase();
// Do not process these special values
@ -131,18 +130,18 @@ Hooks.once('init', () => {
{
// Determine if it's looking for the bonus or the value
if (formula.includes('bonus')) {
formula = formula.replace( "bonus de force mentale", actorData.data.characteristics["wp"].bonus);
formula = formula.replace( "force mentale bonus", actorData.data.characteristics["wp"].bonus);
formula = formula.replace( "bonus de force mentale", this.actor.characteristics["wp"].bonus);
formula = formula.replace( "force mentale bonus", this.actor.characteristics["wp"].bonus);
}
else
formula = formula.replace("force mentale", actorData.data.characteristics["wp"].value);
formula = formula.replace("force mentale", this.actor.characteristics["wp"].value);
}
if (formula.includes("yard") )
formula = formula.replace('yard', "mètre" );
if (formula.includes("yds") )
formula = formula.replace('yds', "m." );
// Iterate through remaining characteristics
for(let ch in actorData.data.characteristics)
for(let ch in this.actor.characteristics)
{
// If formula includes characteristic name
//console.log("Testing :", ch, WFRP4E.characteristics[ch].toLowerCase());
@ -150,11 +149,11 @@ Hooks.once('init', () => {
{
// Determine if it's looking for the bonus or the value
if (formula.includes('bonus')) {
formula = formula.replace("bonus de " + game.wfrp4e.config.characteristics[ch].toLowerCase(), actorData.data.characteristics[ch].bonus);
formula = formula.replace(game.wfrp4e.config.characteristics[ch].toLowerCase() + " bonus", actorData.data.characteristics[ch].bonus);
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);
}
else
formula = formula.replace(game.wfrp4e.config.characteristics[ch].toLowerCase(), actorData.data.characteristics[ch].value);
formula = formula.replace(game.wfrp4e.config.characteristics[ch].toLowerCase(), this.actor.characteristics[ch].value);
}
}
}

View File

@ -2,7 +2,7 @@
"name": "WH4-fr-translation",
"title": "WFRP4e - Core Module en français.",
"description": "Traduction Française pour Warhammer v4.",
"version": "4.0.10",
"version": "4.0.11",
"minimumCoreVersion" : "0.8.0",
"compatibleCoreVersion": "0.8.8",
"author": "LeRatierBretonnien",