Add Trader Repair Value on game start

This commit is contained in:
Dev 2023-11-07 20:00:02 +00:00
parent 8fb8b66afb
commit 1f622a0760

View File

@ -119,6 +119,8 @@ export class GameController
this.adjustLooseLootSpawnProbabilities();
this.checkTraderRepairValuesExist();
// repeatableQuests are stored by in profile.Quests due to the responses of the client (e.g. Quests in offraidData)
// Since we don't want to clutter the Quests list, we need to remove all completed (failed / successful) repeatable quests.
// We also have to remove the Counters from the repeatableQuests
@ -228,6 +230,30 @@ export class GameController
}
}
/**
* Out of date/incorrectly made trader mods forget this data
*/
protected checkTraderRepairValuesExist(): void
{
for (const traderKey in this.databaseServer.getTables().traders)
{
const trader = this.databaseServer.getTables().traders[traderKey];
if (!trader?.base?.repair)
{
this.logger.warning(`Trader ${trader.base._id} ${trader.base.name} is missing a repair object, adding in default values`);
trader.base.repair = this.jsonUtil.clone(this.databaseServer.getTables().traders.ragfair.base.repair);
return;
}
if (trader?.base?.repair?.quality)
{
this.logger.warning(`Trader ${trader.base._id} ${trader.base.name} is missing a repair quality value, adding in default value`);
trader.base.repair.quality = this.jsonUtil.clone(this.databaseServer.getTables().traders.ragfair.base.repair.quality);
}
}
}
protected addCustomLooseLootPositions(): void
{
const looseLootPositionsToAdd = this.lootConfig.looseLoot;