HumanReadableRoundNames.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using System;
  2. using System.Collections;
  3. using System.Text.RegularExpressions;
  4. namespace MISTBowl_Brackets
  5. {
  6. public static class HumanReadableRoundNames
  7. {
  8. static readonly Hashtable m_hashtable = new Hashtable(0);
  9. public static string GetHumanReadableName(string roundName)
  10. {
  11. try
  12. {
  13. if (m_hashtable.Count == 0)
  14. {
  15. m_hashtable.Add("QF", "QUARTER-FINALS");
  16. m_hashtable.Add("SF", "SEMI-FINALS");
  17. m_hashtable.Add("F", "FINALS");
  18. }
  19. if (Regex.IsMatch(roundName, "^PRELIM[0-9]+/[0-9]+$"))
  20. return "PRELIMINARY ROUND " + Regex.Split(roundName, "^PRELIM")[1].Split('/')[0] + " OF " + roundName.Split('/')[1];
  21. if (Regex.IsMatch(roundName, "^ROUNDOF[0-9]+$"))
  22. return "ROUND OF " + Regex.Split(roundName, "^ROUNDOF")[1];
  23. if (m_hashtable[roundName] == null)
  24. throw new ApplicationException();
  25. return (string)m_hashtable[roundName];
  26. }
  27. catch (Exception e)
  28. {
  29. Traceback.Write("At string GetHumanReadableName(string) (class HumanReadableRoundNames):");
  30. throw e;
  31. }
  32. }
  33. }
  34. }