Files
Radicade/Server/Keepsakes/KeepsakeCatalog.cs
T
2026-10-16 23:33:13 -07:00

45 lines
1.8 KiB
C#

namespace RadicadeServer.RecNet.Keepsakes
{
public static class KeepsakeCatalog
{
public sealed record Category(int KeepsakeCategoryId, string VisualId, int LimitPerRoom, int XpValue, string IconOutlineImageName, string IconFilledImageName);
public static readonly Category[] All =
{
new(6, "science_core_red_OLD", 5, 40, "aebsucfhhn98ymh4z25ot8d6x.png", "cxaofjxo76zxa338274fsstof.png"),
new(5, "science_core_blue_OLD", 5, 30, "4w053xrmhi3as5s50fm6kpw6h.png", "bx4ikmxlnmk2tf3z132j94yrd.png"),
new(4, "science_core_yellow_OLD", 5, 20, "08ms9eetb8xhyv9d9nt4ml1lq.png", "0tliyqyr3ckv9h7i5zo6w5sa1.png"),
new(2, "presents", 2, 50, "d5v1c62yb5tzedako4x91u7ll.png", "9abduornso8kkr34frsoyp7wp.png"),
new(0, "explore", 3, 20, "aknjr1eq1hmrx7mr7wyfvll07.png", "701ffxv6rli6btqtvzdh26mse.png"),
};
public static bool Enabled
=> !string.Equals(Environment.GetEnvironmentVariable("RADICADE_KEEPSAKE_CATALOG"), "empty", StringComparison.OrdinalIgnoreCase);
public static string? IconOverride
=> NullIfBlank(Environment.GetEnvironmentVariable("RADICADE_KEEPSAKE_ICON"));
public static object[] Results() => Results(Enabled);
public static object[] Results(bool enabled)
{
if (!enabled) return Array.Empty<object>();
var icon = IconOverride;
return All.Select(c => (object)new
{
KeepsakeCategoryId = c.KeepsakeCategoryId,
VisualId = c.VisualId,
LimitPerRoom = c.LimitPerRoom,
XpValue = c.XpValue,
IconOutlineImageName = icon ?? c.IconOutlineImageName,
IconFilledImageName = icon ?? c.IconFilledImageName,
}).ToArray();
}
public static Category? Find(int id) => All.FirstOrDefault(c => c.KeepsakeCategoryId == id);
private static string? NullIfBlank(string? value)
=> string.IsNullOrWhiteSpace(value) ? null : value;
}
}