Improved how generateMultipleBotsAndCache()
and returnSingleBotFromCache()
handles missing raid settings from AppContext
This commit is contained in:
parent
5697bd8783
commit
8f67f75930
@ -186,7 +186,7 @@ export class BotController {
|
|||||||
* @param request Bot generation request object
|
* @param request Bot generation request object
|
||||||
* @param pmcProfile Player profile
|
* @param pmcProfile Player profile
|
||||||
* @param sessionId Session id
|
* @param sessionId Session id
|
||||||
* @returns
|
* @returns IBotBase[]
|
||||||
*/
|
*/
|
||||||
protected async generateMultipleBotsAndCache(
|
protected async generateMultipleBotsAndCache(
|
||||||
request: IGenerateBotsRequestData,
|
request: IGenerateBotsRequestData,
|
||||||
@ -198,10 +198,10 @@ export class BotController {
|
|||||||
?.getValue<IGetRaidConfigurationRequestData>();
|
?.getValue<IGetRaidConfigurationRequestData>();
|
||||||
|
|
||||||
if (raidSettings === undefined) {
|
if (raidSettings === undefined) {
|
||||||
// throw new Error(this.localisationService.getText("bot-unable_to_load_raid_settings_from_appcontext"));
|
this.logger.warning(this.localisationService.getText("bot-unable_to_load_raid_settings_from_appcontext"));
|
||||||
}
|
}
|
||||||
const pmcLevelRangeForMap =
|
|
||||||
this.pmcConfig.locationSpecificPmcLevelOverride[raidSettings?.location.toLowerCase()];
|
const pmcLevelRangeForMap = this.getPmcLevelRangeForMap(raidSettings?.location);
|
||||||
|
|
||||||
const allPmcsHaveSameNameAsPlayer = this.randomUtil.getChance100(
|
const allPmcsHaveSameNameAsPlayer = this.randomUtil.getChance100(
|
||||||
this.pmcConfig.allPMCsHavePlayerNameWithRandomPrefixChance,
|
this.pmcConfig.allPMCsHavePlayerNameWithRandomPrefixChance,
|
||||||
@ -221,12 +221,27 @@ export class BotController {
|
|||||||
conditionPromises.push(this.generateWithBotDetails(condition, botGenerationDetails, sessionId));
|
conditionPromises.push(this.generateWithBotDetails(condition, botGenerationDetails, sessionId));
|
||||||
}
|
}
|
||||||
|
|
||||||
await Promise.all(conditionPromises).then((p) => Promise.all(p)).catch((ex) => {
|
await Promise.all(conditionPromises)
|
||||||
|
.then((p) => Promise.all(p))
|
||||||
|
.catch((ex) => {
|
||||||
this.logger.error(ex);
|
this.logger.error(ex);
|
||||||
});
|
});
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get min/max level range values for a specific map
|
||||||
|
* @param location Map name e.g. factory4_day
|
||||||
|
* @returns MinMax
|
||||||
|
*/
|
||||||
|
protected getPmcLevelRangeForMap(location: string): MinMax {
|
||||||
|
if (!location) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.pmcConfig.locationSpecificPmcLevelOverride[location.toLowerCase()];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a BotGenerationDetails for the bot generator to use
|
* Create a BotGenerationDetails for the bot generator to use
|
||||||
* @param condition Client data defining bot type and difficulty
|
* @param condition Client data defining bot type and difficulty
|
||||||
@ -363,12 +378,12 @@ export class BotController {
|
|||||||
?.getValue<IGetRaidConfigurationRequestData>();
|
?.getValue<IGetRaidConfigurationRequestData>();
|
||||||
|
|
||||||
if (raidSettings === undefined) {
|
if (raidSettings === undefined) {
|
||||||
throw new Error(this.localisationService.getText("bot-unable_to_load_raid_settings_from_appcontext"));
|
this.logger.warning(this.localisationService.getText("bot-unable_to_load_raid_settings_from_appcontext"));
|
||||||
}
|
}
|
||||||
const pmcLevelRangeForMap =
|
|
||||||
this.pmcConfig.locationSpecificPmcLevelOverride[raidSettings.location.toLowerCase()];
|
|
||||||
|
|
||||||
// Create gen request for when cache is empty
|
const pmcLevelRangeForMap = this.getPmcLevelRangeForMap(raidSettings?.location);
|
||||||
|
|
||||||
|
// Create generation request for when cache is empty
|
||||||
const condition: Condition = {
|
const condition: Condition = {
|
||||||
Role: requestedBot.Role,
|
Role: requestedBot.Role,
|
||||||
Limit: 5,
|
Limit: 5,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user