37 lines
1.1 KiB
C#
Raw Normal View History

using AssortGenerator.Models.Input;
using AssortGenerator.Models.Other;
using AssortGenerator.Models.Output;using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.Json;
namespace AssortGenerator.Common.Helpers
{
public static class PresetHelper
{
private static Dictionary<string, GlobalPreset> _presetData;
public static List<Item> GetDefaultPreset(string tpl)
{
if (_presetData == null)
{
var questFilePath = InputFileHelper.GetInputFilePaths().FirstOrDefault(x => x.Contains("globals"));
var questDataJson = File.ReadAllText(questFilePath);
_presetData = JsonSerializer.Deserialize<Globals>(questDataJson).ItemPresets;
}
return _presetData.FirstOrDefault(x => x.Value._encyclopedia == tpl).Value?._items;
}
}
}
public class Globals
{
public Dictionary<string, GlobalPreset> ItemPresets { get; set; }
}
public class GlobalPreset
{
public string _encyclopedia { get; set; }
public List<Item> _items { get; set; }
}