Improve data returned from getAllBotDifficulties()

This commit is contained in:
Dev 2024-04-24 10:09:37 +01:00
parent 6e262a228f
commit 60eb6bfe80

View File

@ -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 { Difficulty } from "@spt-aki/models/eft/common/tables/IBotType";
import { IGetRaidConfigurationRequestData } from "@spt-aki/models/eft/match/IGetRaidConfigurationRequestData"; import { IGetRaidConfigurationRequestData } from "@spt-aki/models/eft/match/IGetRaidConfigurationRequestData";
import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes"; 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 { BotGenerationDetails } from "@spt-aki/models/spt/bots/BotGenerationDetails";
import { IBotConfig } from "@spt-aki/models/spt/config/IBotConfig"; import { IBotConfig } from "@spt-aki/models/spt/config/IBotConfig";
import { IPmcConfig } from "@spt-aki/models/spt/config/IPmcConfig"; import { IPmcConfig } from "@spt-aki/models/spt/config/IPmcConfig";
@ -146,23 +147,31 @@ export class BotController
const result = {}; const result = {};
const botDb = this.databaseServer.getTables().bots.types; const botDb = this.databaseServer.getTables().bots.types;
const botTypes = Object.keys(botDb); const botTypes = Object.keys(WildSpawnTypeNumber).filter((v) => Number.isNaN(Number(v)));
for (const botType of botTypes) 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]; const botDetails = botDb[botType];
if (!botDetails.difficulty) if (!botDetails?.difficulty)
{ {
continue; continue;
} }
const botDifficulties = Object.keys(botDetails.difficulty);
result[botType] = {}; const botDifficulties = Object.keys(botDetails.difficulty);
result[enumType] = {};
for (const difficulty of botDifficulties) 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; return result;
} }