using System.Globalization; using System.Text.RegularExpressions; using Newtonsoft.Json.Linq; namespace XFEWarframe.Core.Data; public static partial class GameVersion { public const long August2026 = 202608191106; private static readonly Lazy Versions = new(() => (JObject)Assets.Json("world/gameToBuildVersion.json")); public static long Parse(string? label) { var match = BuildPattern().Match(label ?? "2026.05.13.13.07"); if (!match.Success) throw new ApiException(400, "Invalid build label"); return long.Parse(string.Concat(match.Groups.Cast().Skip(1).Select(x => x.Value)), CultureInfo.InvariantCulture); } public static long Of(string gameVersion) => Parse(Versions.Value.Value(gameVersion) ?? throw new ArgumentException("Unknown game version")); public static long For(JObject account) => Parse(account.Value("BuildLabel")); public static JObject Oid(string id, long build) => new() { [build <= Of("19.5.3") ? "$id" : "$oid"] = id }; public static JObject Date(long ms, long build) => build <= Of("19.5.3") ? new JObject { ["sec"] = ms / 1000, ["usec"] = ms % 1000 * 1000 } : Wire.Date(ms); public static bool RegionAvailable(string id, JObject region, long build) => (id != "SolNode307" || build >= Of("32.2.0")) && (id != "SolNode308" || build >= Of("25.7.0")) && (region.Value("systemIndex") != 18 || build >= Of("19.0.1")); [GeneratedRegex(@"^(\d{4})\.(\d{2})\.(\d{2})\.(\d{2})\.(\d{2})", RegexOptions.CultureInvariant)] private static partial Regex BuildPattern(); }