LikabilityReplace.cs 1.5 KB

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