From 1d8bc4537c9db3a657c68bfe61692670f6290921 Mon Sep 17 00:00:00 2001 From: Dev Date: Tue, 14 May 2024 15:45:04 +0100 Subject: [PATCH] Fix issue with `getBotDifficultySettings()` cloning assault bot correctly when bot type not found but storing it against the new bot type with preserved caps, resulting in getting difficulty values failing --- project/src/helpers/BotDifficultyHelper.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/project/src/helpers/BotDifficultyHelper.ts b/project/src/helpers/BotDifficultyHelper.ts index d63347b0..2305d7e6 100644 --- a/project/src/helpers/BotDifficultyHelper.ts +++ b/project/src/helpers/BotDifficultyHelper.ts @@ -56,26 +56,27 @@ export class BotDifficultyHelper */ public getBotDifficultySettings(type: string, difficulty: string): Difficulty { - const bot = this.databaseServer.getTables().bots.types[type]; + const desiredType = type.toLowerCase(); + const bot = this.databaseServer.getTables().bots.types[desiredType]; if (!bot) { // get fallback this.logger.warning(this.localisationService.getText("bot-unable_to_get_bot_fallback_to_assault", type)); - this.databaseServer.getTables().bots.types[type] = this.cloner.clone( + this.databaseServer.getTables().bots.types[desiredType] = this.cloner.clone( this.databaseServer.getTables().bots.types.assault, ); } - const difficultySettings = this.botHelper.getBotTemplate(type).difficulty[difficulty]; + const difficultySettings = this.botHelper.getBotTemplate(desiredType).difficulty[difficulty]; if (!difficultySettings) { this.logger.warning( this.localisationService.getText("bot-unable_to_get_bot_difficulty_fallback_to_assault", { - botType: type, + botType: desiredType, difficulty: difficulty, }), ); - this.databaseServer.getTables().bots.types[type].difficulty[difficulty] = this.cloner.clone( + this.databaseServer.getTables().bots.types[desiredType].difficulty[difficulty] = this.cloner.clone( this.databaseServer.getTables().bots.types.assault.difficulty[difficulty], ); }