using Newtonsoft.Json.Linq; namespace XFEWarframe.Core.Data; public static class LegacyMods { private static readonly Lazy Data = new(() => (JObject)Assets.Json("editor/legacy-mods.json")); public static JObject All => Data.Value; public static JObject? Find(string type) => All[type] as JObject; public static (double Min, double Max, bool Percent) Range(JObject meta, string fit, string attribute, string rarity) { var attenuation = meta["fits"]!.FirstOrDefault(x => x.Value("type") == fit)?.Value("statAtten") ?? 1; var stat = meta["upgrades"]!.FirstOrDefault(x => x.Value("type") == attribute) ?? throw new ApiException(400, "未知旧版 MOD 属性。"); // U5 clients use the uncommon numeric range for rare rolls too. var range = stat["valueRarity"]?[rarity == "RARE" ? "UNCOMMON" : rarity] as JArray ?? throw new ApiException(400, "未知旧版 MOD 稀有度。"); var multiply = stat.Value("operation") == "MULTIPLY"; var percent = multiply || stat.Value("displayAsPercent"); double Convert(double x) => (percent ? x * 100 - (multiply ? 100 : 0) : x) * attenuation; return (Convert(range[0]!.Value()), Convert(range[1]!.Value()), percent); } }