Redefine actors for French use

This commit is contained in:
sladecraven 2020-11-06 21:44:22 +01:00
parent db8e5efa2e
commit c4211304d4
4 changed files with 61 additions and 203 deletions

View File

@ -1,155 +0,0 @@
/************************************************************************************/
/* 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

@ -3,7 +3,7 @@
"name": "WH4-fr-translation", "name": "WH4-fr-translation",
"title": "Traduction du module WH4 en Français.", "title": "Traduction du module WH4 en Français.",
"description": "La traduction du module WH4.", "description": "La traduction du module WH4.",
"version": "1.3.12", "version": "1.3.13",
"minimumCoreVersion" : "0.6.6", "minimumCoreVersion" : "0.6.6",
"compatibleCoreVersion": "1.0.0", "compatibleCoreVersion": "1.0.0",
"author": "LeRatierBretonnien", "author": "LeRatierBretonnien",

View File

@ -178,7 +178,7 @@ export default class ActorWfrp4e_fr extends Actor {
} }
// If the size has been changed since the last known value, update the value // If the size has been changed since the last known value, update the value
data.data.details.size.value = WFRP_Utility.findKey(size, WFRP4E.actorSizes) || "avg" data.data.details.size.value = WFRP_Utility.findKey(size, game.wfrp4e.config.actorSizes) || "avg"
// Now that we have size, calculate wounds and token size // Now that we have size, calculate wounds and token size
if (data.flags.autoCalcWounds) { if (data.flags.autoCalcWounds) {
@ -191,7 +191,8 @@ export default class ActorWfrp4e_fr extends Actor {
} }
if (data.flags.autoCalcSize) { if (data.flags.autoCalcSize) {
let tokenSize = WFRP4E.tokenSizes[data.data.details.size.value] //let tokenSize = WFRP4E.tokenSizes[data.data.details.size.value]
let tokenSize = game.wfrp4e.config.tokenSizes[data.data.details.size.value]
if (this.isToken) { if (this.isToken) {
this.token.update({"height" : tokenSize, "width" : tokenSize }); this.token.update({"height" : tokenSize, "width" : tokenSize });
} }
@ -372,7 +373,7 @@ export default class ActorWfrp4e_fr extends Actor {
// Note that this does not execute until DiceWFRP.setupDialog() has finished and the user confirms the dialog // Note that this does not execute until DiceWFRP.setupDialog() has finished and the user confirms the dialog
cardOptions.rollMode = html.find('[name="rollMode"]').val(); cardOptions.rollMode = html.find('[name="rollMode"]').val();
testData.testModifier = Number(html.find('[name="testModifier"]').val()); testData.testModifier = Number(html.find('[name="testModifier"]').val());
testData.testDifficulty = WFRP4E.difficultyModifiers[html.find('[name="testDifficulty"]').val()]; testData.testDifficulty = game.wfrp4e.config.difficultyModifiers[html.find('[name="testDifficulty"]').val()];
testData.successBonus = Number(html.find('[name="successBonus"]').val()); testData.successBonus = Number(html.find('[name="successBonus"]').val());
testData.slBonus = Number(html.find('[name="slBonus"]').val()); testData.slBonus = Number(html.find('[name="slBonus"]').val());
// Target value is the final value being tested against, after all modifiers and bonuses are added // Target value is the final value being tested against, after all modifiers and bonuses are added
@ -455,7 +456,7 @@ export default class ActorWfrp4e_fr extends Actor {
data: { data: {
hitLocation: testData.hitLocation, hitLocation: testData.hitLocation,
talents: this.data.flags.talentTests, talents: this.data.flags.talentTests,
characteristicList: WFRP4E.characteristics, characteristicList: game.wfrp4e.config.characteristics,
characteristicToUse: skill.data.characteristic.value, characteristicToUse: skill.data.characteristic.value,
advantage: this.data.data.status.advantage.value || 0, advantage: this.data.data.status.advantage.value || 0,
rollMode: options.rollMode rollMode: options.rollMode
@ -465,7 +466,7 @@ export default class ActorWfrp4e_fr extends Actor {
// Note that this does not execute until DiceWFRP.setupDialog() has finished and the user confirms the dialog // Note that this does not execute until DiceWFRP.setupDialog() has finished and the user confirms the dialog
cardOptions.rollMode = html.find('[name="rollMode"]').val(); cardOptions.rollMode = html.find('[name="rollMode"]').val();
testData.testModifier = Number(html.find('[name="testModifier"]').val()); testData.testModifier = Number(html.find('[name="testModifier"]').val());
testData.testDifficulty = WFRP4E.difficultyModifiers[html.find('[name="testDifficulty"]').val()]; testData.testDifficulty = game.wfrp4e.config.difficultyModifiers[html.find('[name="testDifficulty"]').val()];
testData.successBonus = Number(html.find('[name="successBonus"]').val()); testData.successBonus = Number(html.find('[name="successBonus"]').val());
testData.slBonus = Number(html.find('[name="slBonus"]').val()); testData.slBonus = Number(html.find('[name="slBonus"]').val());
let characteristicToUse = html.find('[name="characteristicToUse"]').val(); let characteristicToUse = html.find('[name="characteristicToUse"]').val();
@ -673,7 +674,7 @@ export default class ActorWfrp4e_fr extends Actor {
// Note that this does not execute until DiceWFRP.setupDialog() has finished and the user confirms the dialog // Note that this does not execute until DiceWFRP.setupDialog() has finished and the user confirms the dialog
cardOptions.rollMode = html.find('[name="rollMode"]').val(); cardOptions.rollMode = html.find('[name="rollMode"]').val();
testData.testModifier = Number(html.find('[name="testModifier"]').val()); testData.testModifier = Number(html.find('[name="testModifier"]').val());
testData.testDifficulty = WFRP4E.difficultyModifiers[html.find('[name="testDifficulty"]').val()]; testData.testDifficulty = game.wfrp4e.config.difficultyModifiers[html.find('[name="testDifficulty"]').val()];
testData.successBonus = Number(html.find('[name="successBonus"]').val()); testData.successBonus = Number(html.find('[name="successBonus"]').val());
testData.slBonus = Number(html.find('[name="slBonus"]').val()); testData.slBonus = Number(html.find('[name="slBonus"]').val());
let skillSelected = skillCharList[Number(html.find('[name="skillSelected"]').val())]; let skillSelected = skillCharList[Number(html.find('[name="skillSelected"]').val())];
@ -791,7 +792,7 @@ export default class ActorWfrp4e_fr extends Actor {
// Note that this does not execute until DiceWFRP.setupDialog() has finished and the user confirms the dialog // Note that this does not execute until DiceWFRP.setupDialog() has finished and the user confirms the dialog
cardOptions.rollMode = html.find('[name="rollMode"]').val(); cardOptions.rollMode = html.find('[name="rollMode"]').val();
testData.testModifier = Number(html.find('[name="testModifier"]').val()); testData.testModifier = Number(html.find('[name="testModifier"]').val());
testData.testDifficulty = WFRP4E.difficultyModifiers[html.find('[name="testDifficulty"]').val()]; testData.testDifficulty = game.wfrp4e.config.difficultyModifiers[html.find('[name="testDifficulty"]').val()];
testData.successBonus = Number(html.find('[name="successBonus"]').val()); testData.successBonus = Number(html.find('[name="successBonus"]').val());
testData.slBonus = Number(html.find('[name="slBonus"]').val()); testData.slBonus = Number(html.find('[name="slBonus"]').val());
@ -870,7 +871,7 @@ export default class ActorWfrp4e_fr extends Actor {
} }
} }
else { else {
defaultSelection = channellSkills.indexOf(channellSkills.find(x => x.name.includes(WFRP4E.magicWind[spellLore]))); defaultSelection = channellSkills.indexOf(channellSkills.find(x => x.name.includes(game.wfrp4e.config.magicWind[spellLore])));
} }
if (spellLore == "witchcraft") if (spellLore == "witchcraft")
@ -911,7 +912,7 @@ export default class ActorWfrp4e_fr extends Actor {
// Note that this does not execute until DiceWFRP.setupDialog() has finished and the user confirms the dialog // Note that this does not execute until DiceWFRP.setupDialog() has finished and the user confirms the dialog
cardOptions.rollMode = html.find('[name="rollMode"]').val(); cardOptions.rollMode = html.find('[name="rollMode"]').val();
testData.testModifier = Number(html.find('[name="testModifier"]').val()); testData.testModifier = Number(html.find('[name="testModifier"]').val());
testData.testDifficulty = WFRP4E.difficultyModifiers[html.find('[name="testDifficulty"]').val()]; testData.testDifficulty = game.wfrp4e.config.difficultyModifiers[html.find('[name="testDifficulty"]').val()];
testData.successBonus = Number(html.find('[name="successBonus"]').val()); testData.successBonus = Number(html.find('[name="successBonus"]').val());
testData.slBonus = Number(html.find('[name="slBonus"]').val()); testData.slBonus = Number(html.find('[name="slBonus"]').val());
testData.extra.malignantInfluence = html.find('[name="malignantInfluence"]').is(':checked'); testData.extra.malignantInfluence = html.find('[name="malignantInfluence"]').is(':checked');
@ -1010,7 +1011,7 @@ export default class ActorWfrp4e_fr extends Actor {
// Note that this does not execute until DiceWFRP.setupDialog() has finished and the user confirms the dialog // Note that this does not execute until DiceWFRP.setupDialog() has finished and the user confirms the dialog
cardOptions.rollMode = html.find('[name="rollMode"]').val(); cardOptions.rollMode = html.find('[name="rollMode"]').val();
testData.testModifier = Number(html.find('[name="testModifier"]').val()); testData.testModifier = Number(html.find('[name="testModifier"]').val());
testData.testDifficulty = WFRP4E.difficultyModifiers[html.find('[name="testDifficulty"]').val()]; testData.testDifficulty = game.wfrp4e.config.difficultyModifiers[html.find('[name="testDifficulty"]').val()];
testData.successBonus = Number(html.find('[name="successBonus"]').val()); testData.successBonus = Number(html.find('[name="successBonus"]').val());
testData.slBonus = Number(html.find('[name="slBonus"]').val()); testData.slBonus = Number(html.find('[name="slBonus"]').val());
@ -1066,7 +1067,7 @@ export default class ActorWfrp4e_fr extends Actor {
setupTrait(trait, options = {}) { setupTrait(trait, options = {}) {
if (!trait.data.rollable.value) if (!trait.data.rollable.value)
return; return;
let title = WFRP4E.characteristics[trait.data.rollable.rollCharacteristic] + ` ${game.i18n.localize("Test")} - ` + trait.name; let title = game.wfrp4e.config.characteristics[trait.data.rollable.rollCharacteristic] + ` ${game.i18n.localize("Test")} - ` + trait.name;
let testData = { let testData = {
hitLocation: false, hitLocation: false,
target: this.data.data.characteristics[trait.data.rollable.rollCharacteristic].value, target: this.data.data.characteristics[trait.data.rollable.rollCharacteristic].value,
@ -1092,7 +1093,7 @@ export default class ActorWfrp4e_fr extends Actor {
data: { data: {
hitLocation: testData.hitLocation, hitLocation: testData.hitLocation,
talents: this.data.flags.talentTests, talents: this.data.flags.talentTests,
characteristicList: WFRP4E.characteristics, characteristicList: game.wfrp4e.config.characteristics,
characteristicToUse: trait.data.rollable.rollCharacteristic, characteristicToUse: trait.data.rollable.rollCharacteristic,
advantage: this.data.data.status.advantage.value || 0, advantage: this.data.data.status.advantage.value || 0,
testDifficulty: trait.data.rollable.defaultDifficulty testDifficulty: trait.data.rollable.defaultDifficulty
@ -1102,7 +1103,7 @@ export default class ActorWfrp4e_fr extends Actor {
// Note that this does not execute until DiceWFRP.setupDialog() has finished and the user confirms the dialog // Note that this does not execute until DiceWFRP.setupDialog() has finished and the user confirms the dialog
cardOptions.rollMode = html.find('[name="rollMode"]').val(); cardOptions.rollMode = html.find('[name="rollMode"]').val();
testData.testModifier = Number(html.find('[name="testModifier"]').val()); testData.testModifier = Number(html.find('[name="testModifier"]').val());
testData.testDifficulty = WFRP4E.difficultyModifiers[html.find('[name="testDifficulty"]').val()]; testData.testDifficulty = game.wfrp4e.config.difficultyModifiers[html.find('[name="testDifficulty"]').val()];
testData.successBonus = Number(html.find('[name="successBonus"]').val()); testData.successBonus = Number(html.find('[name="successBonus"]').val());
testData.slBonus = Number(html.find('[name="slBonus"]').val()); testData.slBonus = Number(html.find('[name="slBonus"]').val());
let characteristicToUse = html.find('[name="characteristicToUse"]').val(); let characteristicToUse = html.find('[name="characteristicToUse"]').val();
@ -1268,10 +1269,10 @@ DiceWFRP.renderRollCard() as well as handleOpposedTarget().
let status = testData.income.value.split(' ') let status = testData.income.value.split(' ')
let dieAmount = WFRP4E.earningValues[WFRP_Utility.findKey(status[0], WFRP4E.statusTiers)][0] // b, s, or g maps to 2d10, 1d10, or 1 respectively (takes the first letter) let dieAmount = game.wfrp4e.config.earningValues[WFRP_Utility.findKey(status[0], game.wfrp4e.config.statusTiers)][0] // b, s, or g maps to 2d10, 1d10, or 1 respectively (takes the first letter)
dieAmount = Number(dieAmount) * status[1]; // Multilpy that first letter by your standing (Brass 4 = 8d10 pennies) dieAmount = Number(dieAmount) * status[1]; // Multilpy that first letter by your standing (Brass 4 = 8d10 pennies)
let moneyEarned; let moneyEarned;
if (WFRP_Utility.findKey(status[0], WFRP4E.statusTiers) != "g") // Don't roll for gold, just use standing value if (WFRP_Utility.findKey(status[0], game.wfrp4e.config.statusTiers) != "g") // Don't roll for gold, just use standing value
{ {
dieAmount = dieAmount + "d10"; dieAmount = dieAmount + "d10";
moneyEarned = new Roll(dieAmount).roll().total; moneyEarned = new Roll(dieAmount).roll().total;
@ -1282,7 +1283,7 @@ DiceWFRP.renderRollCard() as well as handleOpposedTarget().
// After rolling, determined how much, if any, was actually earned // After rolling, determined how much, if any, was actually earned
if (result.description.includes("Success")) { if (result.description.includes("Success")) {
result.incomeResult = game.i18n.localize("INCOME.YouEarn") + " " + moneyEarned; result.incomeResult = game.i18n.localize("INCOME.YouEarn") + " " + moneyEarned;
switch (WFRP_Utility.findKey(status[0], WFRP4E.statusTiers)) { switch (WFRP_Utility.findKey(status[0], game.wfrp4e.config.statusTiers)) {
case "b": case "b":
result.incomeResult += ` ${game.i18n.localize("NAME.BPPlural").toLowerCase()}.` result.incomeResult += ` ${game.i18n.localize("NAME.BPPlural").toLowerCase()}.`
break; break;
@ -1300,7 +1301,7 @@ DiceWFRP.renderRollCard() as well as handleOpposedTarget().
else if (Number(result.SL) > -6) { else if (Number(result.SL) > -6) {
moneyEarned /= 2; moneyEarned /= 2;
result.incomeResult = game.i18n.localize("INCOME.YouEarn") + " " + moneyEarned; result.incomeResult = game.i18n.localize("INCOME.YouEarn") + " " + moneyEarned;
switch (WFRP_Utility.findKey(status[0], WFRP4E.statusTiers)) { switch (WFRP_Utility.findKey(status[0], game.wfrp4e.config.statusTiers)) {
case "b": case "b":
result.incomeResult += ` ${game.i18n.localize("NAME.BPPlural").toLowerCase()}.` result.incomeResult += ` ${game.i18n.localize("NAME.BPPlural").toLowerCase()}.`
break; break;
@ -1321,7 +1322,7 @@ DiceWFRP.renderRollCard() as well as handleOpposedTarget().
} }
// let contextAudio = await WFRP_Audio.MatchContextAudio(WFRP_Audio.FindContext(result)) // let contextAudio = await WFRP_Audio.MatchContextAudio(WFRP_Audio.FindContext(result))
// cardOptions.sound = contextAudio.file || cardOptions.sound // cardOptions.sound = contextAudio.file || cardOptions.sound
result.moneyEarned = moneyEarned + WFRP_Utility.findKey(status[0], WFRP4E.statusTiers); result.moneyEarned = moneyEarned + WFRP_Utility.findKey(status[0], game.wfrp4e.config.statusTiers);
if (!options.suppressMessage) if (!options.suppressMessage)
DiceWFRP.renderRollCard(cardOptions, result, options.rerenderMessage).then(msg => { DiceWFRP.renderRollCard(cardOptions, result, options.rerenderMessage).then(msg => {
OpposedWFRP.handleOpposedTarget(msg) OpposedWFRP.handleOpposedTarget(msg)
@ -1690,7 +1691,7 @@ DiceWFRP.renderRollCard() as well as handleOpposedTarget().
{ {
if (loc == "shield") if (loc == "shield")
continue continue
let row = WFRP_Tables[actorData.data.details.hitLocationTable.value].rows.find(r => r.result == loc) let row = game.wfrp4e.tables[actorData.data.details.hitLocationTable.value].rows.find(r => r.result == loc)
if (row) if (row)
AP[loc].label = game.i18n.localize(row.description) AP[loc].label = game.i18n.localize(row.description)
else else
@ -2083,9 +2084,9 @@ DiceWFRP.renderRollCard() as well as handleOpposedTarget().
var itemsInside = inContainers.filter(i => i.data.location.value == cont._id); var itemsInside = inContainers.filter(i => i.data.location.value == cont._id);
itemsInside.map(function (item) { // Add category of item to be displayed itemsInside.map(function (item) { // Add category of item to be displayed
if (item.type == "trapping") if (item.type == "trapping")
item.type = WFRP4E.trappingCategories[item.data.trappingType.value]; item.type = game.wfrp4e.config.trappingCategories[item.data.trappingType.value];
else else
item.type = WFRP4E.trappingCategories[item.type]; item.type = game.wfrp4e.config.trappingCategories[item.type];
}) })
cont["carrying"] = itemsInside.filter(i => i.type != "Container"); // cont.carrying -> items the container is carrying cont["carrying"] = itemsInside.filter(i => i.type != "Container"); // cont.carrying -> items the container is carrying
cont["packsInside"] = itemsInside.filter(i => i.type == "Container"); // cont.packsInside -> containers the container is carrying cont["packsInside"] = itemsInside.filter(i => i.type == "Container"); // cont.packsInside -> containers the container is carrying
@ -2166,15 +2167,15 @@ DiceWFRP.renderRollCard() as well as handleOpposedTarget().
enc.state = enc.value / enc.max; // state is how many times over you are max encumbrance enc.state = enc.value / enc.max; // state is how many times over you are max encumbrance
if (enc.state > 3) { if (enc.state > 3) {
enc["maxEncumbered"] = true enc["maxEncumbered"] = true
enc.penalty = WFRP4E.encumbrancePenalties["maxEncumbered"]; enc.penalty = game.wfrp4e.config.encumbrancePenalties["maxEncumbered"];
} }
else if (enc.state > 2) { else if (enc.state > 2) {
enc["veryEncumbered"] = true enc["veryEncumbered"] = true
enc.penalty = WFRP4E.encumbrancePenalties["veryEncumbered"]; enc.penalty = game.wfrp4e.config.encumbrancePenalties["veryEncumbered"];
} }
else if (enc.state > 1) { else if (enc.state > 1) {
enc["encumbered"] = true enc["encumbered"] = true
enc.penalty = WFRP4E.encumbrancePenalties["encumbered"]; enc.penalty = game.wfrp4e.config.encumbrancePenalties["encumbered"];
} }
else else
enc["notEncumbered"] = true; enc["notEncumbered"] = true;
@ -2232,7 +2233,7 @@ DiceWFRP.renderRollCard() as well as handleOpposedTarget().
else if (skill.data.modifier.value < 0) else if (skill.data.modifier.value < 0)
skill.modified = "negative" skill.modified = "negative"
} }
skill.data.characteristic.abrev = WFRP4E.characteristicsAbbrev[skill.data.characteristic.value]; skill.data.characteristic.abrev = game.wfrp4e.config.characteristicsAbbrev[skill.data.characteristic.value];
skill.data.cost = WFRP_Utility._calculateAdvCost(skill.data.advances.value, "skill", skill.data.advances.costModifier) skill.data.cost = WFRP_Utility._calculateAdvCost(skill.data.advances.value, "skill", skill.data.advances.costModifier)
return skill return skill
} }
@ -2308,9 +2309,9 @@ DiceWFRP.renderRollCard() as well as handleOpposedTarget().
if (!skills) // If a skill list isn't provided, filter all items to find skills if (!skills) // If a skill list isn't provided, filter all items to find skills
skills = actorData.items.filter(i => i.type == "skill"); skills = actorData.items.filter(i => i.type == "skill");
weapon.attackType = WFRP4E.groupToType[weapon.data.weaponGroup.value] weapon.attackType = game.wfrp4e.config.groupToType[weapon.data.weaponGroup.value]
weapon.data.reach.value = WFRP4E.weaponReaches[weapon.data.reach.value]; weapon.data.reach.value = game.wfrp4e.config.weaponReaches[weapon.data.reach.value];
weapon.data.weaponGroup.value = WFRP4E.weaponGroups[weapon.data.weaponGroup.value] || "basic"; weapon.data.weaponGroup.value = game.wfrp4e.config.weaponGroups[weapon.data.weaponGroup.value] || "basic";
// Attach the available skills to use to the weapon. // Attach the available skills to use to the weapon.
weapon.skillToUse = skills.find(x => x.name.toLowerCase().includes(`(${weapon.data.weaponGroup.value.toLowerCase()})`)) weapon.skillToUse = skills.find(x => x.name.toLowerCase().includes(`(${weapon.data.weaponGroup.value.toLowerCase()})`))
@ -2726,7 +2727,7 @@ DiceWFRP.renderRollCard() as well as handleOpposedTarget().
{ {
// 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(game.wfrp4e.config.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
@ -2921,7 +2922,7 @@ DiceWFRP.renderRollCard() as well as handleOpposedTarget().
* @param {Object} opposedData Test results, all the information needed to calculate damage * @param {Object} opposedData Test results, all the information needed to calculate damage
* @param {var} damageType enum for what the damage ignores, see config.js * @param {var} damageType enum for what the damage ignores, see config.js
*/ */
static applyDamage(victim, opposeData, damageType = WFRP4E.DAMAGE_TYPE.NORMAL) { static applyDamage(victim, opposeData, damageType = game.wfrp4e.config.DAMAGE_TYPE.NORMAL) {
if (!opposeData.damage) if (!opposeData.damage)
return `<b>Error</b>: ${game.i18n.localize("CHAT.DamageAppliedError")}` return `<b>Error</b>: ${game.i18n.localize("CHAT.DamageAppliedError")}`
// If no damage value, don't attempt anything // If no damage value, don't attempt anything
@ -2936,13 +2937,13 @@ DiceWFRP.renderRollCard() as well as handleOpposedTarget().
// Start wound loss at the damage value // Start wound loss at the damage value
let totalWoundLoss = opposeData.damage.value let totalWoundLoss = opposeData.damage.value
let newWounds = actor.data.data.status.wounds.value; let newWounds = actor.data.data.status.wounds.value;
let applyAP = (damageType == WFRP4E.DAMAGE_TYPE.IGNORE_TB || damageType == WFRP4E.DAMAGE_TYPE.NORMAL) let applyAP = (damageType == game.wfrp4e.config.DAMAGE_TYPE.IGNORE_TB || damageType == game.wfrp4e.config.DAMAGE_TYPE.NORMAL)
let applyTB = (damageType == WFRP4E.DAMAGE_TYPE.IGNORE_AP || damageType == WFRP4E.DAMAGE_TYPE.NORMAL) let applyTB = (damageType == game.wfrp4e.config.DAMAGE_TYPE.IGNORE_AP || damageType == game.wfrp4e.config.DAMAGE_TYPE.NORMAL)
let AP = {}; let AP = {};
// Start message update string // Start message update string
let updateMsg = `<b>${game.i18n.localize("CHAT.DamageApplied")}</b><span class = 'hide-option'>: @TOTAL`; let updateMsg = `<b>${game.i18n.localize("CHAT.DamageApplied")}</b><span class = 'hide-option'>: @TOTAL`;
if (damageType != WFRP4E.DAMAGE_TYPE.IGNORE_ALL) if (damageType != game.wfrp4e.config.DAMAGE_TYPE.IGNORE_ALL)
updateMsg += " (" updateMsg += " ("
let weaponProperties let weaponProperties
@ -3099,7 +3100,7 @@ DiceWFRP.renderRollCard() as well as handleOpposedTarget().
updateMsg += `<br>${game.i18n.localize("PROPERTY.Impenetrable")} - ${game.i18n.localize("CHAT.CriticalsNullified")}` updateMsg += `<br>${game.i18n.localize("PROPERTY.Impenetrable")} - ${game.i18n.localize("CHAT.CriticalsNullified")}`
if (hack) if (hack)
updateMsg += `<br>${game.i18n.localize("CHAT.DamageAP")} ${WFRP4E.locations[opposeData.hitloc.value]}` updateMsg += `<br>${game.i18n.localize("CHAT.DamageAP")} ${game.wfrp4e.config.locations[opposeData.hitloc.value]}`
if (newWounds <= 0) if (newWounds <= 0)
newWounds = 0; // Do not go below 0 wounds newWounds = 0; // Do not go below 0 wounds
@ -3137,11 +3138,11 @@ DiceWFRP.renderRollCard() as well as handleOpposedTarget().
// A species may not be entered in the actor, so use some error handling. // A species may not be entered in the actor, so use some error handling.
try { try {
skillList = WFRP4E.speciesSkills[this.data.data.details.species.value]; skillList = game.wfrp4e.config.speciesSkills[this.data.data.details.species.value];
if (!skillList) { if (!skillList) {
// findKey() will do an inverse lookup of the species key in the species object defined in config.js, and use that if // findKey() will do an inverse lookup of the species key in the species object defined in config.js, and use that if
// user-entered species value does not work (which it probably will not) // user-entered species value does not work (which it probably will not)
skillList = WFRP4E.speciesSkills[WFRP_Utility.findKey(this.data.data.details.species.value, WFRP4E.species)] skillList = game.wfrp4e.config.speciesSkills[WFRP_Utility.findKey(this.data.data.details.species.value, game.wfrp4e.config.species)]
if (!skillList) { if (!skillList) {
throw game.i18n.localize("Error.SpeciesSkills") + " " + this.data.data.details.species.value; throw game.i18n.localize("Error.SpeciesSkills") + " " + this.data.data.details.species.value;
} }
@ -3188,11 +3189,11 @@ DiceWFRP.renderRollCard() as well as handleOpposedTarget().
// A species may not be entered in the actor, so use some error handling. // A species may not be entered in the actor, so use some error handling.
let talentList let talentList
try { try {
talentList = WFRP4E.speciesTalents[this.data.data.details.species.value]; talentList = game.wfrp4e.config.speciesTalents[this.data.data.details.species.value];
if (!talentList) { if (!talentList) {
// findKey() will do an inverse lookup of the species key in the species object defined in config.js, and use that if // findKey() will do an inverse lookup of the species key in the species object defined in config.js, and use that if
// user-entered species value does not work (which it probably will not) // user-entered species value does not work (which it probably will not)
talentList = WFRP4E.speciesTalents[WFRP_Utility.findKey(this.data.data.details.species.value, WFRP4E.species)] talentList = game.wfrp4e.config.speciesTalents[WFRP_Utility.findKey(this.data.data.details.species.value, game.wfrp4e.config.species)]
if (!talentList) if (!talentList)
throw game.i18n.localize("Error.SpeciesTalents") + " " + this.data.data.details.species.value; throw game.i18n.localize("Error.SpeciesTalents") + " " + this.data.data.details.species.value;
} }
@ -3207,7 +3208,7 @@ DiceWFRP.renderRollCard() as well as handleOpposedTarget().
if (!isNaN(talent)) // If is a number, roll on random talents if (!isNaN(talent)) // If is a number, roll on random talents
{ {
for (let i = 0; i < talent; i++) { for (let i = 0; i < talent; i++) {
let result = WFRP_Tables.rollTable("talents") let result = game.wfrp4e.tables.rollTable("talents")
await this._advanceTalent(result.name); await this._advanceTalent(result.name);
} }
continue continue
@ -3375,7 +3376,7 @@ DiceWFRP.renderRollCard() as well as handleOpposedTarget().
} }
delete data.preData.roll; delete data.preData.roll;
delete data.preData.SL; delete data.preData.SL;
new ActorWfrp4e(data.postData.actor)[`${data.postData.postFunction}`]({testData : data.preData, cardOptions}); new ActorWfrp4e_fr(data.postData.actor)[`${data.postData.postFunction}`]({testData : data.preData, cardOptions});
//We also set fortuneUsedAddSL to force the player to use it on the new roll //We also set fortuneUsedAddSL to force the player to use it on the new roll
message.update({ message.update({
@ -3399,7 +3400,7 @@ DiceWFRP.renderRollCard() as well as handleOpposedTarget().
game.user.targets.forEach(t => t.setTarget(false, { user: game.user, releaseOthers: false, groupSelection: true })); game.user.targets.forEach(t => t.setTarget(false, { user: game.user, releaseOthers: false, groupSelection: true }));
cardOptions.fortuneUsedAddSL = true; cardOptions.fortuneUsedAddSL = true;
new ActorWfrp4e(data.postData.actor)[`${data.postData.postFunction}`]({testData : newTestData, cardOptions}, {rerenderMessage : message}); new ActorWfrp4e_fr(data.postData.actor)[`${data.postData.postFunction}`]({testData : newTestData, cardOptions}, {rerenderMessage : message});
message.update({ message.update({
"flags.data.fortuneUsedAddSL": true "flags.data.fortuneUsedAddSL": true
}); });
@ -3442,7 +3443,7 @@ DiceWFRP.renderRollCard() as well as handleOpposedTarget().
} }
delete message.data.flags.data.preData.roll; delete message.data.flags.data.preData.roll;
delete message.data.flags.data.preData.SL; delete message.data.flags.data.preData.SL;
new ActorWfrp4e(data.postData.actor)[`${data.postData.postFunction}`]({testData : data.preData, cardOptions}); new ActorWfrp4e_fr(data.postData.actor)[`${data.postData.postFunction}`]({testData : data.preData, cardOptions});
} }
/** /**
@ -3564,7 +3565,7 @@ DiceWFRP.renderRollCard() as well as handleOpposedTarget().
if (failed) { if (failed) {
let wpb = this.data.data.characteristics.wp.bonus; let wpb = this.data.data.characteristics.wp.bonus;
let tableText = "Roll on a Corruption Table:<br>" + WFRP4E.corruptionTables.map(t => `@Table[${t}]<br>`).join("") let tableText = "Roll on a Corruption Table:<br>" + game.wfrp4e.config.corruptionTables.map(t => `@Table[${t}]<br>`).join("")
ChatMessage.create(WFRP_Utility.chatDataSetup(` ChatMessage.create(WFRP_Utility.chatDataSetup(`
<h3>Dissolution of Body and Mind</h3> <h3>Dissolution of Body and Mind</h3>
<p>As corruption ravages your soul, the warping breath of Chaos whispers within, either fanning your flesh into a fresh, new form, or fracturing your psyche with exquisite knowledge it can never unlearn.</p> <p>As corruption ravages your soul, the warping breath of Chaos whispers within, either fanning your flesh into a fresh, new form, or fracturing your psyche with exquisite knowledge it can never unlearn.</p>

File diff suppressed because one or more lines are too long