YotogiClass.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. using System;
  2. using System.Collections.Generic;
  3. using MaidStatus.CsvData;
  4. using wf;
  5. using Yotogis;
  6. namespace MaidStatus
  7. {
  8. public static class YotogiClass
  9. {
  10. public static int Count
  11. {
  12. get
  13. {
  14. YotogiClass.CreateData();
  15. return YotogiClass.commonIdManager.idMap.Count;
  16. }
  17. }
  18. public static bool Contains(string name)
  19. {
  20. return YotogiClass.commonIdManager.nameMap.ContainsKey(name);
  21. }
  22. public static bool Contains(int id)
  23. {
  24. return YotogiClass.commonIdManager.idMap.ContainsKey(id);
  25. }
  26. public static int uniqueNameToId(string name)
  27. {
  28. YotogiClass.CreateData();
  29. NDebug.Assert(YotogiClass.commonIdManager.nameMap.ContainsKey(name), "夜伽クラス\nユニーク名[" + name + "]をIDに変換できませんでした");
  30. return YotogiClass.commonIdManager.nameMap[name];
  31. }
  32. public static string IdToUniqueName(int id)
  33. {
  34. YotogiClass.CreateData();
  35. NDebug.Assert(YotogiClass.commonIdManager.idMap.ContainsKey(id), "夜伽クラス\nID[" + id + "]をユニーク名に変換できませんでした");
  36. return YotogiClass.commonIdManager.idMap[id].Key;
  37. }
  38. public static YotogiClass.Data GetData(int id)
  39. {
  40. YotogiClass.CreateData();
  41. NDebug.Assert(YotogiClass.basicDatas.ContainsKey(id), "夜伽クラス\nID[" + id + "]のデータは存在しません");
  42. return YotogiClass.basicDatas[id];
  43. }
  44. public static YotogiClass.Data GetData(string uniqueName)
  45. {
  46. return YotogiClass.GetData(YotogiClass.uniqueNameToId(uniqueName));
  47. }
  48. public static bool IsEnabled(string uniqueName)
  49. {
  50. YotogiClass.CreateData();
  51. return YotogiClass.commonIdManager.enabledIdList.Contains(YotogiClass.uniqueNameToId(uniqueName));
  52. }
  53. public static bool IsEnabled(int id)
  54. {
  55. YotogiClass.CreateData();
  56. return YotogiClass.commonIdManager.enabledIdList.Contains(id);
  57. }
  58. public static List<YotogiClass.Data> GetAllDatas(bool onlyEnabled)
  59. {
  60. YotogiClass.CreateData();
  61. List<YotogiClass.Data> list = new List<YotogiClass.Data>();
  62. foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair in YotogiClass.commonIdManager.idMap)
  63. {
  64. if (!onlyEnabled || YotogiClass.commonIdManager.enabledIdList.Contains(keyValuePair.Key))
  65. {
  66. list.Add(YotogiClass.basicDatas[keyValuePair.Key]);
  67. }
  68. }
  69. return list;
  70. }
  71. public static SortedList<int, List<Skill.Data>> GetLearnSkillList(string uniqueName)
  72. {
  73. return YotogiClass.GetLearnSkillList(YotogiClass.uniqueNameToId(uniqueName));
  74. }
  75. public static SortedList<int, List<Skill.Data>> GetLearnSkillList(int id)
  76. {
  77. if (YotogiClass.learnSkillList == null)
  78. {
  79. YotogiClass.learnSkillList = new Dictionary<int, SortedList<int, List<Skill.Data>>>();
  80. Skill.CreateData();
  81. YotogiClass.CreateData();
  82. foreach (YotogiClass.Data data in YotogiClass.GetAllDatas(false))
  83. {
  84. YotogiClass.learnSkillList.Add(data.id, new SortedList<int, List<Skill.Data>>());
  85. }
  86. for (int i = 0; i < Skill.skill_data_list.Length; i++)
  87. {
  88. foreach (Skill.Data data2 in Skill.skill_data_list[i].Values)
  89. {
  90. if (data2.getcondition_data.yotogi_class != null)
  91. {
  92. if (YotogiClass.learnSkillList.ContainsKey(data2.getcondition_data.yotogi_class.id))
  93. {
  94. SortedList<int, List<Skill.Data>> sortedList = YotogiClass.learnSkillList[data2.getcondition_data.yotogi_class.id];
  95. if (sortedList.ContainsKey(data2.getcondition_data.yotogi_class_level))
  96. {
  97. sortedList[data2.getcondition_data.yotogi_class_level].Add(data2);
  98. }
  99. else
  100. {
  101. List<Skill.Data> list = new List<Skill.Data>();
  102. list.Add(data2);
  103. sortedList.Add(data2.getcondition_data.yotogi_class_level, list);
  104. }
  105. }
  106. }
  107. }
  108. }
  109. }
  110. NDebug.Assert(YotogiClass.learnSkillList.ContainsKey(id), "夜伽クラス\nID[" + id + "]のデータは存在しません");
  111. return YotogiClass.learnSkillList[id];
  112. }
  113. public static SortedList<int, List<Skill.Old.Data>> GetLearnSkillOldList(string uniqueName)
  114. {
  115. return YotogiClass.GetLearnSkillOldList(YotogiClass.uniqueNameToId(uniqueName));
  116. }
  117. public static SortedList<int, List<Skill.Old.Data>> GetLearnSkillOldList(int id)
  118. {
  119. if (YotogiClass.learnSkillOldList == null)
  120. {
  121. YotogiClass.learnSkillOldList = new Dictionary<int, SortedList<int, List<Skill.Old.Data>>>();
  122. Skill.CreateData();
  123. YotogiClass.CreateData();
  124. foreach (YotogiClass.Data data in YotogiClass.GetAllDatas(false))
  125. {
  126. YotogiClass.learnSkillOldList.Add(data.id, new SortedList<int, List<Skill.Old.Data>>());
  127. }
  128. for (int i = 0; i < Skill.Old.skill_data_list.Length; i++)
  129. {
  130. foreach (Skill.Old.Data data2 in Skill.Old.skill_data_list[i].Values)
  131. {
  132. if (1 <= data2.getcondition_data.yotogi_class_level)
  133. {
  134. if (YotogiClass.learnSkillOldList.ContainsKey(data2.getcondition_data.yotogi_class.id))
  135. {
  136. SortedList<int, List<Skill.Old.Data>> sortedList = YotogiClass.learnSkillOldList[data2.getcondition_data.yotogi_class.id];
  137. if (sortedList.ContainsKey(data2.getcondition_data.yotogi_class_level))
  138. {
  139. sortedList[data2.getcondition_data.yotogi_class_level].Add(data2);
  140. }
  141. else
  142. {
  143. List<Skill.Old.Data> list = new List<Skill.Old.Data>();
  144. list.Add(data2);
  145. sortedList.Add(data2.getcondition_data.yotogi_class_level, list);
  146. }
  147. }
  148. }
  149. }
  150. }
  151. }
  152. NDebug.Assert(YotogiClass.learnSkillOldList.ContainsKey(id), "夜伽クラス\nID[" + id + "]のデータは存在しません");
  153. return YotogiClass.learnSkillOldList[id];
  154. }
  155. public static bool IsNTRClass(int id, bool refOld)
  156. {
  157. YotogiClass.Data data = YotogiClass.GetData(id);
  158. if (refOld && data.classType == AbstractClassData.ClassType.New)
  159. {
  160. refOld = false;
  161. }
  162. else if (!refOld && data.classType == AbstractClassData.ClassType.Old)
  163. {
  164. refOld = true;
  165. }
  166. bool flag = true;
  167. if (refOld)
  168. {
  169. SortedList<int, List<Skill.Old.Data>> sortedList = YotogiClass.GetLearnSkillOldList(data.id);
  170. if (sortedList.Count == 0)
  171. {
  172. flag = false;
  173. }
  174. foreach (KeyValuePair<int, List<Skill.Old.Data>> keyValuePair in sortedList)
  175. {
  176. List<Skill.Old.Data> value = keyValuePair.Value;
  177. for (int i = 0; i < value.Count; i++)
  178. {
  179. if (value[i].category != YotogiOld.Category.交換 && value[i].category != YotogiOld.Category.乱交)
  180. {
  181. flag = false;
  182. break;
  183. }
  184. if (!flag)
  185. {
  186. break;
  187. }
  188. }
  189. if (!flag)
  190. {
  191. break;
  192. }
  193. }
  194. }
  195. else
  196. {
  197. SortedList<int, List<Skill.Data>> sortedList2 = YotogiClass.GetLearnSkillList(data.id);
  198. if (sortedList2.Count == 0)
  199. {
  200. flag = false;
  201. }
  202. foreach (KeyValuePair<int, List<Skill.Data>> keyValuePair2 in sortedList2)
  203. {
  204. List<Skill.Data> value2 = keyValuePair2.Value;
  205. for (int j = 0; j < value2.Count; j++)
  206. {
  207. if (value2[j].category != Yotogi.Category.交換 && value2[j].category != Yotogi.Category.乱交)
  208. {
  209. flag = false;
  210. break;
  211. }
  212. if (!flag)
  213. {
  214. break;
  215. }
  216. }
  217. if (!flag)
  218. {
  219. break;
  220. }
  221. }
  222. }
  223. return flag;
  224. }
  225. public static void CreateData()
  226. {
  227. if (YotogiClass.commonIdManager != null)
  228. {
  229. return;
  230. }
  231. YotogiClass.commonIdManager = new CsvCommonIdManager("maid_status_yotogiclass", "夜伽クラス", CsvCommonIdManager.Type.IdAndUniqueName, null);
  232. YotogiClass.basicDatas = new Dictionary<int, YotogiClass.Data>();
  233. string[] array = new string[]
  234. {
  235. "list",
  236. "acquired_condition",
  237. "bonus",
  238. "experiences"
  239. };
  240. KeyValuePair<AFileBase, CsvParser>[] array2 = new KeyValuePair<AFileBase, CsvParser>[array.Length];
  241. for (int i = 0; i < array2.Length; i++)
  242. {
  243. string text = "maid_status_yotogiclass_" + array[i] + ".nei";
  244. AFileBase afileBase = GameUty.FileSystem.FileOpen(text);
  245. CsvParser csvParser = new CsvParser();
  246. bool condition = csvParser.Open(afileBase);
  247. NDebug.Assert(condition, text + "\nopen failed.");
  248. array2[i] = new KeyValuePair<AFileBase, CsvParser>(afileBase, csvParser);
  249. }
  250. foreach (KeyValuePair<string, int> keyValuePair in YotogiClass.commonIdManager.nameMap)
  251. {
  252. string key = keyValuePair.Key;
  253. YotogiClass.Data value = new YotogiClass.Data(key, array2[0].Value, array2[1].Value, array2[2].Value, array2[3].Value);
  254. YotogiClass.basicDatas.Add(keyValuePair.Value, value);
  255. }
  256. foreach (KeyValuePair<AFileBase, CsvParser> keyValuePair2 in array2)
  257. {
  258. keyValuePair2.Value.Dispose();
  259. keyValuePair2.Key.Dispose();
  260. }
  261. if (GameUty.FileSystemOld.IsExistentFile("yotogi_class_enabled_list.nei"))
  262. {
  263. Dictionary<string, string> enabledIdListOld = new Dictionary<string, string>();
  264. Action<string> action = delegate(string file_name)
  265. {
  266. file_name += ".nei";
  267. if (!GameUty.FileSystemOld.IsExistentFile(file_name))
  268. {
  269. return;
  270. }
  271. using (AFileBase afileBase3 = GameUty.FileSystemOld.FileOpen(file_name))
  272. {
  273. using (CsvParser csvParser3 = new CsvParser())
  274. {
  275. bool condition3 = csvParser3.Open(afileBase3);
  276. NDebug.Assert(condition3, file_name + "\nopen failed.");
  277. for (int num = 1; num < csvParser3.max_cell_y; num++)
  278. {
  279. if (csvParser3.IsCellToExistData(0, num))
  280. {
  281. string cellAsString2 = csvParser3.GetCellAsString(0, num);
  282. string cellAsString3 = csvParser3.GetCellAsString(1, num);
  283. if (!enabledIdListOld.ContainsKey(cellAsString2))
  284. {
  285. enabledIdListOld.Add(cellAsString2, cellAsString3);
  286. }
  287. }
  288. }
  289. }
  290. }
  291. };
  292. action("yotogi_class_enabled_list");
  293. for (int k = 0; k < GameUty.PathListOld.Count; k++)
  294. {
  295. action("yotogi_class_enabled_list_" + GameUty.PathListOld[k]);
  296. }
  297. array = new string[]
  298. {
  299. "infotext",
  300. "acquisition_data",
  301. "bonus_status",
  302. "exp_list"
  303. };
  304. array2 = new KeyValuePair<AFileBase, CsvParser>[array.Length];
  305. for (int l = 0; l < array2.Length; l++)
  306. {
  307. string text2 = "yotogi_class_" + array[l] + ".nei";
  308. AFileBase afileBase2 = GameUty.FileSystemOld.FileOpen(text2);
  309. CsvParser csvParser2 = new CsvParser();
  310. bool condition2 = csvParser2.Open(afileBase2);
  311. NDebug.Assert(condition2, text2 + "\nopen failed.");
  312. array2[l] = new KeyValuePair<AFileBase, CsvParser>(afileBase2, csvParser2);
  313. }
  314. Dictionary<int, KeyValuePair<string, string>> dictionary = new Dictionary<int, KeyValuePair<string, string>>();
  315. Dictionary<string, int> dictionary2 = new Dictionary<string, int>();
  316. for (int m = 1; m < array2[0].Value.max_cell_y; m++)
  317. {
  318. int cellAsInteger = array2[0].Value.GetCellAsInteger(0, m);
  319. if (!YotogiClass.basicDatas.ContainsKey(cellAsInteger))
  320. {
  321. string cellAsString = array2[0].Value.GetCellAsString(1, m);
  322. string text3 = (!enabledIdListOld.ContainsKey(cellAsString)) ? cellAsString : enabledIdListOld[cellAsString];
  323. YotogiClass.Data value2 = new YotogiClass.Data(cellAsString, text3, array2[0].Value, array2[1].Value, array2[2].Value, array2[3].Value);
  324. YotogiClass.basicDatas.Add(cellAsInteger, value2);
  325. dictionary.Add(cellAsInteger, new KeyValuePair<string, string>(cellAsString, text3));
  326. dictionary2.Add(cellAsString, cellAsInteger);
  327. }
  328. else
  329. {
  330. YotogiClass.basicDatas[cellAsInteger].SetClassType(AbstractClassData.ClassType.Share);
  331. }
  332. }
  333. Dictionary<int, KeyValuePair<string, string>> dictionary3 = new Dictionary<int, KeyValuePair<string, string>>(YotogiClass.commonIdManager.idMap);
  334. Dictionary<string, int> dictionary4 = new Dictionary<string, int>(YotogiClass.commonIdManager.nameMap);
  335. HashSet<int> hashSet = new HashSet<int>(YotogiClass.commonIdManager.enabledIdList);
  336. foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair3 in dictionary)
  337. {
  338. dictionary3.Add(keyValuePair3.Key, keyValuePair3.Value);
  339. NDebug.Assert(!dictionary4.ContainsKey(keyValuePair3.Value.Key), "夜伽クラスのユニーク名[" + keyValuePair3.Value.Key + "]が重複しています");
  340. dictionary4.Add(keyValuePair3.Value.Key, keyValuePair3.Key);
  341. }
  342. foreach (KeyValuePair<string, string> keyValuePair4 in enabledIdListOld)
  343. {
  344. if (dictionary2.ContainsKey(keyValuePair4.Key) && !hashSet.Contains(dictionary2[keyValuePair4.Key]))
  345. {
  346. hashSet.Add(dictionary2[keyValuePair4.Key]);
  347. }
  348. }
  349. YotogiClass.commonIdManager = new CsvCommonIdManager(dictionary3, dictionary4, hashSet, CsvCommonIdManager.Type.IdAndUniqueName);
  350. foreach (KeyValuePair<AFileBase, CsvParser> keyValuePair5 in array2)
  351. {
  352. keyValuePair5.Value.Dispose();
  353. keyValuePair5.Key.Dispose();
  354. }
  355. }
  356. }
  357. private const string csvTopCommonName = "maid_status_yotogiclass";
  358. private const string typeNameForErrorLog = "夜伽クラス";
  359. private static CsvCommonIdManager commonIdManager;
  360. private static Dictionary<int, YotogiClass.Data> basicDatas;
  361. private static Dictionary<int, SortedList<int, List<Skill.Data>>> learnSkillList;
  362. private static Dictionary<int, SortedList<int, List<Skill.Old.Data>>> learnSkillOldList;
  363. public class Data : AbstractClassData
  364. {
  365. public Data(string uniqueName, CsvParser basicCsv, CsvParser acquiredConditionCsv, CsvParser bonusCsv, CsvParser experienceCsv) : base(uniqueName, basicCsv, acquiredConditionCsv, bonusCsv, experienceCsv)
  366. {
  367. }
  368. public Data(string uniqueName, string drawName, CsvParser infoCsv, CsvParser acquiredConditionCsv, CsvParser bonusCsv, CsvParser experienceCsv) : base(uniqueName, drawName, infoCsv, acquiredConditionCsv, bonusCsv, experienceCsv)
  369. {
  370. }
  371. protected override string termCategoryName
  372. {
  373. get
  374. {
  375. return "夜伽クラス";
  376. }
  377. }
  378. }
  379. }
  380. }