Minor fixes + compute function

This commit is contained in:
sladecraven 2021-07-25 10:05:59 +02:00
parent 8e80c7a005
commit e6e1cbd073
3 changed files with 26 additions and 77 deletions

View File

@ -38,74 +38,14 @@ Hooks.once('init', () => {
} }
/*---------------------------------------------------------------------*/ /*---------------------------------------------------------------------*/
game.wfrp4e.utility.handleConditionClick = function(event) { game.wfrp4e.entities.ItemWfrp4e.prototype.computeSpellDamage = function(formula, isMagicMissile) {
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 { 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);
}
/*---------------------------------------------------------------------*/
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(); formula = formula.toLowerCase();
if (isMagicMissile) // If it's a magic missile, damage includes willpower bonus 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" // Specific case, to avoid wrong matching with "Force"
@ -140,12 +80,19 @@ Hooks.once('init', () => {
} }
} }
//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") //console.log("Compute FR")
let actorData = this.data let actorData = this.data
formula = formula.toLowerCase(); formula = formula.toLowerCase();

View File

@ -561,7 +561,8 @@
"CHAT.CommandLine.Help.Corruption.Usage.Command" : "/corruption", "CHAT.CommandLine.Help.Corruption.Usage.Command" : "/corruption",
"CHAT.CommandLine.Help.Corruption.Usage.Example" : "<br>/corruption minor<br>/corruption moderate", "CHAT.CommandLine.Help.Corruption.Usage.Example" : "<br>/corruption minor<br>/corruption moderate",
"CHAT.CommandLine.Help.Corruption.Usage.Note" : "Utilisez cette commande pour demander à vos joueurs de faire un jet contres les influences corruptrices.", "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 <b>Test de Résistance Trés Facile (+60)</b> ou recevoir une @Compendium[wfrp4e-core.diseases.1hQuVFZt9QnnbWzg]{Infection Mineure}.",
"CHAT.TestModifiers.AttackingLarger": "Bonus de +10 à <b>{attacker}</b>pour l'attaque d'une créature plus grande", "CHAT.TestModifiers.AttackingLarger": "Bonus de +10 à <b>{attacker}</b>pour l'attaque d'une créature plus grande",
"CHAT.TestModifiers.WeaponLength": "Pénalité de -10 à <b>{attacker}</b> à cause d'une arme plus courte.", "CHAT.TestModifiers.WeaponLength": "Pénalité de -10 à <b>{attacker}</b> à cause d'une arme plus courte.",
"CHAT.TestModifiers.ShootingLarger": "Bonus de +{bonus} à <b>{attacker}</b> pour tir sur une cible plus grande", "CHAT.TestModifiers.ShootingLarger": "Bonus de +{bonus} à <b>{attacker}</b> pour tir sur une cible plus grande",
@ -1410,6 +1411,7 @@
"Home": "Revenir à la maison", "Home": "Revenir à la maison",
"Male": "Homme", "Male": "Homme",
"Female": "Femme", "Female": "Femme",
"Update": "Mise à jour",
"TRAVEL.TravelMessageBase": "De <b>{from}</b> à <b>{to}</b> : ", "TRAVEL.TravelMessageBase": "De <b>{from}</b> à <b>{to}</b> : ",
"TRAVEL.TravelMessageRoad": "<br><b>Route</b> : {road_distance} km<br>&nbsp;&nbsp;En chariot : {road_days} jours, danger {road_danger_string}<br>&nbsp;&nbsp;A Cheval : {road_horse_heavy_days} jours, danger {road_danger_string}<br>&nbsp;&nbsp;A Cheval (Rapide) : {road_horse_fast_days} jours, danger {road_danger_string}<br>&nbsp;&nbsp;A Pied : {road_feet_days} jours, danger {road_danger_feet_string}", "TRAVEL.TravelMessageRoad": "<br><b>Route</b> : {road_distance} km<br>&nbsp;&nbsp;En chariot : {road_days} jours, danger {road_danger_string}<br>&nbsp;&nbsp;A Cheval : {road_horse_heavy_days} jours, danger {road_danger_string}<br>&nbsp;&nbsp;A Cheval (Rapide) : {road_horse_fast_days} jours, danger {road_danger_string}<br>&nbsp;&nbsp;A Pied : {road_feet_days} jours, danger {road_danger_feet_string}",

View File

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