diff --git a/project/src/callbacks/BotCallbacks.ts b/project/src/callbacks/BotCallbacks.ts index 6631ba8f..ff72176c 100644 --- a/project/src/callbacks/BotCallbacks.ts +++ b/project/src/callbacks/BotCallbacks.ts @@ -74,9 +74,11 @@ export class BotCallbacks * Handle singleplayer/settings/bot/maxCap * @returns string */ - public getBotCap(): string + public getBotCap(url: string, info: any, sessionID: string): string { - return this.httpResponse.noBody(this.botController.getBotCap()); + const splitUrl = url.split("/"); + const location = splitUrl[splitUrl.length - 1]; + return this.httpResponse.noBody(this.botController.getBotCap(location)); } /** diff --git a/project/src/controllers/BotController.ts b/project/src/controllers/BotController.ts index 062d0e28..f8c9bdd9 100644 --- a/project/src/controllers/BotController.ts +++ b/project/src/controllers/BotController.ts @@ -487,32 +487,20 @@ export class BotController /** * Get the max number of bots allowed on a map * Looks up location player is entering when getting cap value + * @param location The map location cap was requested for * @returns cap number */ - public getBotCap(): number + public getBotCap(location: string): number { - const defaultMapCapId = "default"; - const raidConfig = this.applicationContext - .getLatestValue(ContextVariableType.RAID_CONFIGURATION) - ?.getValue(); - - if (!raidConfig) - { - this.logger.warning(this.localisationService.getText("bot-missing_saved_match_info")); - } - - const mapName = raidConfig ? raidConfig.location : defaultMapCapId; - - let botCap = this.botConfig.maxBotCap[mapName.toLowerCase()]; - if (!botCap) + const botCap = this.botConfig.maxBotCap[location.toLowerCase()]; + if (location === "default") { this.logger.warning( this.localisationService.getText( "bot-no_bot_cap_found_for_location", - raidConfig?.location.toLowerCase(), + location.toLowerCase(), ), ); - botCap = this.botConfig.maxBotCap[defaultMapCapId]; } return botCap; diff --git a/project/src/routers/dynamic/BotDynamicRouter.ts b/project/src/routers/dynamic/BotDynamicRouter.ts index c827357d..b3612a84 100644 --- a/project/src/routers/dynamic/BotDynamicRouter.ts +++ b/project/src/routers/dynamic/BotDynamicRouter.ts @@ -39,7 +39,7 @@ export class BotDynamicRouter extends DynamicRouter "/singleplayer/settings/bot/maxCap", async (url: string, info: any, sessionID: string, output: string): Promise => { - return this.botCallbacks.getBotCap(); + return this.botCallbacks.getBotCap(url, info, sessionID); }, ), new RouteAction(