Enhance robustness

This commit is contained in:
2026-01-05 17:24:01 +01:00
parent 07928acb48
commit d1da169fa3
31 changed files with 110 additions and 92 deletions

View File

@@ -4,6 +4,9 @@ export class WH4FRPatchConfig {
/************************************************************************************/
static translateSkillList(skillList) {
if (!skillList || skillList.length == 0) {
return skillList;
}
let compendiumName = 'wfrp4e-core.items'
let newList = [];
@@ -43,6 +46,9 @@ export class WH4FRPatchConfig {
/************************************************************************************/
static translateTalentList(talentList) {
if (!talentList || talentList.length == 0) {
return talentList;
}
let compendiumName = 'wfrp4e-core.items'
let newList = [];
@@ -76,6 +82,9 @@ export class WH4FRPatchConfig {
/************************************************************************************/
static patch_subspecies() {
if (!game.wfrp4e?.config?.subspecies) {
return
}
for (let speciesName in game.wfrp4e.config.subspecies) {
let subspeciesList = game.wfrp4e.config.subspecies[speciesName];
for (let subspeciesName in subspeciesList) {
@@ -92,6 +101,9 @@ export class WH4FRPatchConfig {
/************************************************************************************/
static patch_species_skills() {
if (!game.wfrp4e?.config?.speciesSkills) {
return
}
console.log("Patching species skills....");
for (let speciesName in game.wfrp4e.config.speciesSkills) {
let speciesComp = game.wfrp4e.config.speciesSkills[speciesName];
@@ -102,6 +114,9 @@ export class WH4FRPatchConfig {
/************************************************************************************/
static patch_species_talents() {
if (!game.wfrp4e?.config?.speciesTalents) {
return
}
for (let speciesName in game.wfrp4e.config.speciesTalents) {
let speciesTalents = game.wfrp4e.config.speciesTalents[speciesName];
game.wfrp4e.config.speciesTalents[speciesName] = this.translateTalentList(speciesTalents);
@@ -112,7 +127,7 @@ export class WH4FRPatchConfig {
static patch_career() {
let compendiumName = 'wfrp4e-core.items'
if (game.wfrp4e.tables.career) {
if (game.wfrp4e?.tables?.career) {
for (let row of game.wfrp4e.tables.career.rows) {
for (let key in row) {
if (key != "range") {
@@ -133,7 +148,10 @@ export class WH4FRPatchConfig {
/************************************************************************************/
static fixSpeciesTable() {
let speciesTable = game.wfrp4e.tables.findTable("species");
let speciesTable = game.wfrp4e?.tables?.findTable("species");
if (!speciesTable?.results) {
return
}
let newResults = foundry.utils.duplicate(speciesTable.results);
for (let result of newResults) {
result.name = game.i18n.localize(result.name);