From 055a6f901a69bcb91dbec384ad838bbd620e8ae7 Mon Sep 17 00:00:00 2001 From: Chomp Date: Sun, 9 Jan 2022 20:33:24 +0000 Subject: [PATCH] Dump cleaner now handles: trader base files Location base files --- DumpCleaner/DumpFiles.cs | 4 + DumpCleaner/Helpers/TraderSellCategories.cs | 149 ++++++++++++++++++++ DumpCleaner/Models/Location.cs | 5 + DumpCleaner/Models/Trader.cs | 26 ++++ DumpCleaner/Program.cs | 77 +++++++--- QuestValidator.sln | 4 +- 6 files changed, 247 insertions(+), 18 deletions(-) create mode 100644 DumpCleaner/Helpers/TraderSellCategories.cs create mode 100644 DumpCleaner/Models/Location.cs create mode 100644 DumpCleaner/Models/Trader.cs diff --git a/DumpCleaner/DumpFiles.cs b/DumpCleaner/DumpFiles.cs index 7e1c793..2a63535 100644 --- a/DumpCleaner/DumpFiles.cs +++ b/DumpCleaner/DumpFiles.cs @@ -40,6 +40,9 @@ namespace DumpCleaner new DumpData{InputName = "resp.client.hideout.production.scavcase.recipes", OutputName = "scavcase", OutputFolder = "hideout"}, new DumpData{InputName = "resp.client.hideout.settings", OutputName = "settings", OutputFolder = "hideout"}, + new DumpData{InputName = "resp.client.locations", OutputName = "locations", OutputFolder = "locations", SpecialCase = true}, + + new DumpData{InputName = "resp.client.trading.api.traderSettings", OutputName = "traders", OutputFolder = "traders", SpecialCase = true}, }; } @@ -48,6 +51,7 @@ namespace DumpCleaner public string InputName { get; set; } public string OutputName { get; set; } public string OutputFolder { get; set; } + public bool SpecialCase { get; internal set; } } public class Dump diff --git a/DumpCleaner/Helpers/TraderSellCategories.cs b/DumpCleaner/Helpers/TraderSellCategories.cs new file mode 100644 index 0000000..0b25444 --- /dev/null +++ b/DumpCleaner/Helpers/TraderSellCategories.cs @@ -0,0 +1,149 @@ +// read contents of input folder +public static class TraderSellCategories +{ + private static readonly Dictionary> _dict = new Dictionary> + { + { "5a7c2eca46aef81a7ca2145d", new List { "5b5f78dc86f77409407a7f8e", + "5b5f71b386f774093f2ecf11", + "5b5f71c186f77409407a7ec0", + "5b5f71de86f774093f2ecf13", + "5b5f724186f77447ed5636ad", + "5b5f736886f774094242f193", + "5b5f73ec86f774093e6cb4fd", + "5b5f74cc86f77447ec5d770a", + "5b5f750686f774093e6cb503", + "5b5f751486f77447ec5d770c", + "5b5f752e86f774093e6cb505", + "5b5f754a86f774094242f19b", + "5b5f755f86f77447ec5d770e", + "5b5f757486f774093e6cb507", + "5b5f75b986f77447ec5d7710", + "5b5f75c686f774094242f19f", + "5b5f75e486f77447ec5d7712", + "5b5f760586f774093e6cb509", + "5b5f761f86f774094242f1a1", + "5b5f764186f77447ec5d7714", + "5b47574386f77428ca22b33e", + "5b47574386f77428ca22b341", + "5b47574386f77428ca22b345", + "5b47574386f77428ca22b2ef", + "5b47574386f77428ca22b343" } }, + { "5ac3b934156ae10c4430e83c", new List { "5b47574386f77428ca22b33f" } }, + { "5c0647fdd443bc2504c2d371", new List {"5b5f78e986f77447ed5636b1", + "5b5f791486f774093f2ed3be", + "5b5f792486f77447ed5636b3", + "5b5f794b86f77409407a7f92", + "5b5f798886f77447ed5636b5", + "5b5f7a0886f77409407a7f96", + "5b5f75b986f77447ec5d7710", + "5b47574386f77428ca22b346", + "5b47574386f77428ca22b340", + "5b47574386f77428ca22b2ed", + "5b47574386f77428ca22b2f2"} }, + { "54cb50c76803fa8b248b4571", new List {"5b5f71b386f774093f2ecf11", + "5b5f71c186f77409407a7ec0", + "5b5f71de86f774093f2ecf13", + "5b5f724186f77447ed5636ad", + "5b5f736886f774094242f193", + "5b5f73ec86f774093e6cb4fd", + "5b5f74cc86f77447ec5d770a", + "5b5f750686f774093e6cb503", + "5b5f751486f77447ec5d770c", + "5b5f752e86f774093e6cb505", + "5b5f754a86f774094242f19b", + "5b5f755f86f77447ec5d770e", + "5b5f757486f774093e6cb507", + "5b5f75b986f77447ec5d7710", + "5b5f75c686f774094242f19f", + "5b5f75e486f77447ec5d7712", + "5b5f760586f774093e6cb509", + "5b5f761f86f774094242f1a1", + "5b5f764186f77447ec5d7714", + "5b5f78dc86f77409407a7f8e", + "5b47574386f77428ca22b346", + "5b47574386f77428ca22b345"} }, + { "54cb57776803fa99248b456e", new List {"5b47574386f77428ca22b344", + "5b47574386f77428ca22b2f1", + "5b47574386f77428ca22b340", + "5b47574386f77428ca22b2f4", + "5b47574386f77428ca22b2f3", + "5b47574386f77428ca22b342", + "5b47574386f77428ca22b341", + "5b5f6fa186f77409407a7eb7", + "5b47574386f77428ca22b343"} }, + { "579dc571d53a0658a154fbec", new List {"5b47574386f77428ca22b33e", + "5b47574386f77428ca22b33f", + "5b5f78dc86f77409407a7f8e", + "5b47574386f77428ca22b346", + "5b47574386f77428ca22b340", + "5b47574386f77428ca22b344", + "5b47574386f77428ca22b342", + "5b47574386f77428ca22b341", + "5b47574386f77428ca22b345", + "5b47574386f77428ca22b343", + "5b5f71b386f774093f2ecf11", + "5b5f71c186f77409407a7ec0", + "5b5f71de86f774093f2ecf13", + "5b5f724186f77447ed5636ad", + "5b5f736886f774094242f193", + "5b5f73ec86f774093e6cb4fd", + "5b5f74cc86f77447ec5d770a", + "5b5f750686f774093e6cb503", + "5b5f751486f77447ec5d770c", + "5b5f752e86f774093e6cb505", + "5b5f754a86f774094242f19b", + "5b5f755f86f77447ec5d770e", + "5b5f757486f774093e6cb507", + "5b5f75b986f77447ec5d7710", + "5b5f75c686f774094242f19f", + "5b5f75e486f77447ec5d7712", + "5b5f760586f774093e6cb509", + "5b5f761f86f774094242f1a1", + "5b5f764186f77447ec5d7714"} }, + { "5935c25fb3acc3127c3d8cd9", new List {"5b47574386f77428ca22b33f", + "5b5f78dc86f77409407a7f8e", + "5b5f71b386f774093f2ecf11", + "5b5f71c186f77409407a7ec0", + "5b5f71de86f774093f2ecf13", + "5b5f724186f77447ed5636ad", + "5b5f736886f774094242f193", + "5b5f73ec86f774093e6cb4fd", + "5b5f74cc86f77447ec5d770a", + "5b5f750686f774093e6cb503", + "5b5f751486f77447ec5d770c", + "5b5f752e86f774093e6cb505", + "5b5f754a86f774094242f19b", + "5b5f755f86f77447ec5d770e", + "5b5f757486f774093e6cb507", + "5b5f75b986f77447ec5d7710", + "5b5f75c686f774094242f19f", + "5b5f75e486f77447ec5d7712", + "5b5f760586f774093e6cb509", + "5b5f761f86f774094242f1a1", + "5b5f764186f77447ec5d7714", + "5b47574386f77428ca22b346", + "5b47574386f77428ca22b340", + "5b47574386f77428ca22b344", + "5b47574386f77428ca22b341"} }, + { "58330581ace78e27b8b10cee", new List {"5b5f71b386f774093f2ecf11", + "5b5f71c186f77409407a7ec0", + "5b5f71de86f774093f2ecf13", + "5b5f724186f77447ed5636ad", + "5b5f736886f774094242f193", + "5b5f73ec86f774093e6cb4fd", + "5b5f74cc86f77447ec5d770a", + "5b5f750686f774093e6cb503", + "5b5f751486f77447ec5d770c", + "5b5f752e86f774093e6cb505", + "5b5f754a86f774094242f19b", + "5b5f755f86f77447ec5d770e", + "5b5f757486f774093e6cb507", + "5b5f78e986f77447ed5636b1", + "5b5f78fc86f77409407a7f90"} }, + }; + + public static List GetCategoriesByTraderId(string id) + { + return _dict[id]; + } +} \ No newline at end of file diff --git a/DumpCleaner/Models/Location.cs b/DumpCleaner/Models/Location.cs new file mode 100644 index 0000000..09b6e21 --- /dev/null +++ b/DumpCleaner/Models/Location.cs @@ -0,0 +1,5 @@ +// read contents of input folder +public class Location +{ + public string Id { get; set; } +} diff --git a/DumpCleaner/Models/Trader.cs b/DumpCleaner/Models/Trader.cs new file mode 100644 index 0000000..ddabc83 --- /dev/null +++ b/DumpCleaner/Models/Trader.cs @@ -0,0 +1,26 @@ +// read contents of input folder +public class Trader +{ + public string _id { get; set; } + public bool customization_seller { get; set; } + public string name { get; set; } + public string surname { get; set; } + public string nickname { get; set; } + public string location { get; set; } + public string avatar { get; set; } + public int balance_rub { get; set; } + public int balance_dol { get; set; } + public int balance_eur { get; set; } + public bool unlockedByDefault { get; set; } + public int discount { get; set; } + public int discount_end { get; set; } + public bool buyer_up { get; set; } + public string currency { get; set; } + public int nextResupply { get; set; } + public object repair { get; set; } + public object insurance { get; set; } + public bool medic { get; set; } + public int gridHeight { get; set; } + public List loyaltyLevels { get; set; } + public List sell_category { get; set; } +} diff --git a/DumpCleaner/Program.cs b/DumpCleaner/Program.cs index 025c348..65aff4f 100644 --- a/DumpCleaner/Program.cs +++ b/DumpCleaner/Program.cs @@ -1,7 +1,4 @@ - - -// read contents of input folder -using AssortGenerator.Common.Helpers; +using AssortGenerator.Common.Helpers; using DumpCleaner; using QuestValidator.Common; using QuestValidator.Common.Helpers; @@ -11,13 +8,10 @@ using System.Text.Json; var inputPath = DiskHelpers.CreateWorkingFolders(); InputFileHelper.SetInputFiles(inputPath); -var filePaths = InputFileHelper.GetInputFilePaths(); - -//create list of paths -foreach (var path in filePaths) +foreach (var path in InputFileHelper.GetInputFilePaths()) { var filename = Path.GetFileNameWithoutExtension(path); - var names = DumpFiles.filenames.FirstOrDefault(x=> filename.StartsWith(x.InputName)); + var names = DumpFiles.filenames.FirstOrDefault(x => filename.StartsWith(x.InputName)); if (names == null) { @@ -34,15 +28,66 @@ foreach (var path in filePaths) continue; } - JsonWriter.WriteJson(dumpFile.data, names.OutputFolder, Directory.GetCurrentDirectory(), names.OutputName); - LoggingHelpers.LogToConsole($"Found file: {filename} wrote file to output folder"); + // Special case, Do special tasks with it + if (names.SpecialCase) + { + HandleSpecialCase(names, dumpFile); + } + else + { + JsonWriter.WriteJson(dumpFile.data, names.OutputFolder, Directory.GetCurrentDirectory(), names.OutputName); + LoggingHelpers.LogToConsole($"Found file: {filename} wrote file to output folder"); + } } +void HandleSpecialCase(DumpData names, Dump dumpFile) +{ + if (names.InputName == "resp.client.locations") + { + HandleLocationsFile(names, dumpFile); + } -// iterate over paths + if (names.InputName == "resp.client.trading.api.traderSettings") + { + HandleTraderSettingsFile(names, dumpFile); + } +} -// check if filename matches a file in a list of files we want -// it matches: clean up file and output to 'output' -// get data object from it, save this into new file +void HandleLocationsFile(DumpData names, Dump dumpFile) +{ + var locationsRoot = JsonSerializer.Deserialize>(dumpFile.data.ToString()); + var locations = JsonSerializer.Deserialize>(locationsRoot.First().Value.ToString()); -// doesnt match: ignore it with warning \ No newline at end of file + foreach (var location in locations) + { + var locationData = JsonSerializer.Deserialize(location.Value.ToString()); + + var mapName = locationData.Id.ToLower(); + if (mapName == "lighthouse2") + { + continue; + } + + if (new string[] { "bigmap", "interchange", "lighthouse", "rezervbase", "shoreline", "woods" }.Contains(mapName)) + { + // TODO: add back airdrop chance + } + + JsonWriter.WriteJson(mapdata, $"{names.OutputFolder}/{locationData.Id.ToLower()}", Directory.GetCurrentDirectory(), "base"); + LoggingHelpers.LogToConsole($"Found map file: {locationData.Id} wrote file to output folder"); + } +} + +void HandleTraderSettingsFile(DumpData names, Dump dumpFile) +{ + var traders = JsonSerializer.Deserialize>(dumpFile.data.ToString()); + + foreach (var trader in traders) + { + var traderData = JsonSerializer.Deserialize(trader.ToString()); + traderData.sell_category = TraderSellCategories.GetCategoriesByTraderId(traderData._id); + + JsonWriter.WriteJson(traderData, $"{names.OutputFolder}/{traderData._id}", Directory.GetCurrentDirectory(), "base"); + LoggingHelpers.LogToConsole($"Found trader file: {traderData._id} wrote file to output folder"); + } +} diff --git a/QuestValidator.sln b/QuestValidator.sln index 6a27822..037425a 100644 --- a/QuestValidator.sln +++ b/QuestValidator.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.31624.102 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.32002.185 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QuestValidator", "QuestValidator\QuestValidator.csproj", "{52D43AB5-26C2-4C82-82F2-F63ED911E7F4}" EndProject