From f3b28d532cb74145d5a71b4909528bfb103f9ba2 Mon Sep 17 00:00:00 2001 From: Dev Date: Thu, 18 May 2023 17:23:28 +0100 Subject: [PATCH] Refactor convertBotDifficultyDropdownToBotDifficulty() ot use switch statement --- project/src/helpers/BotDifficultyHelper.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/project/src/helpers/BotDifficultyHelper.ts b/project/src/helpers/BotDifficultyHelper.ts index 4ba1bdbb..3cbde021 100644 --- a/project/src/helpers/BotDifficultyHelper.ts +++ b/project/src/helpers/BotDifficultyHelper.ts @@ -98,17 +98,15 @@ export class BotDifficultyHelper */ public convertBotDifficultyDropdownToBotDifficulty(dropDownDifficulty: string): string { - if (dropDownDifficulty.toLowerCase() === "medium") + switch (dropDownDifficulty.toLowerCase()) { - return "normal"; + case "medium": + return "normal"; + case "random": + return this.chooseRandomDifficulty(); + default: + return dropDownDifficulty.toLowerCase(); } - - if (dropDownDifficulty.toLowerCase() === "random") - { - return this.chooseRandomDifficulty(); - } - - return dropDownDifficulty.toLowerCase(); } /**