using System; using System.Collections.Generic; namespace IdleSpectator; /// Book dials from event-catalog.json books. public static partial class EventCatalog { public static class Book { private static readonly Dictionary Entries = new Dictionary(StringComparer.OrdinalIgnoreCase); private static int _appliedGeneration = -1; public static void InvalidateOverlays() { Entries.Clear(); _appliedGeneration = -1; } private static void Ensure() { if (_appliedGeneration == EventCatalogConfig.Generation) { return; } _appliedGeneration = EventCatalogConfig.Generation; EventCatalogConfig.FillBooks(Entries); } public static IEnumerable AuthoredIds { get { Ensure(); return Entries.Keys; } } public static bool HasAuthored(string id) { Ensure(); return !string.IsNullOrEmpty(id) && Entries.ContainsKey(id.Trim()); } public static DiscreteEventEntry GetOrFallback(string id) { Ensure(); if (!string.IsNullOrEmpty(id) && Entries.TryGetValue(id.Trim(), out DiscreteEventEntry entry)) { return entry; } string key = string.IsNullOrEmpty(id) ? "unknown" : id.Trim(); return new DiscreteEventEntry { Id = key, EventStrength = 45f, Category = "Culture", LabelTemplate = "{a} writes a book", CreatesInterest = true, IsFallback = true }; } } }