using System.Collections.Generic; namespace Theriapolis.GodotHost.UI; /// /// Per-background availability rules — which backgrounds are visible / /// pickable for a given . The /// backgrounds.json schema doesn't carry restriction fields (gating /// lives in flavor text), so they're hardcoded here. /// /// Used by StepBackground to filter the visible card list and by /// StepClade to clear the currently-selected background when a clade /// change makes it no longer valid (e.g. picking a non-canid lineage /// while Pack-Raised is selected). /// public static class BackgroundAvailability { private static readonly Dictionary> Rules = new() { // Hybrid-only backgrounds — flavor text explicitly hybrid. { "passer", d => d.IsHybrid }, { "hybrid_underground", d => d.IsHybrid }, { "former_chattel", d => d.IsHybrid }, // Clade-restricted backgrounds. { "warren_runner", d => d.HasClade("leporidae") }, { "pack_raised", d => d.HasClade("canidae") }, { "herd_city_born", d => d.HasAnyCladeOfKind("prey") }, }; /// True if the background id can be picked under the given /// draft state. Backgrounds not in the rules table are universally /// available; the empty id is also "available" (means no /// background selected). public static bool IsAvailable(string backgroundId, CharacterDraft draft) { if (string.IsNullOrEmpty(backgroundId)) return true; if (!Rules.TryGetValue(backgroundId, out var rule)) return true; return rule(draft); } }