Prepare for official content

This commit is contained in:
sladecraven 2020-11-05 21:53:12 +01:00
parent 9fa2e404f4
commit d29f9ba1f5
3 changed files with 173 additions and 9 deletions

View File

@ -174,7 +174,7 @@ const _manage_inn_roll = async (content, msg) => {
let command = content.split(" ").map(function(item) { let command = content.split(" ").map(function(item) {
return item.trim(); return item.trim();
}) })
console.log(WFRP_Tables["talents"]); console.log(game.wfrp4e.tables["talents"]);
if (command[0] == "/auberge" && command[1] ) if (command[0] == "/auberge" && command[1] )
{ {
@ -307,7 +307,7 @@ const __check_fix_wrong_modules = ( chatFlag, patchFinished ) => {
} }
} }
}); });
WFRP4E.speciesSkills["gnome"] = [ game.wfrp4e.config.speciesSkills["gnome"] = [
"Focalisation (Ulgu)", "Focalisation (Ulgu)",
"Charme", "Charme",
"Résistance à l'alcool", "Résistance à l'alcool",
@ -321,7 +321,7 @@ const __check_fix_wrong_modules = ( chatFlag, patchFinished ) => {
"Survie en extérieur", "Survie en extérieur",
"Discrétion (Au choix)" "Discrétion (Au choix)"
]; ];
WFRP4E.speciesTalents["gnome"] = [ game.wfrp4e.config.speciesTalents["gnome"] = [
"Insignifiant, Imprégné avec Uglu", "Insignifiant, Imprégné avec Uglu",
"Chance, Imitation", "Chance, Imitation",
"Vision Nocturne", "Vision Nocturne",
@ -421,6 +421,9 @@ Hooks.once('ready', () => {
if ( name == "wfrp4e-content" && module.active) { if ( name == "wfrp4e-content" && module.active) {
compmod = "wfrp4e-content"; compmod = "wfrp4e-content";
} }
if ( name == "wfrp4e-core" && module.active) {
compmod = "wfrp4e-core";
}
} ); } );
__auto_patch_translation_journal_compendium( compmod ) __auto_patch_translation_journal_compendium( compmod )
/* Uncomment this to auto-create the translation tables /* Uncomment this to auto-create the translation tables

155
babele-register-orig.js Normal file
View File

@ -0,0 +1,155 @@
/************************************************************************************/
/* Override some methods of the WFRP4 actor class, mainly to compute spells/weapons */
class ActorWfrp4e_fr extends ActorWfrp4e {
/**
* Calculates a weapon's range or damage formula.
*
* Takes a weapon formula for Damage or Range (SB + 4 or SBx3) and converts to a numeric value.
*
* @param {String} formula formula to be processed (SBx3 => 9).
*
* @return {Number} Numeric formula evaluation
*/
calculateRangeOrDamage(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', '*');
return eval(formula);
}
catch
{
return formula
}
}
/**
* Turns a formula into a processed string for display
*
* Processes damage formula based - same as calculateSpellAttributes, but with additional
* consideration to whether its a magic missile or not
*
* @param {String} formula Formula to process - "Willpower Bonus + 4"
* @param {boolean} isMagicMissile Whether or not it's a magic missile - used in calculating additional damage
* @returns {String} Processed formula
*/
calculateSpellDamage(formula, isMagicMissile)
{
let actorData = this.data
formula = formula.toLowerCase();
if (isMagicMissile) // If it's a magic missile, damage includes willpower bonus
{
formula += "+ " + actorData.data.characteristics["wp"].bonus
}
// Specific case, to avoid wrong matching with "Force"
if (formula.includes("force mentale"))
{
// 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);
} else
formula = formula.replace("force mentale", actorData.data.characteristics["wp"].value);
}
// Iterate through characteristics
for(let ch in actorData.data.characteristics)
{
// If formula includes characteristic name
while (formula.includes(actorData.data.characteristics[ch].label.toLowerCase()))
{
// Determine if it's looking for the bonus or the value
if (formula.includes('bonus')) {
formula = formula.replace("bonus de " + WFRP4E.characteristics[ch].toLowerCase(), actorData.data.characteristics[ch].bonus);
formula = formula.replace(WFRP4E.characteristics[ch].toLowerCase() + " bonus", actorData.data.characteristics[ch].bonus);
}
else
formula = formula.replace(WFRP4E.characteristics[ch].toLowerCase(), actorData.data.characteristics[ch].value);
}
}
//console.log("calculateSpellDamage -> " + formula );
return eval(formula);
}
/**
* Turns a formula into a processed string for display
*
* Turns a spell attribute such as "Willpower Bonus Rounds" into a more user friendly, processed value
* such as "4 Rounds". If the aoe is checked, it wraps the result in AoE (Result).
*
* @param {String} formula Formula to process - "Willpower Bonus Rounds"
* @param {boolean} aoe Whether or not it's calculating AoE (changes string return)
* @returns {String} formula processed formula
*/
calculateSpellAttributes(formula, aoe=false)
{
let actorData = this.data
formula = formula.toLowerCase();
// Do not process these special values
if (formula != game.i18n.localize("Vous").toLowerCase() && formula != game.i18n.localize("Special").toLowerCase() && formula != game.i18n.localize("Instantané").toLowerCase())
{
// Specific case, to avoid wrong matching with "Force"
if (formula.includes("force mentale"))
{
// 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);
}
else
formula = formula.replace("force mentale", actorData.data.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)
{
// If formula includes characteristic name
//console.log("Testing :", ch, WFRP4E.characteristics[ch].toLowerCase());
if (formula.includes(WFRP4E.characteristics[ch].toLowerCase()))
{
// Determine if it's looking for the bonus or the value
if (formula.includes('bonus')) {
formula = formula.replace("bonus de " + WFRP4E.characteristics[ch].toLowerCase(), actorData.data.characteristics[ch].bonus);
formula = formula.replace(WFRP4E.characteristics[ch].toLowerCase() + " bonus", actorData.data.characteristics[ch].bonus);
}
else
formula = formula.replace(WFRP4E.characteristics[ch].toLowerCase(), actorData.data.characteristics[ch].value);
}
}
}
// If AoE - wrap with AoE ( )
if (aoe)
formula = "AoE (" + formula.capitalize() + ")";
//console.log("calculateSpellAttributes -> " + formula );
return formula.capitalize();
}
}

View File

@ -1,3 +1,6 @@
/************************************************************************************/
import ActorWfrp4e from "/systems/wfrp4e//modules/actor/actor-wfrp4e.js";
/************************************************************************************/ /************************************************************************************/
/* Override some methods of the WFRP4 actor class, mainly to compute spells/weapons */ /* Override some methods of the WFRP4 actor class, mainly to compute spells/weapons */
class ActorWfrp4e_fr extends ActorWfrp4e { class ActorWfrp4e_fr extends ActorWfrp4e {
@ -83,10 +86,10 @@ class ActorWfrp4e_fr extends ActorWfrp4e {
// Determine if it's looking for the bonus or the value // Determine if it's looking for the bonus or the value
if (formula.includes('bonus')) { if (formula.includes('bonus')) {
formula = formula.replace("bonus de " + WFRP4E.characteristics[ch].toLowerCase(), actorData.data.characteristics[ch].bonus); formula = formula.replace("bonus de " + WFRP4E.characteristics[ch].toLowerCase(), actorData.data.characteristics[ch].bonus);
formula = formula.replace(WFRP4E.characteristics[ch].toLowerCase() + " bonus", actorData.data.characteristics[ch].bonus); formula = formula.replace(game.wfrp4e.config.characteristics[ch].toLowerCase() + " bonus", actorData.data.characteristics[ch].bonus);
} }
else else
formula = formula.replace(WFRP4E.characteristics[ch].toLowerCase(), actorData.data.characteristics[ch].value); formula = formula.replace(game.wfrp4e.config.characteristics[ch].toLowerCase(), actorData.data.characteristics[ch].value);
} }
} }
@ -132,15 +135,15 @@ class ActorWfrp4e_fr extends ActorWfrp4e {
{ {
// If formula includes characteristic name // If formula includes characteristic name
//console.log("Testing :", ch, WFRP4E.characteristics[ch].toLowerCase()); //console.log("Testing :", ch, WFRP4E.characteristics[ch].toLowerCase());
if (formula.includes(WFRP4E.characteristics[ch].toLowerCase())) if (formula.includes(game.wfrp4e.config.characteristics[ch].toLowerCase()))
{ {
// Determine if it's looking for the bonus or the value // Determine if it's looking for the bonus or the value
if (formula.includes('bonus')) { if (formula.includes('bonus')) {
formula = formula.replace("bonus de " + WFRP4E.characteristics[ch].toLowerCase(), actorData.data.characteristics[ch].bonus); formula = formula.replace("bonus de " + game.wfrp4e.config.characteristics[ch].toLowerCase(), actorData.data.characteristics[ch].bonus);
formula = formula.replace(WFRP4E.characteristics[ch].toLowerCase() + " bonus", actorData.data.characteristics[ch].bonus); formula = formula.replace(game.wfrp4e.config.characteristics[ch].toLowerCase() + " bonus", actorData.data.characteristics[ch].bonus);
} }
else else
formula = formula.replace(WFRP4E.characteristics[ch].toLowerCase(), actorData.data.characteristics[ch].value); formula = formula.replace(game.wfrp4e.config.characteristics[ch].toLowerCase(), actorData.data.characteristics[ch].value);
} }
} }
} }
@ -168,6 +171,9 @@ Hooks.once('init', () => {
if ( name == "wfrp4e-content" && module.active) { if ( name == "wfrp4e-content" && module.active) {
compmod = "wfrp4e-content"; compmod = "wfrp4e-content";
} }
if ( name == "wfrp4e-core" && module.active) {
compmod = "wfrp4e-core";
}
} ); } );
// Babele stuff // Babele stuff