namespace IdleSpectator;
///
/// Shared catalog row for discrete / library-backed spectator events.
/// Lives in Events/ with - catalogs own dials; director only ranks.
///
public sealed class DiscreteEventEntry
{
public string Id = "";
public float EventStrength = 50f;
public string Category = "Event";
public bool CreatesInterest = true;
public string LabelTemplate = "{a}";
///
/// Optional infinitive clause for decision-style reasons
/// (e.g. change the kingdom's culture → {a} decides to …).
///
public string ActionPhrase = "";
///
/// When set, {id} resolves via for this domain.
///
public string LibraryKind = "";
public bool IsFallback;
public string MakeLabel(Actor a, Actor b = null)
{
string template = LabelTemplate ?? "";
if (template.IndexOf("casts {id}", System.StringComparison.OrdinalIgnoreCase) >= 0
|| template.IndexOf("casts {ID}", System.StringComparison.OrdinalIgnoreCase) >= 0)
{
string an = EventFeedUtil.SafeName(a);
string obj = EventReason.SpellCastObject(Id);
return (string.IsNullOrEmpty(an) ? "Someone" : an) + " casts " + obj;
}
string displayId = ResolveIdDisplay();
string t = string.IsNullOrEmpty(template) ? "{a}" : template;
return t
.Replace("{id}", displayId)
.Replace("{a}", EventFeedUtil.SafeName(a) ?? "")
.Replace("{b}", EventFeedUtil.SafeName(b) ?? "");
}
public string MakeLabel(string a, string b)
{
string template = string.IsNullOrEmpty(LabelTemplate) ? "{id}" : LabelTemplate;
if (template.IndexOf("casts {id}", System.StringComparison.OrdinalIgnoreCase) >= 0)
{
string an = string.IsNullOrEmpty(a) ? "Someone" : a;
return an + " casts " + EventReason.SpellCastObject(Id);
}
string displayId = ResolveIdDisplay();
return template
.Replace("{id}", displayId)
.Replace("{a}", a ?? "")
.Replace("{b}", b ?? "");
}
/// Localized library name when is set; else humanized id.
public string ResolveIdDisplay()
{
if (string.IsNullOrEmpty(Id))
{
return "";
}
if (!string.IsNullOrEmpty(LibraryKind))
{
string named = LibraryAssetNames.DisplayName(LibraryKind, Id);
if (!string.IsNullOrEmpty(named))
{
return named;
}
}
return EventReason.HumanizeId(Id);
}
}