From 60eb6bfe809c6ea6742e8c2345776034d836e52a Mon Sep 17 00:00:00 2001 From: Dev Date: Wed, 24 Apr 2024 10:09:37 +0100 Subject: [PATCH] Improve data returned from `getAllBotDifficulties()` --- project/src/controllers/BotController.ts | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/project/src/controllers/BotController.ts b/project/src/controllers/BotController.ts index c2fafbfb..30967cee 100644 --- a/project/src/controllers/BotController.ts +++ b/project/src/controllers/BotController.ts @@ -13,6 +13,7 @@ import { IBotCore } from "@spt-aki/models/eft/common/tables/IBotCore"; import { Difficulty } from "@spt-aki/models/eft/common/tables/IBotType"; import { IGetRaidConfigurationRequestData } from "@spt-aki/models/eft/match/IGetRaidConfigurationRequestData"; import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes"; +import { WildSpawnTypeNumber } from "@spt-aki/models/enums/WildSpawnTypeNumber"; import { BotGenerationDetails } from "@spt-aki/models/spt/bots/BotGenerationDetails"; import { IBotConfig } from "@spt-aki/models/spt/config/IBotConfig"; import { IPmcConfig } from "@spt-aki/models/spt/config/IPmcConfig"; @@ -146,23 +147,31 @@ export class BotController const result = {}; const botDb = this.databaseServer.getTables().bots.types; - const botTypes = Object.keys(botDb); - for (const botType of botTypes) + const botTypes = Object.keys(WildSpawnTypeNumber).filter((v) => Number.isNaN(Number(v))); + for (let botType of botTypes) { + const enumType = botType.toLowerCase(); + // sptBear/sptUsec need to be converted into `usec`/`bear` so we can read difficulty settings from bots/types + botType = this.botHelper.isBotPmc(botType) + ? this.botHelper.getPmcSideByRole(botType).toLowerCase() + : botType.toLowerCase(); + const botDetails = botDb[botType]; - if (!botDetails.difficulty) + if (!botDetails?.difficulty) { continue; } - const botDifficulties = Object.keys(botDetails.difficulty); - result[botType] = {}; + const botDifficulties = Object.keys(botDetails.difficulty); + result[enumType] = {}; for (const difficulty of botDifficulties) { - result[botType][difficulty] = this.getBotDifficulty(botType, difficulty, true); + result[enumType][difficulty] = this.getBotDifficulty(enumType, difficulty, true); } } + result["core"] = this.getBotCoreDifficulty(); + return result; }