Add endpoint to allow getting all bot difficulty data in one call
This commit is contained in:
parent
18b28a6d0b
commit
13ab57298b
@ -4,6 +4,7 @@ import { BotController } from "@spt-aki/controllers/BotController";
|
||||
import { IGenerateBotsRequestData } from "@spt-aki/models/eft/bot/IGenerateBotsRequestData";
|
||||
import { IEmptyRequestData } from "@spt-aki/models/eft/common/IEmptyRequestData";
|
||||
import { IBotBase } from "@spt-aki/models/eft/common/tables/IBotBase";
|
||||
import { Difficulties } from "@spt-aki/models/eft/common/tables/IBotType";
|
||||
import { IGetBodyResponseData } from "@spt-aki/models/eft/httpResponse/IGetBodyResponseData";
|
||||
import { HttpResponseUtil } from "@spt-aki/utils/HttpResponseUtil";
|
||||
|
||||
@ -44,6 +45,15 @@ export class BotCallbacks
|
||||
return this.httpResponse.noBody(this.botController.getBotDifficulty(type, difficulty));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle singleplayer/settings/bot/difficulties
|
||||
* @returns dictionary of every bot and its diffiulty settings
|
||||
*/
|
||||
public getAllBotDifficulties(url: string, info: IEmptyRequestData, sessionID: string): Record<string, Difficulties>
|
||||
{
|
||||
return this.httpResponse.noBody(this.botController.getAllBotDifficulties());
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle client/game/bot/generate
|
||||
* @returns IGetBodyResponseData
|
||||
|
@ -83,7 +83,7 @@ export class BotController
|
||||
|
||||
/**
|
||||
* Get bot difficulty settings
|
||||
* adjust PMC settings to ensure they engage the correct bot types
|
||||
* Adjust PMC settings to ensure they engage the correct bot types
|
||||
* @param type what bot the server is requesting settings for
|
||||
* @param diffLevel difficulty level server requested settings for
|
||||
* @returns Difficulty object
|
||||
@ -104,7 +104,7 @@ export class BotController
|
||||
|
||||
// Check value chosen in pre-raid difficulty dropdown
|
||||
// If value is not 'asonline', change requested difficulty to be what was chosen in dropdown
|
||||
const botDifficultyDropDownValue = raidConfig.wavesSettings.botDifficulty.toLowerCase();
|
||||
const botDifficultyDropDownValue = raidConfig?.wavesSettings.botDifficulty.toLowerCase() ?? "asonline";
|
||||
if (botDifficultyDropDownValue !== "asonline")
|
||||
{
|
||||
difficulty = this.botDifficultyHelper.convertBotDifficultyDropdownToBotDifficulty(
|
||||
@ -140,6 +140,31 @@ export class BotController
|
||||
return difficultySettings;
|
||||
}
|
||||
|
||||
public getAllBotDifficulties(): Record<string, any>
|
||||
{
|
||||
const result = {};
|
||||
|
||||
const botDb = this.databaseServer.getTables().bots.types;
|
||||
const botTypes = Object.keys(botDb);
|
||||
for (const botType of botTypes)
|
||||
{
|
||||
const botDetails = botDb[botType];
|
||||
if (!botDetails.difficulty)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
const botDifficulties = Object.keys(botDetails.difficulty);
|
||||
|
||||
result[botType] = {};
|
||||
for (const difficulty of botDifficulties)
|
||||
{
|
||||
result[botType][difficulty] = this.getBotDifficulty(botType, difficulty);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate bot profiles and store in cache
|
||||
* @param sessionId Session id
|
||||
|
@ -23,6 +23,13 @@ export class BotDynamicRouter extends DynamicRouter
|
||||
return this.botCallbacks.getBotDifficulty(url, info, sessionID);
|
||||
},
|
||||
),
|
||||
new RouteAction(
|
||||
"/singleplayer/settings/bot/difficulties/",
|
||||
(url: string, info: any, sessionID: string, output: string): any =>
|
||||
{
|
||||
return this.botCallbacks.getAllBotDifficulties(url, info, sessionID);
|
||||
},
|
||||
),
|
||||
new RouteAction(
|
||||
"/singleplayer/settings/bot/maxCap",
|
||||
(url: string, info: any, sessionID: string, output: string): any =>
|
||||
|
Loading…
x
Reference in New Issue
Block a user