Personal.cs 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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. string[] array = new string[]
  79. {
  80. "list",
  81. "feature_condition"
  82. };
  83. KeyValuePair<AFileBase, CsvParser>[] array2 = new KeyValuePair<AFileBase, CsvParser>[array.Length];
  84. for (int i = 0; i < array2.Length; i++)
  85. {
  86. string text = "maid_status_personal_" + array[i] + ".nei";
  87. AFileBase afileBase = GameUty.FileSystem.FileOpen(text);
  88. CsvParser csvParser = new CsvParser();
  89. bool condition = csvParser.Open(afileBase);
  90. NDebug.Assert(condition, text + "\nopen failed.");
  91. array2[i] = new KeyValuePair<AFileBase, CsvParser>(afileBase, csvParser);
  92. }
  93. foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair in Personal.commonIdManager.idMap)
  94. {
  95. Personal.basicDatas.Add(keyValuePair.Key, new Personal.Data(keyValuePair.Key, array2[0].Value, array2[1].Value));
  96. }
  97. foreach (KeyValuePair<AFileBase, CsvParser> keyValuePair2 in array2)
  98. {
  99. keyValuePair2.Value.Dispose();
  100. keyValuePair2.Key.Dispose();
  101. }
  102. }
  103. private const string csvTopCommonName = "maid_status_personal";
  104. private const string typeNameForErrorLog = "性格";
  105. private static CsvCommonIdManager commonIdManager;
  106. private static Dictionary<int, Personal.Data> basicDatas;
  107. public class Data
  108. {
  109. public Data(int id, CsvParser basicCsv, CsvParser featureConditionsCsv)
  110. {
  111. List<int> list = new List<int>();
  112. for (int i = 0; i < basicCsv.max_cell_y; i++)
  113. {
  114. if (basicCsv.IsCellToExistData(0, i) && basicCsv.GetCellAsInteger(0, i) == id)
  115. {
  116. this.id = id;
  117. int num = 1;
  118. this.uniqueName = basicCsv.GetCellAsString(num++, i);
  119. this.drawName = basicCsv.GetCellAsString(num++, i);
  120. this.replaceText = basicCsv.GetCellAsString(num++, i);
  121. this.bgmFileName = Path.ChangeExtension(basicCsv.GetCellAsString(num++, i), ".ogg");
  122. string cellAsString = basicCsv.GetCellAsString(num++, i);
  123. this.oldPersonal = (cellAsString == "〇");
  124. cellAsString = basicCsv.GetCellAsString(num++, i);
  125. if (this.oldPersonal)
  126. {
  127. this.compatible = true;
  128. foreach (string text in cellAsString.Split(new char[]
  129. {
  130. ','
  131. }))
  132. {
  133. if (!string.IsNullOrEmpty(text) && !PluginData.IsEnabled(text))
  134. {
  135. this.compatible = false;
  136. break;
  137. }
  138. }
  139. }
  140. else
  141. {
  142. this.compatible = false;
  143. }
  144. cellAsString = basicCsv.GetCellAsString(num++, i);
  145. if (this.oldPersonal)
  146. {
  147. this.single = true;
  148. foreach (string text2 in cellAsString.Split(new char[]
  149. {
  150. ','
  151. }))
  152. {
  153. if (!string.IsNullOrEmpty(text2) && !PluginData.IsEnabled(text2))
  154. {
  155. this.single = false;
  156. break;
  157. }
  158. }
  159. }
  160. else
  161. {
  162. this.single = true;
  163. }
  164. string[] array3 = basicCsv.GetCellAsString(num++, i).Split(new char[]
  165. {
  166. '/'
  167. });
  168. this.competitiveMotionFileVictory = new KeyValuePair<string, string>(Path.ChangeExtension(array3[0], ".ks"), array3[1]);
  169. array3 = basicCsv.GetCellAsString(num++, i).Split(new char[]
  170. {
  171. '/'
  172. });
  173. this.competitiveMotionFileDefeat = new KeyValuePair<string, string>(Path.ChangeExtension(array3[0], ".ks"), array3[1]);
  174. break;
  175. }
  176. }
  177. this.acquisitionFeatureList = new List<Personal.Data.LearnFeature>();
  178. for (int l = 0; l < featureConditionsCsv.max_cell_y; l++)
  179. {
  180. if (featureConditionsCsv.IsCellToExistData(0, l) && featureConditionsCsv.GetCellAsString(0, l) == this.uniqueName)
  181. {
  182. int num2 = 0;
  183. while (featureConditionsCsv.IsCellToExistData(1, l + num2))
  184. {
  185. this.acquisitionFeatureList.Add(new Personal.Data.LearnFeature(featureConditionsCsv, l + num2));
  186. num2++;
  187. }
  188. break;
  189. }
  190. }
  191. }
  192. public readonly int id;
  193. public readonly string uniqueName;
  194. public readonly string drawName;
  195. public readonly string replaceText;
  196. public readonly string bgmFileName;
  197. public readonly bool oldPersonal;
  198. public readonly bool compatible;
  199. public readonly bool single;
  200. public readonly KeyValuePair<string, string> competitiveMotionFileVictory;
  201. public readonly KeyValuePair<string, string> competitiveMotionFileDefeat;
  202. public readonly List<Personal.Data.LearnFeature> acquisitionFeatureList;
  203. public class LearnFeature
  204. {
  205. public LearnFeature(CsvParser featureConditionsCsv, int lineY)
  206. {
  207. this.requestParameters = new ParametersPack();
  208. int cell_x = 1;
  209. string cellAsString = featureConditionsCsv.GetCellAsString(cell_x++, lineY);
  210. this.feature = Feature.GetData(cellAsString);
  211. this.requestSeikeikens = true;
  212. string cellAsString2 = featureConditionsCsv.GetCellAsString(cell_x++, lineY);
  213. if (cellAsString2 == "両穴")
  214. {
  215. this.needSeikeiken = Seikeiken.Yes_Yes;
  216. }
  217. else if (cellAsString2 == "前穴")
  218. {
  219. this.needSeikeiken = Seikeiken.Yes_No;
  220. }
  221. else if (cellAsString2 == "後穴")
  222. {
  223. this.needSeikeiken = Seikeiken.No_Yes;
  224. }
  225. else
  226. {
  227. this.requestSeikeikens = false;
  228. }
  229. while (featureConditionsCsv.IsCellToExistData(cell_x, lineY))
  230. {
  231. string cellAsString3 = featureConditionsCsv.GetCellAsString(cell_x++, lineY);
  232. int cellAsInteger = featureConditionsCsv.GetCellAsInteger(cell_x++, lineY);
  233. this.requestParameters.Add(ParametersPack.NameToStatusType(cellAsString3), cellAsInteger);
  234. }
  235. }
  236. public bool isLearnPossible(Status status)
  237. {
  238. return (!this.requestSeikeikens || this.needSeikeiken == status.seikeiken) && this.requestParameters.GreaterThanOrEqualToStatus(status);
  239. }
  240. public readonly Feature.Data feature;
  241. public readonly bool requestSeikeikens;
  242. public readonly Seikeiken needSeikeiken;
  243. public readonly ParametersPack requestParameters;
  244. }
  245. }
  246. }
  247. }