using Core.Entities; namespace Core.Printing; /// /// Rank labels and colors shared by the ranking index, print badges, and legend. /// public static class EventRankLegend { public static readonly IReadOnlyList<(int Rank, string Label)> Items = [ .. Enumerable.Range(1, StudentEventRanking.MaxRank) .Select(rank => (rank, Ordinal(rank))) ]; public static string Ordinal(int num) { if (num <= 0) return num.ToString(); switch (num % 100) { case 11: case 12: case 13: return num + "th"; } return (num % 10) switch { 1 => num + "st", 2 => num + "nd", 3 => num + "rd", _ => num + "th" }; } public static string ColorHex(int rank) => rank switch { 1 => "#dd7e6b", 2 => "#ea9999", 3 => "#f9cb9c", 4 => "#ffe599", 5 => "#fff2cc", 6 => "#fffaea", 7 => "#fffefa", 8 => "#fffefc", 9 => "#fffffd", 10 => "#fffffe", _ => "#ddd" }; }