From 4bf5b4ec0f947b73bd378a5711dd76fd711760ee Mon Sep 17 00:00:00 2001 From: sladecraven Date: Wed, 28 Jul 2021 10:46:59 +0200 Subject: [PATCH] Fix spells computations --- babele-register.js | 33 ++++++++++++++++----------------- module.json | 2 +- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/babele-register.js b/babele-register.js index 209de06..2f72d56 100644 --- a/babele-register.js +++ b/babele-register.js @@ -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); } } } diff --git a/module.json b/module.json index ae0b784..2327b0f 100644 --- a/module.json +++ b/module.json @@ -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",