From 1d7113a5497f1a1b915196a31ff73c1f13116015 Mon Sep 17 00:00:00 2001 From: Chomp Date: Sun, 13 Nov 2022 22:13:20 +0000 Subject: [PATCH] Update types --- .../types/callbacks/BotCallbacks.d.ts | 6 +-- .../types/controllers/BotController.d.ts | 10 ++-- .../types/generators/BotGenerator.d.ts | 11 +++-- .../types/helpers/BotDifficultyHelper.d.ts | 46 +++++++++++++++++++ .../types/helpers/BotHelper.d.ts | 25 ---------- .../types/models/spt/config/IBotConfig.d.ts | 2 + .../services/BotGenerationCacheService.d.ts | 24 ++-------- 7 files changed, 65 insertions(+), 59 deletions(-) create mode 100644 TypeScript/1LogToConsole/types/helpers/BotDifficultyHelper.d.ts diff --git a/TypeScript/1LogToConsole/types/callbacks/BotCallbacks.d.ts b/TypeScript/1LogToConsole/types/callbacks/BotCallbacks.d.ts index 0436bba..9319ea3 100644 --- a/TypeScript/1LogToConsole/types/callbacks/BotCallbacks.d.ts +++ b/TypeScript/1LogToConsole/types/callbacks/BotCallbacks.d.ts @@ -28,9 +28,5 @@ export declare class BotCallbacks { * @returns string */ getBotCap(): string; - /** - * Handle /singleplayer/settings/bot/getBotBehaviour/ - * @returns string - */ - getBotBehaviour(url: string, info: IEmptyRequestData, sessionID: string): string; + getBotBehaviours(): string; } diff --git a/TypeScript/1LogToConsole/types/controllers/BotController.d.ts b/TypeScript/1LogToConsole/types/controllers/BotController.d.ts index b71f6d5..92317c3 100644 --- a/TypeScript/1LogToConsole/types/controllers/BotController.d.ts +++ b/TypeScript/1LogToConsole/types/controllers/BotController.d.ts @@ -1,5 +1,6 @@ import { ApplicationContext } from "../context/ApplicationContext"; import { BotGenerator } from "../generators/BotGenerator"; +import { BotDifficultyHelper } from "../helpers/BotDifficultyHelper"; import { BotHelper } from "../helpers/BotHelper"; import { WeightedRandomHelper } from "../helpers/WeightedRandomHelper"; import { IGenerateBotsRequestData } from "../models/eft/bot/IGenerateBotsRequestData"; @@ -12,18 +13,22 @@ import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { BotGenerationCacheService } from "../services/BotGenerationCacheService"; import { LocalisationService } from "../services/LocalisationService"; +import { JsonUtil } from "../utils/JsonUtil"; export declare class BotController { protected logger: ILogger; protected databaseServer: DatabaseServer; protected botGenerator: BotGenerator; protected botHelper: BotHelper; + protected botDifficultyHelper: BotDifficultyHelper; protected botGenerationCacheService: BotGenerationCacheService; protected localisationService: LocalisationService; protected weightedRandomHelper: WeightedRandomHelper; protected configServer: ConfigServer; protected applicationContext: ApplicationContext; + protected jsonUtil: JsonUtil; protected botConfig: IBotConfig; - constructor(logger: ILogger, databaseServer: DatabaseServer, botGenerator: BotGenerator, botHelper: BotHelper, botGenerationCacheService: BotGenerationCacheService, localisationService: LocalisationService, weightedRandomHelper: WeightedRandomHelper, configServer: ConfigServer, applicationContext: ApplicationContext); + static readonly pmcTypeLabel = "PMC"; + constructor(logger: ILogger, databaseServer: DatabaseServer, botGenerator: BotGenerator, botHelper: BotHelper, botDifficultyHelper: BotDifficultyHelper, botGenerationCacheService: BotGenerationCacheService, localisationService: LocalisationService, weightedRandomHelper: WeightedRandomHelper, configServer: ConfigServer, applicationContext: ApplicationContext, jsonUtil: JsonUtil); /** * Return the number of bot loadout varieties to be generated * @param type bot Type we want the loadout gen count for @@ -39,7 +44,6 @@ export declare class BotController { * @returns Difficulty object */ getBotDifficulty(type: string, difficulty: string): Difficulty; - protected getPmcDifficultySettings(pmcType: "bear" | "usec", difficulty: string, usecType: string, bearType: string): Difficulty; /** * Generate bot profiles and store in cache * @param sessionId Session id @@ -53,5 +57,5 @@ export declare class BotController { * @returns cap number */ getBotCap(): number; - getPmcBotType(botType: string): string; + getPmcBotTypes(): Record>>; } diff --git a/TypeScript/1LogToConsole/types/generators/BotGenerator.d.ts b/TypeScript/1LogToConsole/types/generators/BotGenerator.d.ts index b5217c0..a1ac9ed 100644 --- a/TypeScript/1LogToConsole/types/generators/BotGenerator.d.ts +++ b/TypeScript/1LogToConsole/types/generators/BotGenerator.d.ts @@ -1,8 +1,8 @@ +import { BotDifficultyHelper } from "../helpers/BotDifficultyHelper"; import { BotHelper } from "../helpers/BotHelper"; import { GameEventHelper } from "../helpers/GameEventHelper"; import { ProfileHelper } from "../helpers/ProfileHelper"; import { WeightedRandomHelper } from "../helpers/WeightedRandomHelper"; -import { IGenerateBotsRequestData } from "../models/eft/bot/IGenerateBotsRequestData"; import { Health as PmcHealth, IBotBase, Skills } from "../models/eft/common/tables/IBotBase"; import { Health, IBotType, Inventory } from "../models/eft/common/tables/IBotType"; import { IBotConfig } from "../models/spt/config/IBotConfig"; @@ -31,10 +31,11 @@ export declare class BotGenerator { protected botEquipmentFilterService: BotEquipmentFilterService; protected weightedRandomHelper: WeightedRandomHelper; protected botHelper: BotHelper; + protected botDifficultyHelper: BotDifficultyHelper; protected gameEventHelper: GameEventHelper; protected configServer: ConfigServer; protected botConfig: IBotConfig; - constructor(logger: ILogger, hashUtil: HashUtil, randomUtil: RandomUtil, jsonUtil: JsonUtil, profileHelper: ProfileHelper, databaseServer: DatabaseServer, botInventoryGenerator: BotInventoryGenerator, botEquipmentFilterService: BotEquipmentFilterService, weightedRandomHelper: WeightedRandomHelper, botHelper: BotHelper, gameEventHelper: GameEventHelper, configServer: ConfigServer); + constructor(logger: ILogger, hashUtil: HashUtil, randomUtil: RandomUtil, jsonUtil: JsonUtil, profileHelper: ProfileHelper, databaseServer: DatabaseServer, botInventoryGenerator: BotInventoryGenerator, botEquipmentFilterService: BotEquipmentFilterService, weightedRandomHelper: WeightedRandomHelper, botHelper: BotHelper, botDifficultyHelper: BotDifficultyHelper, gameEventHelper: GameEventHelper, configServer: ConfigServer); /** * Generate a player scav bot object * @param role e.g. assault / pmcbot @@ -44,12 +45,12 @@ export declare class BotGenerator { */ generatePlayerScav(sessionId: string, role: string, difficulty: string, botTemplate: IBotType): IBotBase; /** - * Generate an array of bot objects for populate a raid with + * Generate an array of bot objects based on a condition for a raid with * @param sessionId session id - * @param info request object + * @param condition request condition * @returns bot array */ - generate(sessionId: string, info: IGenerateBotsRequestData): IBotBase[]; + generateByCondition(sessionId: string, botCountToGenerate: number, difficulty: string, role: string, isPmc: boolean): IBotBase[]; /** * Get the PMCs wildSpawnType value * @param role "usec" / "bear" diff --git a/TypeScript/1LogToConsole/types/helpers/BotDifficultyHelper.d.ts b/TypeScript/1LogToConsole/types/helpers/BotDifficultyHelper.d.ts new file mode 100644 index 0000000..a58ebdb --- /dev/null +++ b/TypeScript/1LogToConsole/types/helpers/BotDifficultyHelper.d.ts @@ -0,0 +1,46 @@ +import { Difficulty } from "../models/eft/common/tables/IBotType"; +import { IBotConfig } from "../models/spt/config/IBotConfig"; +import { ILogger } from "../models/spt/utils/ILogger"; +import { ConfigServer } from "../servers/ConfigServer"; +import { DatabaseServer } from "../servers/DatabaseServer"; +import { LocalisationService } from "../services/LocalisationService"; +import { JsonUtil } from "../utils/JsonUtil"; +import { RandomUtil } from "../utils/RandomUtil"; +import { BotHelper } from "./BotHelper"; +export declare class BotDifficultyHelper { + protected logger: ILogger; + protected jsonUtil: JsonUtil; + protected databaseServer: DatabaseServer; + protected randomUtil: RandomUtil; + protected localisationService: LocalisationService; + protected botHelper: BotHelper; + protected configServer: ConfigServer; + protected botConfig: IBotConfig; + constructor(logger: ILogger, jsonUtil: JsonUtil, databaseServer: DatabaseServer, randomUtil: RandomUtil, localisationService: LocalisationService, botHelper: BotHelper, configServer: ConfigServer); + getPmcDifficultySettings(pmcType: "bear" | "usec", difficulty: string, usecType: string, bearType: string): Difficulty; + /** + * Get difficulty settings for desired bot type, if not found use assault bot types + * @param type bot type to retreive difficulty of + * @param difficulty difficulty to get settings for (easy/normal etc) + * @returns Difficulty object + */ + getBotDifficultySettings(type: string, difficulty: string): Difficulty; + /** + * Get difficulty settings for a PMC + * @param type "usec" / "bear" + * @param difficulty what difficulty to retrieve + * @returns Difficulty object + */ + protected getDifficultySettings(type: string, difficulty: string): Difficulty; + /** + * Translate chosen value from pre-raid difficulty dropdown into bot difficulty value + * @param dropDownDifficulty Dropdown difficulty value to convert + * @returns bot difficulty + */ + convertBotDifficultyDropdownToBotDifficulty(dropDownDifficulty: string): string; + /** + * Choose a random difficulty from - easy/normal/hard/impossible + * @returns random difficulty + */ + chooseRandomDifficulty(): string; +} diff --git a/TypeScript/1LogToConsole/types/helpers/BotHelper.d.ts b/TypeScript/1LogToConsole/types/helpers/BotHelper.d.ts index a87acf6..a7f779e 100644 --- a/TypeScript/1LogToConsole/types/helpers/BotHelper.d.ts +++ b/TypeScript/1LogToConsole/types/helpers/BotHelper.d.ts @@ -15,37 +15,12 @@ export declare class BotHelper { protected configServer: ConfigServer; protected botConfig: IBotConfig; constructor(logger: ILogger, jsonUtil: JsonUtil, databaseServer: DatabaseServer, randomUtil: RandomUtil, localisationService: LocalisationService, configServer: ConfigServer); - /** - * Get difficulty settings for desired bot type, if not found use assault bot types - * @param type bot type to retreive difficulty of - * @param difficulty difficulty to get settings for (easy/normal etc) - * @returns Difficulty object - */ - getBotDifficultySettings(type: string, difficulty: string): Difficulty; /** * Get a template object for the specified botRole from bots.types db * @param role botRole to get template for * @returns IBotType object */ getBotTemplate(role: string): IBotType; - /** - * Get difficulty settings for a PMC - * @param type "usec" / "bear" - * @param difficulty what difficulty to retrieve - * @returns Difficulty object - */ - getPmcDifficultySettings(type: string, difficulty: string): Difficulty; - /** - * Translate chosen value from pre-raid difficulty dropdown into bot difficulty value - * @param dropDownDifficulty Dropdown difficulty value to convert - * @returns bot difficulty - */ - convertBotDifficultyDropdownToBotDifficulty(dropDownDifficulty: string): string; - /** - * Choose a random difficulty from - easy/normal/hard/impossible - * @returns random difficulty - */ - chooseRandomDifficulty(): string; /** * Randomise the chance the PMC will attack their own side * Look up value in bot.json/chanceSameSideIsHostilePercent diff --git a/TypeScript/1LogToConsole/types/models/spt/config/IBotConfig.d.ts b/TypeScript/1LogToConsole/types/models/spt/config/IBotConfig.d.ts index de5ca0a..d6fa5e0 100644 --- a/TypeScript/1LogToConsole/types/models/spt/config/IBotConfig.d.ts +++ b/TypeScript/1LogToConsole/types/models/spt/config/IBotConfig.d.ts @@ -27,6 +27,8 @@ export interface IBotConfig extends IBaseConfig { maxBotCap: Record; /** How many stacks of secret ammo should a bot have in its bot secure container */ secureContainerAmmoStackCount: number; + /** Batch generation size when type not available in cache */ + botGenerationBatchSizePerType: number; } export interface PresetBatch { assault: number; diff --git a/TypeScript/1LogToConsole/types/services/BotGenerationCacheService.d.ts b/TypeScript/1LogToConsole/types/services/BotGenerationCacheService.d.ts index ba53fec..505cfc8 100644 --- a/TypeScript/1LogToConsole/types/services/BotGenerationCacheService.d.ts +++ b/TypeScript/1LogToConsole/types/services/BotGenerationCacheService.d.ts @@ -8,7 +8,7 @@ export declare class BotGenerationCacheService { protected randomUtil: RandomUtil; protected jsonUtil: JsonUtil; protected botHelper: BotHelper; - protected storedBots: IBotBase[]; + protected storedBots: Map; constructor(logger: ILogger, randomUtil: RandomUtil, jsonUtil: JsonUtil, botHelper: BotHelper); /** * Store array of bots in cache, shuffle results before storage @@ -21,25 +21,7 @@ export declare class BotGenerationCacheService { * @param role role to retreive (assault/bossTagilla etc) * @returns IBotBase object */ - getBot(role: string): IBotBase[]; - /** - * Find a bot by its index from cache - * @param indexOfBotToReturn index to find bot by - * @returns bot profile - */ - protected getBotFromCache(indexOfBotToReturn: number): IBotBase; - /** - * Remove bot profile by index from cache - * @param indexOfBotToReturn Index of bot profile to remove - */ - protected removeBotFromCache(indexOfBotToReturn: number): void; - /** - * Get index of bot profile that matches criteria - * @param role Role of bot wanted - * @param getPmc Requested bot a pmc - * @returns index of found bot, -1 if not found - */ - protected getIndexOfBotToReturn(role: string, getPmc: boolean): number; + getBot(role: string): IBotBase; /** * Remove all cached bot profiles */ @@ -48,5 +30,5 @@ export declare class BotGenerationCacheService { * Does cache have bots * @returns true if empty */ - cacheIsEmpty(): boolean; + cacheHasBotOfRole(role: string): boolean; }