using System.Collections.Concurrent;
using Newtonsoft.Json.Linq;
namespace XFEWarframe.Core.Data;
public static class GameData
{
private const string MarketPrefix = "/Lotus/StoreItems/";
// Callers must clone before modifying metadata shared between accounts.
private static readonly ConcurrentDictionary<string, Lazy<JObject>> tables = new(StringComparer.Ordinal);
private static readonly Lazy<JObject> EventItems = new(() => (JObject)Assets.Json("world/supplementalEventItems.json"));
public static JObject Table(string name) => tables.GetOrAdd(name, n => new(() =>
{
var result = (JObject)Assets.Json($"export/Export{n}.json");
var supplement = n switch { "Recipes" => "supplementalRecipes", "Warframes" => "supplementalSuits", "Weapons" => "supplementalWeapons", "Keys" => "supplementalKeys", "Upgrades" => "supplementalUpgrades", "Customs" => "supplementalCustoms", "Resources" => "supplementalResources", _ => null };
if (supplement is not null) foreach (var p in ((JObject)Assets.Json($"world/{supplement}.json")).Properties()) if (result[p.Name] is null) result[p.Name] = p.Value.DeepClone();
if (EventItems.Value[name] is JObject eventItems) foreach (var p in eventItems.Properties()) if (result[p.Name] is null) result[p.Name] = p.Value.DeepClone();
return result;
})).Value;
public static JObject? Find(string table, string? type) => type is null ? null : Table(table)[type] as JObject;
// StoreItems can also occur inside an actual item path (for example avatar images).
// Only the leading market namespace is a conversion prefix.
public static string ItemType(string value) => value.StartsWith(MarketPrefix, StringComparison.Ordinal) ? "/Lotus/" + value[MarketPrefix.Length..] : value;
public static string StoreType(string value) => value.StartsWith(MarketPrefix, StringComparison.Ordinal) || !value.StartsWith("/Lotus/", StringComparison.Ordinal) ? value : MarketPrefix + value[7..];
}
using System.Collections.Concurrent;
using Newtonsoft.Json.Linq;
namespace XFEWarframe.Core.Data;
public static class GameData
{
private const string MarketPrefix = "/Lotus/StoreItems/";
// Callers must clone before modifying metadata shared between accounts.
private static readonly ConcurrentDictionary<string, Lazy<JObject>> tables = new(StringComparer.Ordinal);
private static readonly Lazy<JObject> EventItems = new(() => (JObject)Assets.Json("world/supplementalEventItems.json"));
public static JObject Table(string name) => tables.GetOrAdd(name, n => new(() =>
{
var result = (JObject)Assets.Json($"export/Export{n}.json");
var supplement = n switch { "Recipes" => "supplementalRecipes", "Warframes" => "supplementalSuits", "Weapons" => "supplementalWeapons", "Keys" => "supplementalKeys", "Upgrades" => "supplementalUpgrades", "Customs" => "supplementalCustoms", "Resources" => "supplementalResources", _ => null };
if (supplement is not null) foreach (var p in ((JObject)Assets.Json($"world/{supplement}.json")).Properties()) if (result[p.Name] is null) result[p.Name] = p.Value.DeepClone();
if (EventItems.Value[name] is JObject eventItems) foreach (var p in eventItems.Properties()) if (result[p.Name] is null) result[p.Name] = p.Value.DeepClone();
return result;
})).Value;
public static JObject? Find(string table, string? type) => type is null ? null : Table(table)[type] as JObject;
// StoreItems can also occur inside an actual item path (for example avatar images).
// Only the leading market namespace is a conversion prefix.
public static string ItemType(string value) => value.StartsWith(MarketPrefix, StringComparison.Ordinal) ? "/Lotus/" + value[MarketPrefix.Length..] : value;
public static string StoreType(string value) => value.StartsWith(MarketPrefix, StringComparison.Ordinal) || !value.StartsWith("/Lotus/", StringComparison.Ordinal) ? value : MarketPrefix + value[7..];
}