2022-06-12 12:12:39 +01:00
|
|
|
|
using DumpCleaner;
|
|
|
|
|
using QuestValidator.Common;
|
|
|
|
|
using QuestValidator.Common.Helpers;
|
|
|
|
|
using System.Text.Json;
|
2023-07-07 21:00:59 +01:00
|
|
|
|
using System.Text.Json.Nodes;
|
|
|
|
|
|
|
|
|
|
public class LocationData
|
|
|
|
|
{
|
|
|
|
|
public LocationData(Location location, Dump rawLocation)
|
|
|
|
|
{
|
|
|
|
|
Location = location;
|
|
|
|
|
RawLocation = rawLocation;
|
|
|
|
|
}
|
|
|
|
|
public Location Location { get; set; }
|
|
|
|
|
public Dump RawLocation { get; set; }
|
|
|
|
|
}
|
2022-06-12 12:12:39 +01:00
|
|
|
|
|
|
|
|
|
public class LocationParser
|
|
|
|
|
{
|
2023-07-07 21:00:59 +01:00
|
|
|
|
private readonly Dictionary<string, LocationData> locations = new Dictionary<string, LocationData>();
|
2022-06-12 12:12:39 +01:00
|
|
|
|
private readonly string outputPath;
|
|
|
|
|
|
|
|
|
|
public LocationParser(string outputPath)
|
|
|
|
|
{
|
|
|
|
|
this.outputPath = outputPath;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-07 21:00:59 +01:00
|
|
|
|
internal void AddLocalLootDump(Dump dumpFile, string rawJson)
|
2022-06-12 12:12:39 +01:00
|
|
|
|
{
|
|
|
|
|
var locationData = JsonSerializer.Deserialize<Location>(dumpFile.data.ToString());
|
|
|
|
|
var locationName = locationData.Id;
|
|
|
|
|
|
|
|
|
|
// already parsed, skip
|
|
|
|
|
if (locations.ContainsKey(locationName))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// remove loot as not needed for base.json
|
|
|
|
|
locationData.Loot?.Clear();
|
|
|
|
|
|
2023-07-07 21:00:59 +01:00
|
|
|
|
// remove loot from raw file
|
|
|
|
|
JsonNode? parsedJson = JsonNode.Parse(rawJson);
|
|
|
|
|
|
|
|
|
|
var data = parsedJson["data"];
|
|
|
|
|
data["Loot"] = new JsonArray();
|
|
|
|
|
|
|
|
|
|
var lootFreeJson = parsedJson.ToString();
|
|
|
|
|
|
|
|
|
|
locations.Add(locationName, new LocationData(locationData, JsonSerializer.Deserialize<Dump>(lootFreeJson)));
|
2022-06-12 12:12:39 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal void CreateLocationFile()
|
|
|
|
|
{
|
|
|
|
|
foreach (var location in locations)
|
|
|
|
|
{
|
|
|
|
|
|
2023-07-07 21:00:59 +01:00
|
|
|
|
if (string.Equals(location.Value.Location.Id, "lighthouse2", StringComparison.CurrentCultureIgnoreCase))
|
2022-06-12 12:12:39 +01:00
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-07 21:00:59 +01:00
|
|
|
|
JsonWriter.WriteJson(location.Value.RawLocation.data, $"{outputPath}/{location.Value.Location.Id.ToLower()}", Directory.GetCurrentDirectory(), "base");
|
|
|
|
|
LoggingHelpers.LogToConsole($"Found map file: {location.Value.Location.Id} wrote file to output folder");
|
2022-06-12 12:12:39 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|