diff --git a/Generator/Helpers/DifficultyHelper.cs b/Generator/Helpers/DifficultyHelper.cs index ab96881..65da6ec 100644 --- a/Generator/Helpers/DifficultyHelper.cs +++ b/Generator/Helpers/DifficultyHelper.cs @@ -1,9 +1,6 @@ using Common.Models.Output; using Common.Models.Output.Difficulty; using Newtonsoft.Json; -using System.Collections.Generic; -using System.IO; -using System.Linq; namespace Generator.Helpers { @@ -16,13 +13,17 @@ namespace Generator.Helpers // Read bot setting files from assets folder that match this bots type // Save into dictionary with difficulty as key var difficultySettingsJsons = new Dictionary(); - foreach (var path in difficultyFilePaths.Where(x=>x.Contains($"_{botToUpdate.botType}", System.StringComparison.InvariantCultureIgnoreCase))) + var botType = botToUpdate.botType.ToString(); + var pathsWithBotType = difficultyFilePaths.Where(x => x.Contains($"_{botType}", StringComparison.InvariantCultureIgnoreCase)); + foreach (var path in pathsWithBotType) { var json = File.ReadAllText(path); - var serialisedObject = JsonConvert.DeserializeObject(json); + var serialisedDifficultySettings = JsonConvert.DeserializeObject(json); + + serialisedDifficultySettings = ApplyCustomDifficultyValues(botType, serialisedDifficultySettings); var difficultyOfFile = GetFileDifficultyFromPath(path); - difficultySettingsJsons.Add(difficultyOfFile, serialisedObject); + difficultySettingsJsons.Add(difficultyOfFile, serialisedDifficultySettings); } // Find each difficulty in dictionary and save into bot @@ -41,6 +42,48 @@ namespace Generator.Helpers } } + private static DifficultySettings ApplyCustomDifficultyValues(string botType, DifficultySettings difficultySettings) + { + switch (botType) + { + // make all bosses fight PMCs + case "bosskilla": + case "bossgluhar": + case "bosstagilla": + case "bossbully": + case "bosskojaniy": + AddHostileToPMCSettings(difficultySettings); + break; + default: + break; + } + + return difficultySettings; + } + + private static void AddHostileToPMCSettings(DifficultySettings settings) + { + var defaultEnemyUsecKey = "DEFAULT_ENEMY_USEC"; + if (settings.Mind.ContainsKey(defaultEnemyUsecKey)) + { + settings.Mind[defaultEnemyUsecKey] = true; + } + else + { + settings.Mind.Add(defaultEnemyUsecKey, true); + } + + var defaultEnemyBearKey = "DEFAULT_ENEMY_BEAR"; + if (settings.Mind.ContainsKey(defaultEnemyUsecKey)) + { + settings.Mind[defaultEnemyBearKey] = true; + } + else + { + settings.Mind.Add(defaultEnemyBearKey, true); + } + } + private static string GetFileDifficultyFromPath(string path) { // Split path into parts and find the last part (filename)