Reworked getBotCap()
to use data from url instead of appContext
This commit is contained in:
parent
0864b0074b
commit
f20ffe286b
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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<IGetRaidConfigurationRequestData>();
|
||||
|
||||
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;
|
||||
|
@ -39,7 +39,7 @@ export class BotDynamicRouter extends DynamicRouter
|
||||
"/singleplayer/settings/bot/maxCap",
|
||||
async (url: string, info: any, sessionID: string, output: string): Promise<string> =>
|
||||
{
|
||||
return this.botCallbacks.getBotCap();
|
||||
return this.botCallbacks.getBotCap(url, info, sessionID);
|
||||
},
|
||||
),
|
||||
new RouteAction(
|
||||
|
Loading…
x
Reference in New Issue
Block a user