From e6e1cbd07352a258debbdcaa120806e267126891 Mon Sep 17 00:00:00 2001 From: sladecraven Date: Sun, 25 Jul 2021 10:05:59 +0200 Subject: [PATCH] Minor fixes + compute function --- babele-register.js | 97 +++++++++++----------------------------------- fr.json | 4 +- module.json | 2 +- 3 files changed, 26 insertions(+), 77 deletions(-) diff --git a/babele-register.js b/babele-register.js index 08e82d3..30799b9 100644 --- a/babele-register.js +++ b/babele-register.js @@ -36,83 +36,23 @@ Hooks.once('init', () => { game.wfrp4e.apps.StatBlockParser.parseStatBlock = async function( statString, type = "npc") { 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 = `${condName}
${condDescr}` - - let chatData = game.wfrp4e.utility.chatDataSetup(messageContent) - ChatMessage.create(chatData); - } - - /*---------------------------------------------------------------------*/ - game.wfrp4e.entities.ActorWfrp4e.prototype.calculateRangeOrDamage = function(formula) - { - //console.log("FR function calculateRangeOrDamage !", formula); - let actorData = this.data - try - { - formula = formula.toLowerCase(); - // Iterate through characteristics - for(let ch in actorData.data.characteristics) - { - // Determine if the formula includes the characteristic's abbreviation + B (SB, WPB, etc.) - if (formula.includes(ch.concat('b'))) - { - // Replace that abbreviation with the Bonus value - formula = formula.replace(ch.concat('b'), actorData.data.characteristics[ch].bonus.toString()); - } - } - if (formula.includes("yard") ) - formula = formula.replace('yard', "mètre" ); - if (formula.includes("yds") ) - formula = formula.replace('yds', "m." ); - // To evaluate multiplication, replace x with * - formula = formula.replace('x', '*'); - //console.log("FOEM", formula); - return eval(formula); - } - catch - { - //console.log("FOEM2", formula); - return formula; - } - } - - /*---------------------------------------------------------------------*/ - game.wfrp4e.entities.ActorWfrp4e.prototype.calculateSpellDamage = function(formula, isMagicMissile) { - //console.log("Compute FR") - let actorData = this.data - formula = formula.toLowerCase(); + /*---------------------------------------------------------------------*/ + game.wfrp4e.entities.ItemWfrp4e.prototype.computeSpellDamage = function(formula, isMagicMissile) { + try { + + formula = formula.toLowerCase(); + if (isMagicMissile) // If it's a magic missile, damage includes willpower bonus { - formula += "+ " + actorData.data.characteristics["wp"].bonus + formula += "+ " + this.actor.characteristics["wp"].bonus } - + // Specific case, to avoid wrong matching with "Force" if (formula.includes("toughness bonus")) { formula = formula.replace( "toughness bonus", actorData.data.characteristics["t"].bonus); } - + // Specific case, to avoid wrong matching with "Force" if (formula.includes("force mentale")) { @@ -123,7 +63,7 @@ Hooks.once('init', () => { } else formula = formula.replace("force mentale", actorData.data.characteristics["wp"].value); } - + // Iterate through characteristics for(let ch in actorData.data.characteristics) { @@ -139,13 +79,20 @@ Hooks.once('init', () => { formula = formula.replace(game.wfrp4e.config.characteristics[ch].toLowerCase(), actorData.data.characteristics[ch].value); } } - - //console.log("calculateSpellDamage -> " + formula ); - return eval(formula); - } + + return eval(formula); + } + catch (e) { + throw ui.notifications.error("Error: could not parse spell damage. See console for details") + } + } /*---------------------------------------------------------------------*/ - game.wfrp4e.entities.ActorWfrp4e.prototype.calculateSpellAttributes = function(formula, aoe=false) { + game.wfrp4e.entities.ItemWfrp4e.prototype.computeSpellPrayerFormula = function(type, aoe=false, formulaOverride) { + let formula = formulaOverride || this[type]?.value + if (Number.isNumeric(formula)) + return formula + //console.log("Compute FR") let actorData = this.data formula = formula.toLowerCase(); diff --git a/fr.json b/fr.json index 2707c77..daa0de7 100644 --- a/fr.json +++ b/fr.json @@ -561,7 +561,8 @@ "CHAT.CommandLine.Help.Corruption.Usage.Command" : "/corruption", "CHAT.CommandLine.Help.Corruption.Usage.Example" : "
/corruption minor
/corruption moderate", "CHAT.CommandLine.Help.Corruption.Usage.Note" : "Utilisez cette commande pour demander à vos joueurs de faire un jet contres les influences corruptrices.", - + "CHAT.EndCombat": "Statut de fin de combat", + "CHAT.InfectionReminder": " Ces personnages ont reçus une blessure critique and doivent réussir un Test de Résistance Trés Facile (+60) ou recevoir une @Compendium[wfrp4e-core.diseases.1hQuVFZt9QnnbWzg]{Infection Mineure}.", "CHAT.TestModifiers.AttackingLarger": "Bonus de +10 à {attacker}pour l'attaque d'une créature plus grande", "CHAT.TestModifiers.WeaponLength": "Pénalité de -10 à {attacker} à cause d'une arme plus courte.", "CHAT.TestModifiers.ShootingLarger": "Bonus de +{bonus} à {attacker} pour tir sur une cible plus grande", @@ -1410,6 +1411,7 @@ "Home": "Revenir à la maison", "Male": "Homme", "Female": "Femme", + "Update": "Mise à jour", "TRAVEL.TravelMessageBase": "De {from} à {to} : ", "TRAVEL.TravelMessageRoad": "
Route : {road_distance} km
  En chariot : {road_days} jours, danger {road_danger_string}
  A Cheval : {road_horse_heavy_days} jours, danger {road_danger_string}
  A Cheval (Rapide) : {road_horse_fast_days} jours, danger {road_danger_string}
  A Pied : {road_feet_days} jours, danger {road_danger_feet_string}", diff --git a/module.json b/module.json index 6a74457..bc6e14f 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.8", + "version": "4.0.9", "minimumCoreVersion" : "0.8.0", "compatibleCoreVersion": "0.8.8", "author": "LeRatierBretonnien",