From 4baaeb47bcb2984040b796625216f591090f77b1 Mon Sep 17 00:00:00 2001 From: Chomp Date: Tue, 31 Aug 2021 18:39:30 +0100 Subject: [PATCH] Update boss keygen code to better match requirements --- Common/Extensions/EnumExtensions.cs | 15 +++++++++++++++ .../Models/Enums.cs => Common/Models/BotType.cs | 5 +++-- Generator/BaseBotGenerator.cs | 2 +- Generator/BotLootGenerator.cs | 14 ++++++++++---- Generator/Helpers/Gear/SpecialLootHelper.cs | 13 +++++++------ Generator/Models/Output/Output.cs | 3 ++- 6 files changed, 38 insertions(+), 14 deletions(-) create mode 100644 Common/Extensions/EnumExtensions.cs rename Generator/Models/Enums.cs => Common/Models/BotType.cs (88%) diff --git a/Common/Extensions/EnumExtensions.cs b/Common/Extensions/EnumExtensions.cs new file mode 100644 index 0000000..535ab13 --- /dev/null +++ b/Common/Extensions/EnumExtensions.cs @@ -0,0 +1,15 @@ +using Common.Models; + +namespace Common.Extensions +{ + public static class EnumExtensions + { + /// + /// Add a string to a list only if it doesnt already exist + /// + public static bool IsBoss(this BotType self) + { + return self.HasFlag(BotType.bossbully | BotType.bossgluhar | BotType.bosskilla | BotType.bosskojaniy | BotType.bosssanitar); + } + } +} diff --git a/Generator/Models/Enums.cs b/Common/Models/BotType.cs similarity index 88% rename from Generator/Models/Enums.cs rename to Common/Models/BotType.cs index a159155..7aef3ca 100644 --- a/Generator/Models/Enums.cs +++ b/Common/Models/BotType.cs @@ -1,4 +1,4 @@ -namespace Generator.Models +namespace Common.Models { public enum BotType { @@ -21,6 +21,7 @@ followerstormtrooper = 17, cursedassault = 18, sectantpriest = 19, - sectantwarrior = 20 + sectantwarrior = 20, + usec = 21 } } diff --git a/Generator/BaseBotGenerator.cs b/Generator/BaseBotGenerator.cs index f93ab8c..cde18ee 100644 --- a/Generator/BaseBotGenerator.cs +++ b/Generator/BaseBotGenerator.cs @@ -1,7 +1,7 @@ using Common; using Common.Extensions; +using Common.Models; using Generator.Helpers; -using Generator.Models; using Generator.Models.Input; using Generator.Models.Output; using System; diff --git a/Generator/BotLootGenerator.cs b/Generator/BotLootGenerator.cs index 487f52f..9efef04 100644 --- a/Generator/BotLootGenerator.cs +++ b/Generator/BotLootGenerator.cs @@ -65,16 +65,22 @@ namespace Generator } } - private void AddTacticalVestLoot(Bot finalAssaultBot, List bots) + private void AddTacticalVestLoot(Bot finalBot, List bots) { var tacVestItems = GetItemsStoredInEquipmentItem(bots, "TacticalVest"); - finalAssaultBot.inventory.items.TacticalVest.AddRange(tacVestItems); + finalBot.inventory.items.TacticalVest.AddRange(tacVestItems); } - private void AddBackbackLoot(Bot finalAssaultBot, List bots) + private void AddBackbackLoot(Bot finalBot, List bots) { + // add generic keys to bosses + if (finalBot.botType.IsBoss()) + { + finalBot.inventory.items.Backpack.AddRange(SpecialLootHelper.GetGenericBossKeys()); + } + var backpackItems = GetItemsStoredInEquipmentItem(bots, "Backpack"); - finalAssaultBot.inventory.items.Backpack.AddRange(backpackItems); + finalBot.inventory.items.Backpack.AddRange(backpackItems); } private void AddSecureContainerLoot(Bot finalAssaultBot, List bots) diff --git a/Generator/Helpers/Gear/SpecialLootHelper.cs b/Generator/Helpers/Gear/SpecialLootHelper.cs index 8a4fea9..45874c9 100644 --- a/Generator/Helpers/Gear/SpecialLootHelper.cs +++ b/Generator/Helpers/Gear/SpecialLootHelper.cs @@ -1,4 +1,5 @@ -using Generator.Models; +using Common.Models; +using Generator.Models; using System.Collections.Generic; namespace Generator.Helpers.Gear @@ -58,6 +59,11 @@ namespace Generator.Helpers.Gear "5a0eee1486f77402aa773226" // "Health Resort east wing room 328 key" }; + public static IEnumerable GetGenericBossKeys() + { + return _genericBossKeys; + } + public static IEnumerable GetSpecialLootForBotType(BotType botType) { var results = new List(); @@ -70,20 +76,15 @@ namespace Generator.Helpers.Gear case BotType.marksman: break; case BotType.bossbully: - results.AddRange(_genericBossKeys); break; case BotType.bossgluhar: - results.AddRange(_genericBossKeys); break; case BotType.bosskilla: - results.AddRange(_genericBossKeys); break; case BotType.bosskojaniy: - results.AddRange(_genericBossKeys); results.Add("5d08d21286f774736e7c94c3"); // Shturman's stash key break; case BotType.bosssanitar: - results.AddRange(_genericBossKeys); results.Add("5efde6b4f5448336730dbd61"); // Keycard with a blue marking break; case BotType.bossstormtrooper: diff --git a/Generator/Models/Output/Output.cs b/Generator/Models/Output/Output.cs index 0b4f522..6be2ea7 100644 --- a/Generator/Models/Output/Output.cs +++ b/Generator/Models/Output/Output.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using Common.Models; +using Newtonsoft.Json; using System.Collections.Generic; namespace Generator.Models.Output