WorkCountReplace.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System;
  2. using System.Collections.Generic;
  3. namespace Kasizuki
  4. {
  5. public static class WorkCountReplace
  6. {
  7. public static string GetWorkCountName(int workCount)
  8. {
  9. WorkCountReplace.CreateData();
  10. string text = string.Empty;
  11. foreach (KeyValuePair<int, string> keyValuePair in WorkCountReplace.basicData)
  12. {
  13. int key = keyValuePair.Key;
  14. if (workCount < key)
  15. {
  16. break;
  17. }
  18. text = keyValuePair.Value;
  19. }
  20. if (string.IsNullOrEmpty(text))
  21. {
  22. NDebug.Assert("Error WorkCountReplace.GetWorkCountName(int)", false);
  23. }
  24. return text;
  25. }
  26. public static SortedDictionary<int, string> GetDic()
  27. {
  28. WorkCountReplace.CreateData();
  29. return WorkCountReplace.basicData;
  30. }
  31. private static void CreateData()
  32. {
  33. if (WorkCountReplace.basicData != null)
  34. {
  35. return;
  36. }
  37. WorkCountReplace.basicData = new SortedDictionary<int, string>();
  38. string str = "kasizuki_work_count_convert_list";
  39. using (AFileBase afileBase = GameUty.FileSystem.FileOpen(str + ".nei"))
  40. {
  41. using (CsvParser csvParser = new CsvParser())
  42. {
  43. bool condition = csvParser.Open(afileBase);
  44. NDebug.Assert(condition, str + "\nopen failed.");
  45. for (int i = 1; i < csvParser.max_cell_y; i++)
  46. {
  47. int num = 0;
  48. int cellAsInteger = csvParser.GetCellAsInteger(num++, i);
  49. string cellAsString = csvParser.GetCellAsString(num++, i);
  50. WorkCountReplace.basicData.Add(cellAsInteger, cellAsString);
  51. }
  52. }
  53. }
  54. }
  55. private const string csvFileName = "kasizuki_work_count_convert_list";
  56. private static SortedDictionary<int, string> basicData;
  57. }
  58. }