using AssortGenerator.Common.Helpers; using DumpCleaner; using QuestValidator.Common; using QuestValidator.Common.Helpers; using QuestValidator.Helpers; using System.Text.Json; var inputPath = DiskHelpers.CreateWorkingFolders(); InputFileHelper.SetInputFiles(inputPath); var locationParser = new LocationParser("locations"); foreach (var path in InputFileHelper.GetInputFilePaths()) { var filename = Path.GetFileNameWithoutExtension(path); var names = DumpFiles.filenames.Find(x => filename.StartsWith(x.InputName)); if (names == null) { LoggingHelpers.LogToConsole($"No mapping found for file: {filename} Skipping", ConsoleColor.Yellow); continue; } var rawJson = File.ReadAllText(path); var dumpFile = JsonSerializer.Deserialize(rawJson); if (dumpFile.data == null) { LoggingHelpers.LogWarning($"file: {filename} had no data in it, skipping"); continue; } // 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"); } } locationParser.CreateLocationFile(); void HandleSpecialCase(DumpData names, Dump dumpFile) { if (names.InputName == "resp.client.location.getLocalloot") { locationParser.AddLocalLootDump(dumpFile); } if (names.InputName == "resp.client.trading.api.traderSettings") { HandleTraderSettingsFile(names, dumpFile); } } void HandleLocationsFile(DumpData names, Dump dumpFile) { var locationsRoot = JsonSerializer.Deserialize>(dumpFile.data.ToString()); var locations = JsonSerializer.Deserialize>(locationsRoot.First().Value.ToString()); 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(locationData, $"{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"); } }