diff --git a/Common.Models/GenerationWeightData.cs b/Common.Models/GenerationWeightData.cs new file mode 100644 index 0000000..78e4144 --- /dev/null +++ b/Common.Models/GenerationWeightData.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; + +namespace Common.Models +{ + public class GenerationWeightData + { + public Dictionary weights { get; set; } + public List whitelist { get; set; } + } +} diff --git a/Common.Models/Output/Output.cs b/Common.Models/Output/Output.cs index 20232a8..90ab8a7 100644 --- a/Common.Models/Output/Output.cs +++ b/Common.Models/Output/Output.cs @@ -7,14 +7,12 @@ namespace Common.Models.Output; [JsonSourceGenerationOptions(GenerationMode = JsonSourceGenerationMode.Serialization, WriteIndented = true)] public partial class BotJsonContext : JsonSerializerContext { - } public class Bot { public Bot() { - } public Bot(BotType botType) @@ -183,23 +181,28 @@ public class EquipmentChances public class GenerationChances { - public GenerationChances(int specialMin, int SpecialMax, - int healingMin, int healingMax, - int drugMin, int drugMax, - int stimMin, int stimMax, - int looseLootMin, int looseLootMax, - int magazinesMin, int MagazineMax, - int grenandesMin, int grenadesMax) + public GenerationChances( + GenerationWeightData specialItems, + GenerationWeightData healingItems, + GenerationWeightData drugItems, + GenerationWeightData stimItems, + GenerationWeightData backpackLootItems, + GenerationWeightData pocketLootItems, + GenerationWeightData vestLootItems, + GenerationWeightData magazineItems, + GenerationWeightData grenadeItems) { items = new ItemChances { - specialItems = new MinMax(specialMin, SpecialMax), - healing = new MinMax(healingMin, healingMax), - drugs = new MinMax(drugMin, drugMax), - stims = new MinMax(stimMin, stimMax), - looseLoot = new MinMax(looseLootMin, looseLootMax), - magazines = new MinMax(magazinesMin, MagazineMax), - grenades = new MinMax(grenandesMin, grenadesMax) + specialItems = specialItems, + healing = healingItems, + drugs = drugItems, + stims = stimItems, + backpackLoot = backpackLootItems, + pocketLoot = pocketLootItems, + vestLoot = vestLootItems, + magazines = magazineItems, + grenades = grenadeItems }; } @@ -215,22 +218,26 @@ public class ItemChances { public ItemChances() { - specialItems = new MinMaxWithWhitelist(0, 1, System.Array.Empty()); - healing = new MinMaxWithWhitelist(1, 2, System.Array.Empty()); - drugs = new MinMaxWithWhitelist(0, 1, System.Array.Empty()); - stims = new MinMaxWithWhitelist(0, 1, System.Array.Empty()); - looseLoot = new MinMaxWithWhitelist(0, 3, System.Array.Empty()); - magazines = new MinMaxWithWhitelist(2, 4, System.Array.Empty()); - grenades = new MinMaxWithWhitelist(0, 5, System.Array.Empty()); + specialItems = new GenerationWeightData(); // 0,1 + healing = new GenerationWeightData(); // 1, 2 + drugs = new GenerationWeightData(); // 0, 1 + stims = new GenerationWeightData(); // 0, 1 + backpackLoot = new GenerationWeightData(); //0,3 + pocketLoot = new GenerationWeightData(); + vestLoot = new GenerationWeightData(); + magazines = new GenerationWeightData(); //2,4 + grenades = new GenerationWeightData(); //0,5 } - public MinMax specialItems { get; set; } - public MinMax healing { get; set; } - public MinMax drugs { get; set; } - public MinMax stims { get; set; } - public MinMax looseLoot { get; set; } - public MinMax magazines { get; set; } - public MinMax grenades { get; set; } + public GenerationWeightData specialItems { get; set; } + public GenerationWeightData healing { get; set; } + public GenerationWeightData drugs { get; set; } + public GenerationWeightData stims { get; set; } + public GenerationWeightData backpackLoot { get; set; } + public GenerationWeightData pocketLoot { get; set; } + public GenerationWeightData vestLoot { get; set; } + public GenerationWeightData magazines { get; set; } + public GenerationWeightData grenades { get; set; } } public class MinMax @@ -244,15 +251,3 @@ public class MinMax public int min { get; set; } public int max { get; set; } } - -public class MinMaxWithWhitelist : MinMax -{ - public MinMaxWithWhitelist(int min, int max, string[] whitelist) : base(min, max) - { - this.min = min; - this.max = max; - this.whitelist = whitelist; - } - - public string[] whitelist { get; set; } -} diff --git a/Generator/Assets/generationWeights.json b/Generator/Assets/generationWeights.json new file mode 100644 index 0000000..70ec951 --- /dev/null +++ b/Generator/Assets/generationWeights.json @@ -0,0 +1,879 @@ +{ + "assault": { + "specialItems": { + "weights": { + "0": 1, + "1": 0 + }, + "whitelist": [] + }, + "healing": { + "weights": { + "0": 1, + "1": 2, + "2": 1 + }, + "whitelist": [] + }, + "drugs": { + "weights": { + "0": 1, + "1": 2, + "2": 0 + }, + "whitelist": [] + }, + "stims": { + "weights": { + "0": 15, + "1": 5, + "2": 1 + }, + "whitelist": [] + }, + "backpackLoot": { + "weights": { + "0": 1, + "1": 2, + "2": 2, + "3": 1, + "4": 1, + "5": 1, + "6": 1 + }, + "whitelist": [] + }, + "pocketLoot": { + "weights": { + "0": 1, + "1": 6, + "2": 3, + "3": 1, + "4": 1 + }, + "whitelist": [] + }, + "vestLoot": { + "weights": { + "0": 1, + "1": 1, + "2": 2, + "3": 1, + "4": 0, + "5": 0, + "6": 0 + }, + "whitelist": [] + }, + "magazines": { + "weights": { + "0": 0, + "1": 0, + "2": 1, + "3": 3, + "4": 1 + }, + "whitelist": [] + }, + "grenades": { + "weights": { + "0": 1, + "1": 2, + "2": 1, + "3": 1, + "4": 0, + "5": 0 + }, + "whitelist": [] + } + }, + "marksman": { + "specialItems": { + "weights": { + "0": 1, + "1": 0 + }, + "whitelist": [] + }, + "healing": { + "weights": { + "0": 0, + "1": 2, + "2": 1 + }, + "whitelist": [] + }, + "drugs": { + "weights": { + "0": 1, + "1": 2, + "2": 0 + }, + "whitelist": [] + }, + "stims": { + "weights": { + "0": 3, + "1": 1, + "2": 0 + }, + "whitelist": [] + }, + "backpackLoot": { + "weights": { + "0": 1, + "1": 1, + "2": 2, + "3": 1, + "4": 1, + "5": 1, + "6": 1, + "7": 0 + }, + "whitelist": [] + }, + "pocketLoot": { + "weights": { + "0": 3, + "1": 10, + "2": 3, + "3": 1, + "4": 1 + }, + "whitelist": [] + }, + "vestLoot": { + "weights": { + "0": 1, + "1": 2, + "2": 2, + "3": 0, + "4": 0, + "5": 0, + "6": 0 + }, + "whitelist": [] + }, + "magazines": { + "weights": { + "0": 0, + "1": 0, + "2": 1, + "3": 3, + "4": 1 + }, + "whitelist": [] + }, + "grenades": { + "weights": { + "0": 1, + "1": 2, + "2": 1, + "3": 1, + "4": 1, + "5": 0 + }, + "whitelist": [] + } + }, + "default": { + "specialItems": { + "weights": { + "0": 1, + "1": 0 + }, + "whitelist": [] + }, + "healing": { + "weights": { + "0": 1, + "1": 2, + "2": 1 + }, + "whitelist": [] + }, + "drugs": { + "weights": { + "0": 1, + "1": 2, + "2": 0 + }, + "whitelist": [] + }, + "stims": { + "weights": { + "0": 2, + "1": 1, + "2": 0 + }, + "whitelist": [] + }, + "backpackLoot": { + "weights": { + "0": 1, + "1": 1, + "2": 2, + "3": 1, + "4": 1, + "5": 1, + "6": 1, + "7": 0 + }, + "whitelist": [] + }, + "pocketLoot": { + "weights": { + "0": 1, + "1": 6, + "2": 3, + "3": 1, + "4": 1 + }, + "whitelist": [] + }, + "vestLoot": { + "weights": { + "0": 1, + "1": 1, + "2": 2, + "3": 1, + "4": 0, + "5": 0, + "6": 0 + }, + "whitelist": [] + }, + "magazines": { + "weights": { + "0": 0, + "1": 0, + "2": 1, + "3": 3, + "4": 1 + }, + "whitelist": [] + }, + "grenades": { + "weights": { + "0": 1, + "1": 2, + "2": 1, + "3": 1, + "4": 0, + "5": 0 + }, + "whitelist": [] + } + }, + "followerboar": { + "specialItems": { + "weights": { + "0": 1, + "1": 0 + }, + "whitelist": [] + }, + "healing": { + "weights": { + "0": 1, + "1": 2, + "2": 3, + "3": 5, + "4": 2, + "5": 1 + }, + "whitelist": [] + }, + "drugs": { + "weights": { + "0": 1, + "1": 9, + "2": 3, + "3": 2, + "4": 1 + }, + "whitelist": [] + }, + "stims": { + "weights": { + "0": 9, + "1": 5, + "2": 2, + "3": 1, + }, + "whitelist": [] + }, + "backpackLoot": { + "weights": { + "0": 1, + "1": 4, + "2": 13, + "3": 3, + "4": 1, + "5": 1, + "6": 1, + "7": 0 + }, + "whitelist": [] + }, + "pocketLoot": { + "weights": { + "0": 1, + "1": 6, + "2": 3, + "3": 1, + "4": 1 + }, + "whitelist": [] + }, + "vestLoot": { + "weights": { + "0": 1, + "1": 1, + "2": 2, + "3": 1, + "4": 0, + "5": 0, + "6": 0 + }, + "whitelist": [] + }, + "magazines": { + "weights": { + "0": 0, + "1": 0, + "2": 1, + "3": 3, + "4": 1 + }, + "whitelist": [] + }, + "grenades": { + "weights": { + "0": 1, + "1": 2, + "2": 1, + "3": 1, + "4": 0, + "5": 0 + }, + "whitelist": [] + } + }, + "pmcbot": { + "specialItems": { + "weights": { + "0": 1, + "1": 0 + }, + "whitelist": [] + }, + "healing": { + "weights": { + "0": 1, + "1": 2, + "2": 1 + }, + "whitelist": [] + }, + "drugs": { + "weights": { + "0": 1, + "1": 2, + "2": 0 + }, + "whitelist": [] + }, + "stims": { + "weights": { + "0": 2, + "1": 1, + "2": 0 + }, + "whitelist": [] + }, + "backpackLoot": { + "weights": { + "0": 1, + "1": 1, + "2": 2, + "3": 1, + "4": 1, + "5": 1, + "6": 1, + "7": 0 + }, + "whitelist": [] + }, + "pocketLoot": { + "weights": { + "0": 1, + "1": 6, + "2": 3, + "3": 1, + "4": 1 + }, + "whitelist": [] + }, + "vestLoot": { + "weights": { + "0": 1, + "1": 3, + "2": 5, + "3": 1, + "4": 1, + "5": 1, + "6": 1 + }, + "whitelist": [] + }, + "magazines": { + "weights": { + "0": 0, + "1": 0, + "2": 1, + "3": 3, + "4": 2 + }, + "whitelist": [] + }, + "grenades": { + "weights": { + "0": 1, + "1": 1, + "2": 5, + "3": 2, + "4": 1, + "5": 1 + }, + "whitelist": [] + } + }, + "bosskojaniy": { + "specialItems": { + "weights": { + "0": 0, + "1": 0, + "2": 1 + }, + "whitelist": [] + }, + "healing": { + "weights": { + "0": 1, + "1": 2, + "2": 1 + }, + "whitelist": [] + }, + "drugs": { + "weights": { + "0": 1, + "1": 2, + "2": 0 + }, + "whitelist": [] + }, + "stims": { + "weights": { + "0": 2, + "1": 1, + "2": 0 + }, + "whitelist": [] + }, + "backpackLoot": { + "weights": { + "0": 1, + "1": 1, + "2": 2, + "3": 1, + "4": 1, + "5": 1, + "6": 1, + "7": 0 + }, + "whitelist": [] + }, + "pocketLoot": { + "weights": { + "0": 1, + "1": 6, + "2": 3, + "3": 1, + "4": 1 + }, + "whitelist": [] + }, + "vestLoot": { + "weights": { + "0": 1, + "1": 3, + "2": 5, + "3": 1, + "4": 1, + "5": 1, + "6": 1 + }, + "whitelist": [] + }, + "magazines": { + "weights": { + "0": 0, + "1": 0, + "2": 1, + "3": 3, + "4": 2 + }, + "whitelist": [] + }, + "grenades": { + "weights": { + "0": 1, + "1": 1, + "2": 5, + "3": 2, + "4": 1, + "5": 1 + }, + "whitelist": [] + } + }, + "bossbully": { + "specialItems": { + "weights": { + "0": 0 + }, + "whitelist": [] + }, + "healing": { + "weights": { + "1": 1, + "2": 2 + }, + "whitelist": [] + }, + "drugs": { + "weights": { + "0": 1, + "1": 2 + }, + "whitelist": [] + }, + "stims": { + "weights": { + "0": 2, + "1": 1, + "2": 0 + }, + "whitelist": [] + }, + "backpackLoot": { + "weights": { + "0": 1, + "1": 1, + "2": 2, + "3": 1, + "4": 1, + "5": 1, + "6": 1, + "7": 0 + }, + "whitelist": [] + }, + "pocketLoot": { + "weights": { + "0": 1, + "1": 6, + "2": 3, + "3": 1, + "4": 1 + }, + "whitelist": [] + }, + "vestLoot": { + "weights": { + "0": 1, + "1": 3, + "2": 5, + "3": 1, + "4": 1, + "5": 1, + "6": 1 + }, + "whitelist": [] + }, + "magazines": { + "weights": { + "0": 0, + "1": 0, + "2": 1, + "3": 3, + "4": 2 + }, + "whitelist": [] + }, + "grenades": { + "weights": { + "0": 1, + "1": 1, + "2": 5, + "3": 2, + "4": 1, + "5": 1 + }, + "whitelist": [] + } + }, + "exusec": { + "specialItems": { + "weights": { + "0": 0 + }, + "whitelist": [] + }, + "healing": { + "weights": { + "0": 1, + "1": 1, + "2": 2 + }, + "whitelist": [] + }, + "drugs": { + "weights": { + "0": 1, + "1": 2 + }, + "whitelist": [] + }, + "stims": { + "weights": { + "0": 5, + "1": 1 + }, + "whitelist": [] + }, + "backpackLoot": { + "weights": { + "0": 1, + "1": 2, + "2": 5, + "3": 3, + "4": 1, + "5": 1, + "6": 1, + "7": 0 + }, + "whitelist": [] + }, + "pocketLoot": { + "weights": { + "0": 1, + "1": 7, + "2": 4, + "3": 1, + "4": 1 + }, + "whitelist": [] + }, + "vestLoot": { + "weights": { + "0": 1, + "1": 3, + "2": 5, + "3": 1, + "4": 1 + }, + "whitelist": [] + }, + "magazines": { + "weights": { + "0": 0, + "1": 0, + "2": 1, + "3": 2, + "4": 3 + }, + "whitelist": [] + }, + "grenades": { + "weights": { + "0": 1, + "1": 1, + "2": 3, + "3": 2, + "4": 2, + "5": 1 + }, + "whitelist": [] + } + }, + "bosskilla": { + "specialItems": { + "weights": { + "0": 0 + }, + "whitelist": [] + }, + "healing": { + "weights": { + "0": 2, + "1": 1, + "2": 1 + }, + "whitelist": [] + }, + "drugs": { + "weights": { + "0": 1, + "1": 2 + }, + "whitelist": [] + }, + "stims": { + "weights": { + "0": 5, + "1": 1 + }, + "whitelist": [] + }, + "backpackLoot": { + "weights": { + "0": 1, + "1": 2, + "2": 5, + "3": 3, + "4": 1, + "5": 1, + "6": 1, + "7": 0 + }, + "whitelist": [] + }, + "pocketLoot": { + "weights": { + "0": 1, + "1": 7, + "2": 4, + "3": 1, + "4": 1 + }, + "whitelist": [] + }, + "vestLoot": { + "weights": { + "0": 1, + "1": 3, + "2": 4, + "3": 1, + "4": 1 + }, + "whitelist": [] + }, + "magazines": { + "weights": { + "0": 0, + "1": 0, + "2": 5, + "3": 6 + }, + "whitelist": [] + }, + "grenades": { + "weights": { + "0": 1, + "1": 2, + "2": 3, + "3": 3, + "4": 1, + "5": 1 + }, + "whitelist": [] + } + }, + "bossgluhar": { + "specialItems": { + "weights": { + "0": 0 + }, + "whitelist": [] + }, + "healing": { + "weights": { + "0": 2, + "1": 1, + "2": 1 + }, + "whitelist": [] + }, + "drugs": { + "weights": { + "0": 1, + "1": 2 + }, + "whitelist": [] + }, + "stims": { + "weights": { + "0": 5, + "1": 1 + }, + "whitelist": [] + }, + "backpackLoot": { + "weights": { + "0": 1, + "1": 1, + "2": 4, + "3": 5, + "4": 2, + "5": 1, + "6": 1, + "7": 1 + }, + "whitelist": [] + }, + "pocketLoot": { + "weights": { + "0": 1, + "1": 7, + "2": 4, + "3": 1, + "4": 1 + }, + "whitelist": [] + }, + "vestLoot": { + "weights": { + "0": 1, + "1": 3, + "2": 4, + "3": 1, + "4": 1 + }, + "whitelist": [] + }, + "magazines": { + "weights": { + "0": 0, + "1": 0, + "2": 5, + "3": 6, + "4": 4 + }, + "whitelist": [] + }, + "grenades": { + "weights": { + "0": 1, + "1": 2, + "2": 3, + "3": 3, + "4": 1, + "5": 1 + }, + "whitelist": [] + } + } +} diff --git a/Generator/Assets/weights.json b/Generator/Assets/weights.json index 85145fb..38dc52d 100644 --- a/Generator/Assets/weights.json +++ b/Generator/Assets/weights.json @@ -194,7 +194,7 @@ "5dcbd56fdbd3d91b3e5468d5": 13 }, "Holster": { - "5b3b713c5acfc4330140bd8d": 1, + "5b3b713c5acfc4330140bd8d": 3, "602a9740da11d6478d5a06dc": 5, "6193a720f8ee7e52e42109ed": 1 } diff --git a/Generator/BaseBotGenerator.cs b/Generator/BaseBotGenerator.cs index 62dc5f3..887961a 100644 --- a/Generator/BaseBotGenerator.cs +++ b/Generator/BaseBotGenerator.cs @@ -23,14 +23,13 @@ namespace Generator baseBots.Add(new Bot(typeToAdd)); } - // Iterate over each bot type wejust made and put some data into them + // Iterate over each bot type we just made and put some data into them foreach (var botToUpdate in baseBots) { var rawBotType = botToUpdate.botType.ToString(); var rawBotsOfSameType = rawBots.Where(x => string.Equals(x.Info.Settings.Role, rawBotType, StringComparison.OrdinalIgnoreCase)) .ToList(); var rawBotsOfSameTypeCount = rawBotsOfSameType.Count.ToString(); - if (rawBotsOfSameType.Count == 0) { @@ -54,6 +53,7 @@ namespace Generator } } + stopwatch.Stop(); LoggingHelpers.LogToConsole($"Finished processing bot base. Took {LoggingHelpers.LogTimeTaken(stopwatch.Elapsed.TotalSeconds)} seconds"); @@ -136,12 +136,10 @@ namespace Generator Head = new MinMax(bot.Health.BodyParts.Head.Health.Current, bot.Health.BodyParts.Head.Health.Maximum), Chest = new MinMax(bot.Health.BodyParts.Chest.Health.Current, bot.Health.BodyParts.Chest.Health.Maximum), Stomach = new MinMax(bot.Health.BodyParts.Stomach.Health.Current, bot.Health.BodyParts.Stomach.Health.Maximum), - LeftArm = new MinMax(bot.Health.BodyParts.LeftArm.Health.Current, bot.Health.BodyParts.LeftArm.Health.Maximum) + LeftArm = new MinMax(bot.Health.BodyParts.LeftArm.Health.Current, bot.Health.BodyParts.LeftArm.Health.Maximum), + RightArm = new MinMax(bot.Health.BodyParts.RightArm.Health.Current, bot.Health.BodyParts.RightArm.Health.Maximum), }; - bodyPartHpToAdd.RightArm.min = bot.Health.BodyParts.RightArm.Health.Current; - bodyPartHpToAdd.RightArm.max = bot.Health.BodyParts.RightArm.Health.Maximum; - bodyPartHpToAdd.LeftLeg.min = bot.Health.BodyParts.LeftLeg.Health.Current; bodyPartHpToAdd.LeftLeg.max = bot.Health.BodyParts.LeftLeg.Health.Maximum; @@ -174,7 +172,6 @@ namespace Generator { botToUpdate.lastName.AddUnique(name[1]); } - } } } diff --git a/Generator/BotChancesGenerator.cs b/Generator/BotChancesGenerator.cs index 7ee16ba..0d9fc5b 100644 --- a/Generator/BotChancesGenerator.cs +++ b/Generator/BotChancesGenerator.cs @@ -6,6 +6,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; +using Generator.Weighting; namespace Generator { @@ -16,6 +17,7 @@ namespace Generator var stopwatch = Stopwatch.StartNew(); LoggingHelpers.LogToConsole("Started processing bot gear"); + var weightHelper = new WeightingService(); foreach (var botToUpdate in botsToUpdate) { var botType = botToUpdate.botType.ToString(); @@ -30,7 +32,7 @@ namespace Generator // TODO: Add check to make sure incoming bot list has gear GearChanceHelpers.CalculateEquipmentChances(botToUpdate, rawParsedBotOfCurrentType); - GearChanceHelpers.AddGenerationChances(botToUpdate); + GearChanceHelpers.AddGenerationChances(botToUpdate, rawBots, weightHelper); GearChanceHelpers.CalculateModChances(botToUpdate, rawParsedBotOfCurrentType); GearChanceHelpers.ApplyModChanceOverrides(botToUpdate); GearChanceHelpers.ApplyEquipmentChanceOverrides(botToUpdate); diff --git a/Generator/Generator.csproj b/Generator/Generator.csproj index 845062d..52f62a0 100644 --- a/Generator/Generator.csproj +++ b/Generator/Generator.csproj @@ -173,10 +173,6 @@ - - - - Always @@ -184,6 +180,9 @@ + + Always + Always @@ -195,4 +194,8 @@ + + + + diff --git a/Generator/Helpers/Gear/GearChanceHelpers.cs b/Generator/Helpers/Gear/GearChanceHelpers.cs index cb5c1b0..ca9a86c 100644 --- a/Generator/Helpers/Gear/GearChanceHelpers.cs +++ b/Generator/Helpers/Gear/GearChanceHelpers.cs @@ -4,6 +4,7 @@ using Common.Models.Output; using System.Collections.Generic; using System.Linq; using Common.Models; +using Generator.Weighting; namespace Generator.Helpers.Gear { @@ -149,16 +150,23 @@ namespace Generator.Helpers.Gear } } - public static void AddGenerationChances(Bot bot) + public static void AddGenerationChances(Bot bot, IEnumerable rawBots, WeightingService weightingService) { + var weightsData = weightingService.GetBotGenerationWeights(bot.botType); bot.generation = new GenerationChances( - bot.inventory.items.SpecialLoot.Count, bot.inventory.items.SpecialLoot.Count, - healingMin: GetMedicalItemCountByBotType(bot.botType).min, healingMax: GetMedicalItemCountByBotType(bot.botType).max, - drugMin: 0, drugMax: 1, - stimMin: 0, stimMax: 1, - looseLootMin: GetLooseLootCountByBotType(bot.botType).min, looseLootMax: GetLooseLootCountByBotType(bot.botType).max, - magazinesMin: GetMagazineCountByBotType(bot.botType).min, MagazineMax: GetMagazineCountByBotType(bot.botType).max, - grenandesMin: 0, grenadesMax: 5); //TODO get dynamically + weightsData["specialItems"], + weightsData["healing"], + weightsData["drugs"], + weightsData["stims"], + weightsData["backpackLoot"], + weightsData["pocketLoot"], + weightsData["vestLoot"], + weightsData["magazines"], + weightsData["grenades"]); + + // it makes some crazy values, one assault bot has 10 grenades! + //AddGrenadeMinMax(bot, rawBots); + } public static void CalculateEquipmentChances(Bot bot, List baseBots) diff --git a/Generator/Program.cs b/Generator/Program.cs index a3dd5a1..9bee596 100644 --- a/Generator/Program.cs +++ b/Generator/Program.cs @@ -1,4 +1,6 @@ -namespace Generator; +using Generator.Helpers; + +namespace Generator; internal static class Program { diff --git a/Generator/Weighting/WeightingService.cs b/Generator/Weighting/WeightingService.cs index b4c9d48..d739c79 100644 --- a/Generator/Weighting/WeightingService.cs +++ b/Generator/Weighting/WeightingService.cs @@ -1,4 +1,5 @@ using Common.Models; +using System.Collections.Generic; using System.Text.Json; namespace Generator.Weighting @@ -14,10 +15,12 @@ namespace Generator.Weighting public class WeightingService { private readonly Dictionary _weights; + + private readonly Dictionary> _generationWeights; public WeightingService() { - - var weightsFilePath = $"{Directory.GetCurrentDirectory()}\\Assets\\weights.json"; + var assetsPath = $"{Directory.GetCurrentDirectory()}\\Assets"; + var weightsFilePath = $"{assetsPath}\\weights.json"; if (!File.Exists(weightsFilePath)) { throw new Exception($"Missing weights.json in /assets ({weightsFilePath})"); @@ -25,6 +28,14 @@ namespace Generator.Weighting var weightJson = File.ReadAllText(weightsFilePath); _weights = JsonSerializer.Deserialize>(weightJson); + + // bot / itemtype / itemcount + var generationWeightJson = File.ReadAllText($"{assetsPath}\\generationWeights.json"); + + // assault - dict + // speicalitems - object + // weights + whitelsit + _generationWeights = JsonSerializer.Deserialize>>(generationWeightJson); } public int GetAmmoWeight(string tpl, BotType botType, string caliber) @@ -71,5 +82,16 @@ namespace Generator.Weighting return 1; } + + public Dictionary GetBotGenerationWeights(BotType botType) + { + _generationWeights.TryGetValue(botType.ToString(), out var result); + if (result == null) + { + return _generationWeights["default"]; + } + + return result; + } } }