Personal.cs 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using wf;
  5. namespace MaidStatus
  6. {
  7. public static class Personal
  8. {
  9. public static int Count
  10. {
  11. get
  12. {
  13. Personal.CreateData();
  14. return Personal.commonIdManager.idMap.Count;
  15. }
  16. }
  17. public static bool Contains(string name)
  18. {
  19. return Personal.commonIdManager.nameMap.ContainsKey(name);
  20. }
  21. public static bool Contains(int id)
  22. {
  23. return Personal.commonIdManager.idMap.ContainsKey(id);
  24. }
  25. public static int uniqueNameToId(string name)
  26. {
  27. Personal.CreateData();
  28. NDebug.Assert(Personal.commonIdManager.nameMap.ContainsKey(name), "性格\nユニーク名[" + name + "]をIDに変換できませんでした");
  29. return Personal.commonIdManager.nameMap[name];
  30. }
  31. public static string IdToUniqueName(int id)
  32. {
  33. Personal.CreateData();
  34. NDebug.Assert(Personal.commonIdManager.idMap.ContainsKey(id), "性格\nID[" + id + "]をユニーク名に変換できませんでした");
  35. return Personal.commonIdManager.idMap[id].Key;
  36. }
  37. public static Personal.Data GetData(int id)
  38. {
  39. Personal.CreateData();
  40. NDebug.Assert(Personal.basicDatas.ContainsKey(id), "性格\nID[" + id + "]のデータは存在しません");
  41. return Personal.basicDatas[id];
  42. }
  43. public static Personal.Data GetData(string uniqueName)
  44. {
  45. return Personal.GetData(Personal.uniqueNameToId(uniqueName));
  46. }
  47. public static bool IsEnabled(string uniqueName)
  48. {
  49. Personal.CreateData();
  50. return Personal.commonIdManager.enabledIdList.Contains(Personal.uniqueNameToId(uniqueName));
  51. }
  52. public static bool IsEnabled(int id)
  53. {
  54. Personal.CreateData();
  55. return Personal.commonIdManager.enabledIdList.Contains(id);
  56. }
  57. public static List<Personal.Data> GetAllDatas(bool onlyEnabled)
  58. {
  59. Personal.CreateData();
  60. List<Personal.Data> list = new List<Personal.Data>();
  61. foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair in Personal.commonIdManager.idMap)
  62. {
  63. if (!onlyEnabled || Personal.commonIdManager.enabledIdList.Contains(keyValuePair.Key))
  64. {
  65. list.Add(Personal.basicDatas[keyValuePair.Key]);
  66. }
  67. }
  68. return list;
  69. }
  70. public static void CreateData()
  71. {
  72. if (Personal.commonIdManager != null)
  73. {
  74. return;
  75. }
  76. Personal.commonIdManager = new CsvCommonIdManager("maid_status_personal", "性格", CsvCommonIdManager.Type.IdAndUniqueName, null);
  77. Personal.basicDatas = new Dictionary<int, Personal.Data>();
  78. using (AFileBase afileBase = GameUty.FileSystem.FileOpen("maid_status_personal_request_plugin.nei"))
  79. {
  80. using (CsvParser csvParser = new CsvParser())
  81. {
  82. csvParser.Open(afileBase);
  83. NDebug.Assert(csvParser.IsValid(), "maid_status_personal_request_plugin\nopen failed.");
  84. for (int i = 1; i < csvParser.max_cell_y; i++)
  85. {
  86. int cellAsInteger = csvParser.GetCellAsInteger(0, i);
  87. string cellAsString = csvParser.GetCellAsString(3, i);
  88. if (!string.IsNullOrEmpty(cellAsString))
  89. {
  90. if (Personal.commonIdManager.enabledIdList.Contains(cellAsInteger) && !PluginData.IsEnabled(cellAsString))
  91. {
  92. Personal.commonIdManager.enabledIdList.Remove(cellAsInteger);
  93. }
  94. }
  95. }
  96. }
  97. }
  98. string[] array = new string[]
  99. {
  100. "list",
  101. "feature_condition"
  102. };
  103. KeyValuePair<AFileBase, CsvParser>[] array2 = new KeyValuePair<AFileBase, CsvParser>[array.Length];
  104. for (int j = 0; j < array2.Length; j++)
  105. {
  106. string text = "maid_status_personal_" + array[j] + ".nei";
  107. AFileBase afileBase2 = GameUty.FileSystem.FileOpen(text);
  108. CsvParser csvParser2 = new CsvParser();
  109. bool condition = csvParser2.Open(afileBase2);
  110. NDebug.Assert(condition, text + "\nopen failed.");
  111. array2[j] = new KeyValuePair<AFileBase, CsvParser>(afileBase2, csvParser2);
  112. }
  113. foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair in Personal.commonIdManager.idMap)
  114. {
  115. Personal.basicDatas.Add(keyValuePair.Key, new Personal.Data(keyValuePair.Key, array2[0].Value, array2[1].Value));
  116. }
  117. foreach (KeyValuePair<AFileBase, CsvParser> keyValuePair2 in array2)
  118. {
  119. keyValuePair2.Value.Dispose();
  120. keyValuePair2.Key.Dispose();
  121. }
  122. }
  123. private const string csvTopCommonName = "maid_status_personal";
  124. private const string typeNameForErrorLog = "性格";
  125. private static CsvCommonIdManager commonIdManager;
  126. private static Dictionary<int, Personal.Data> basicDatas;
  127. public class Data
  128. {
  129. public Data(int id, CsvParser basicCsv, CsvParser featureConditionsCsv)
  130. {
  131. List<int> list = new List<int>();
  132. for (int i = 0; i < basicCsv.max_cell_y; i++)
  133. {
  134. if (basicCsv.IsCellToExistData(0, i) && basicCsv.GetCellAsInteger(0, i) == id)
  135. {
  136. this.id = id;
  137. int num = 1;
  138. this.uniqueName = basicCsv.GetCellAsString(num++, i);
  139. this.drawName = basicCsv.GetCellAsString(num++, i);
  140. this.replaceText = basicCsv.GetCellAsString(num++, i);
  141. this.bgmFileName = Path.ChangeExtension(basicCsv.GetCellAsString(num++, i), ".ogg");
  142. string cellAsString = basicCsv.GetCellAsString(num++, i);
  143. this.oldPersonal = (cellAsString == "〇");
  144. string[] array = basicCsv.GetCellAsString(num++, i).Split(new char[]
  145. {
  146. '/'
  147. });
  148. this.competitiveMotionFileVictory = new KeyValuePair<string, string>(Path.ChangeExtension(array[0], ".ks"), array[1]);
  149. array = basicCsv.GetCellAsString(num++, i).Split(new char[]
  150. {
  151. '/'
  152. });
  153. this.competitiveMotionFileDefeat = new KeyValuePair<string, string>(Path.ChangeExtension(array[0], ".ks"), array[1]);
  154. break;
  155. }
  156. }
  157. this.acquisitionFeatureList = new List<Personal.Data.LearnFeature>();
  158. for (int j = 0; j < featureConditionsCsv.max_cell_y; j++)
  159. {
  160. if (featureConditionsCsv.IsCellToExistData(0, j) && featureConditionsCsv.GetCellAsString(0, j) == this.uniqueName)
  161. {
  162. int num2 = 0;
  163. while (featureConditionsCsv.IsCellToExistData(1, j + num2))
  164. {
  165. this.acquisitionFeatureList.Add(new Personal.Data.LearnFeature(featureConditionsCsv, j + num2));
  166. num2++;
  167. }
  168. break;
  169. }
  170. }
  171. }
  172. public readonly int id;
  173. public readonly string uniqueName;
  174. public readonly string drawName;
  175. public readonly string replaceText;
  176. public readonly string bgmFileName;
  177. public readonly bool oldPersonal;
  178. public readonly KeyValuePair<string, string> competitiveMotionFileVictory;
  179. public readonly KeyValuePair<string, string> competitiveMotionFileDefeat;
  180. public readonly List<Personal.Data.LearnFeature> acquisitionFeatureList;
  181. public class LearnFeature
  182. {
  183. public LearnFeature(CsvParser featureConditionsCsv, int lineY)
  184. {
  185. this.requestParameters = new ParametersPack();
  186. int cell_x = 1;
  187. string cellAsString = featureConditionsCsv.GetCellAsString(cell_x++, lineY);
  188. this.feature = Feature.GetData(cellAsString);
  189. this.requestSeikeikens = true;
  190. string cellAsString2 = featureConditionsCsv.GetCellAsString(cell_x++, lineY);
  191. if (cellAsString2 == "両穴")
  192. {
  193. this.needSeikeiken = Seikeiken.Yes_Yes;
  194. }
  195. else if (cellAsString2 == "前穴")
  196. {
  197. this.needSeikeiken = Seikeiken.Yes_No;
  198. }
  199. else if (cellAsString2 == "後穴")
  200. {
  201. this.needSeikeiken = Seikeiken.No_Yes;
  202. }
  203. else
  204. {
  205. this.requestSeikeikens = false;
  206. }
  207. while (featureConditionsCsv.IsCellToExistData(cell_x, lineY))
  208. {
  209. string cellAsString3 = featureConditionsCsv.GetCellAsString(cell_x++, lineY);
  210. int cellAsInteger = featureConditionsCsv.GetCellAsInteger(cell_x++, lineY);
  211. this.requestParameters.Add(ParametersPack.NameToStatusType(cellAsString3), cellAsInteger);
  212. }
  213. }
  214. public bool isLearnPossible(Status status)
  215. {
  216. return (!this.requestSeikeikens || this.needSeikeiken == status.seikeiken) && this.requestParameters.GreaterThanOrEqualToStatus(status);
  217. }
  218. public readonly Feature.Data feature;
  219. public readonly bool requestSeikeikens;
  220. public readonly Seikeiken needSeikeiken;
  221. public readonly ParametersPack requestParameters;
  222. }
  223. }
  224. }
  225. }