Minor fixes + compute function
This commit is contained in:
@ -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 = `<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();
|
||||
|
||||
/*---------------------------------------------------------------------*/
|
||||
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();
|
||||
|
Reference in New Issue
Block a user