From 1b22e9d01b215ed964520284cc5ca30a82cceef9 Mon Sep 17 00:00:00 2001 From: Chomp Date: Sat, 14 Aug 2021 09:53:00 +0100 Subject: [PATCH] pass working path to class pass a list of bot files to difficulty helper --- Generator/BaseBotGenerator.cs | 27 +++++++--------- Generator/Helpers/Gear/GearChanceHelpers.cs | 36 ++++++++++----------- Generator/Program.cs | 2 +- 3 files changed, 31 insertions(+), 34 deletions(-) diff --git a/Generator/BaseBotGenerator.cs b/Generator/BaseBotGenerator.cs index d2b3337..64e71df 100644 --- a/Generator/BaseBotGenerator.cs +++ b/Generator/BaseBotGenerator.cs @@ -5,6 +5,7 @@ using Generator.Models.Output; using System; using System.Collections.Generic; using System.Diagnostics; +using System.IO; using System.Linq; namespace Generator @@ -12,10 +13,12 @@ namespace Generator public class BaseBotGenerator { private readonly List _rawParsedBots; + private readonly string _workingPath; - public BaseBotGenerator(List parsedBots) + public BaseBotGenerator(List parsedBots, string workingPath) { _rawParsedBots = parsedBots; + _workingPath = workingPath; } public List AddBaseDetails() @@ -40,7 +43,7 @@ namespace Generator .Where(x => string.Equals(x.Info.Settings.Role, botToUpdate.botType.ToString(), StringComparison.OrdinalIgnoreCase)).ToList(); UpdateBodyPartHealth(botToUpdate, rawBotsOfSameType); - AddDifficulties(botToUpdate, rawBotsOfSameType); + AddDifficulties(botToUpdate, _workingPath); foreach (var rawParsedBot in rawBotsOfSameType) { @@ -61,20 +64,14 @@ namespace Generator bot.appearance.voice.AddUnique(rawParsedBot.Info.Voice); } - private void AddDifficulties(Bot bot, List rawParsedBots) + private void AddDifficulties(Bot bot, string workingPath) { - switch (bot.botType) - { - case BotType.assault: - DifficultyHelper.AddAssaultDifficulties(bot); - break; - case BotType.pmcBot: - break; - case BotType.marksman: - break; - default: - break; - } + var botFiles = Directory + .GetFiles($"{workingPath}//Assets", "*.txt", SearchOption.TopDirectoryOnly) + .Where(x => x.Contains(bot.botType.ToString())) + .ToList(); + + DifficultyHelper.AddDifficultySettings(bot, botFiles); } private void UpdateBodyPartHealth(Bot botToUpdate, List rawParsedBots) diff --git a/Generator/Helpers/Gear/GearChanceHelpers.cs b/Generator/Helpers/Gear/GearChanceHelpers.cs index b3aceb8..79acf00 100644 --- a/Generator/Helpers/Gear/GearChanceHelpers.cs +++ b/Generator/Helpers/Gear/GearChanceHelpers.cs @@ -12,9 +12,9 @@ namespace Generator.Helpers.Gear { int totalBotsCount = baseBots.Count; int muzzleCount = 0, barrelCount = 0, handguardCount = 0, stockCount = 0, magazineCount = 0, - mountCount = 0, flashlightCount = 0, tactical001Count = 0, tactical002Count = 0, tactical003Count =0, + mountCount = 0, flashlightCount = 0, tactical001Count = 0, tactical002Count = 0, tactical003Count = 0, mount000Count = 0, pistolGripCount = 0, tacticalCount = 0, scopeCount = 0, recieverCount = 0, - sightRearCount = 0, chargeCount = 0, mount001Count = 0, equipmentCount = 0, gasBlockCount=0, + sightRearCount = 0, chargeCount = 0, mount001Count = 0, equipmentCount = 0, gasBlockCount = 0, launcherCount = 0, sightFrontCount = 0, stock000Count = 0, foregripCount = 0, tactical000Count = 0, nvgCount = 0, pistolGripAkmsCount = 0, stockAkmsCount = 0, equipment000Count = 0, equipment001Count = 0, equipment002Count = 0, bipodCount = 0; @@ -110,13 +110,13 @@ namespace Generator.Helpers.Gear public static void CalculateEquipmentChances(Bot bot, List baseBots) { var totalBotsCount = baseBots.Count; - int headwearCount = 0, earCount = 0, faceCoverCount = 0,armorVestCount = 0, eyeWearCount = 0, armBandCount = 0, + int headwearCount = 0, earCount = 0, faceCoverCount = 0, armorVestCount = 0, eyeWearCount = 0, armBandCount = 0, tacticalVestCount = 0, backpackCount = 0, firstPrimaryCount = 0, secondPrimaryCount = 0, holsterCount = 0, scabbardCount = 0, pocketsCount = 0, securedContainerCount = 0; foreach (var baseBot in baseBots) { - headwearCount += baseBot.Inventory.items.Count(x=> x.slotId == "Headwear"); + headwearCount += baseBot.Inventory.items.Count(x => x.slotId == "Headwear"); earCount += baseBot.Inventory.items.Count(x => x.slotId == "Earpiece"); faceCoverCount += baseBot.Inventory.items.Count(x => x.slotId == "FaceCover"); armorVestCount += baseBot.Inventory.items.Count(x => x.slotId == "ArmorVest"); @@ -133,20 +133,20 @@ namespace Generator.Helpers.Gear } bot.chances.equipment = new EquipmentChances( - GetPercent(totalBotsCount, headwearCount), - GetPercent(totalBotsCount, earCount), - GetPercent(totalBotsCount, faceCoverCount), - GetPercent(totalBotsCount, armorVestCount), - GetPercent(totalBotsCount, eyeWearCount), - GetPercent(totalBotsCount, armBandCount), - GetPercent(totalBotsCount, tacticalVestCount), - GetPercent(totalBotsCount, backpackCount), - GetPercent(totalBotsCount, firstPrimaryCount), - GetPercent(totalBotsCount, secondPrimaryCount), - GetPercent(totalBotsCount, holsterCount), - GetPercent(totalBotsCount, scabbardCount), - GetPercent(totalBotsCount, pocketsCount), - GetPercent(totalBotsCount, securedContainerCount)); + GetPercent(totalBotsCount, headwearCount), + GetPercent(totalBotsCount, earCount), + GetPercent(totalBotsCount, faceCoverCount), + GetPercent(totalBotsCount, armorVestCount), + GetPercent(totalBotsCount, eyeWearCount), + GetPercent(totalBotsCount, armBandCount), + GetPercent(totalBotsCount, tacticalVestCount), + GetPercent(totalBotsCount, backpackCount), + GetPercent(totalBotsCount, firstPrimaryCount), + GetPercent(totalBotsCount, secondPrimaryCount), + GetPercent(totalBotsCount, holsterCount), + GetPercent(totalBotsCount, scabbardCount), + GetPercent(totalBotsCount, pocketsCount), + GetPercent(totalBotsCount, securedContainerCount)); } private static int GetPercent(int total, int count) diff --git a/Generator/Program.cs b/Generator/Program.cs index b586706..105e98d 100644 --- a/Generator/Program.cs +++ b/Generator/Program.cs @@ -23,7 +23,7 @@ namespace Generator } // Generate the base bot class and add basic details (health/body part hp etc) - var baseBotGenerator = new BaseBotGenerator(parsedBots); + var baseBotGenerator = new BaseBotGenerator(parsedBots, workingPath); var baseBots = baseBotGenerator.AddBaseDetails(); // Add weapons/armor to bot