AbstractClassData.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. using System;
  2. using System.Collections.Generic;
  3. using PlayerStatus;
  4. using Schedule;
  5. using UnityEngine;
  6. using wf;
  7. namespace MaidStatus.CsvData
  8. {
  9. public abstract class AbstractClassData : IComparable, IComparable<AbstractClassData>
  10. {
  11. public AbstractClassData(string uniqueName, CsvParser basicCsv, CsvParser acquiredConditionCsv, CsvParser bonusCsv, CsvParser experienceCsv)
  12. {
  13. Func<CsvParser, int> func = delegate(CsvParser csv)
  14. {
  15. int cell_x = (basicCsv != csv) ? 0 : 1;
  16. for (int j = 1; j < csv.max_cell_y; j++)
  17. {
  18. if (csv.IsCellToExistData(cell_x, j))
  19. {
  20. if (uniqueName == csv.GetCellAsString(cell_x, j))
  21. {
  22. return j;
  23. }
  24. }
  25. }
  26. Debug.LogError("csv情報が不正です\n[" + uniqueName + "]を見つけられませんでした");
  27. return -1;
  28. };
  29. CsvParser basicCsv2 = basicCsv;
  30. int i = 0;
  31. int num = func(basicCsv2);
  32. this.id = basicCsv2.GetCellAsInteger(i++, num);
  33. this.uniqueName = basicCsv2.GetCellAsString(i++, num);
  34. this.drawName = basicCsv2.GetCellAsString(i++, num);
  35. this.sortId = basicCsv2.GetCellAsInteger(i++, num);
  36. this.explanatoryText = basicCsv2.GetCellAsString(i++, num);
  37. num = func(experienceCsv);
  38. List<int> list = new List<int>();
  39. i = 1;
  40. while (experienceCsv.IsCellToExistData(i, num))
  41. {
  42. list.Add(experienceCsv.GetCellAsInteger(i, num));
  43. i++;
  44. }
  45. this.experiences = list.ToArray();
  46. num = func(bonusCsv);
  47. ParametersPack parametersPack = new ParametersPack();
  48. this.levelBonuss = new ParametersPack[this.experiences.Length];
  49. for (i = 1; i <= this.levelBonuss.Length; i++)
  50. {
  51. this.levelBonuss[i - 1] = new ParametersPack();
  52. this.levelBonuss[i - 1].Parse(bonusCsv.GetCellAsString(i, num), ',');
  53. parametersPack += this.levelBonuss[i - 1];
  54. this.levelBonuss[i - 1] = new ParametersPack(parametersPack);
  55. }
  56. num = func(acquiredConditionCsv);
  57. this.learnConditions = new AbstractClassData.LearnConditions(acquiredConditionCsv, num, false);
  58. this.classType = AbstractClassData.ClassType.New;
  59. }
  60. public AbstractClassData(string uniqueName, string drawName, CsvParser infoCsv, CsvParser acquiredConditionCsv, CsvParser bonusCsv, CsvParser experienceCsv)
  61. {
  62. Func<CsvParser, int> func = delegate(CsvParser csv)
  63. {
  64. int cell_x = (infoCsv != csv) ? 0 : 1;
  65. if (infoCsv == csv && !infoCsv.IsCellToExistData(2, 0))
  66. {
  67. cell_x = 0;
  68. }
  69. for (int j = 1; j < csv.max_cell_y; j++)
  70. {
  71. if (csv.IsCellToExistData(cell_x, j))
  72. {
  73. if (uniqueName == csv.GetCellAsString(cell_x, j))
  74. {
  75. return j;
  76. }
  77. }
  78. }
  79. Debug.LogError("csv情報が不正です\n[" + uniqueName + "]を見つけられませんでした");
  80. return -1;
  81. };
  82. CsvParser infoCsv2 = infoCsv;
  83. int i = 0;
  84. int num = func(infoCsv2);
  85. if (!infoCsv2.IsCellToExistData(2, num))
  86. {
  87. this.id = num - 1;
  88. this.uniqueName = infoCsv2.GetCellAsString(i++, num);
  89. this.drawName = drawName;
  90. }
  91. else
  92. {
  93. this.id = infoCsv2.GetCellAsInteger(i++, num);
  94. this.uniqueName = infoCsv2.GetCellAsString(i++, num);
  95. this.drawName = drawName;
  96. }
  97. this.sortId = this.id;
  98. this.explanatoryText = infoCsv2.GetCellAsString(i++, num);
  99. num = func(experienceCsv);
  100. List<int> list = new List<int>();
  101. i = 1;
  102. while (experienceCsv.IsCellToExistData(i, num))
  103. {
  104. list.Add(experienceCsv.GetCellAsInteger(i, num));
  105. i++;
  106. }
  107. this.experiences = list.ToArray();
  108. num = func(bonusCsv);
  109. ParametersPack parametersPack = new ParametersPack();
  110. this.levelBonuss = new ParametersPack[this.experiences.Length];
  111. for (i = 1; i <= this.levelBonuss.Length; i++)
  112. {
  113. this.levelBonuss[i - 1] = new ParametersPack();
  114. this.levelBonuss[i - 1].Parse(bonusCsv.GetCellAsString(i, num).Replace("精神力", "精神"), ',');
  115. parametersPack += this.levelBonuss[i - 1];
  116. this.levelBonuss[i - 1] = new ParametersPack(parametersPack);
  117. }
  118. num = func(acquiredConditionCsv);
  119. this.learnConditions = new AbstractClassData.LearnConditions(acquiredConditionCsv, num, true);
  120. this.classType = AbstractClassData.ClassType.Old;
  121. }
  122. public int CompareTo(AbstractClassData other)
  123. {
  124. return this.sortId.CompareTo(other.sortId);
  125. }
  126. public int CompareTo(object other)
  127. {
  128. return this.sortId.CompareTo(((AbstractClassData)other).sortId);
  129. }
  130. public void SetClassType(AbstractClassData.ClassType classType)
  131. {
  132. this.classType = classType;
  133. }
  134. public AbstractClassData.ClassType classType { get; private set; }
  135. protected abstract string termCategoryName { get; }
  136. public string termName
  137. {
  138. get
  139. {
  140. return "MaidStatus/" + this.termCategoryName + "/" + this.uniqueName;
  141. }
  142. }
  143. public string termExplanatoryText
  144. {
  145. get
  146. {
  147. return "MaidStatus/" + this.termCategoryName + "/説明/" + this.uniqueName;
  148. }
  149. }
  150. public readonly int id;
  151. public readonly string uniqueName;
  152. public readonly int sortId;
  153. public readonly string drawName;
  154. public readonly string explanatoryText;
  155. public readonly int[] experiences;
  156. public readonly ParametersPack[] levelBonuss;
  157. public readonly AbstractClassData.LearnConditions learnConditions;
  158. [Flags]
  159. public enum ClassType
  160. {
  161. Share = 1,
  162. New = 2,
  163. Old = 4
  164. }
  165. public class LearnConditions
  166. {
  167. public LearnConditions(CsvParser acquiredConditionCsv, int lineY, bool readOldCsv)
  168. {
  169. this.requestParameters = new ParametersPack();
  170. this.requestVipFlags = new List<int>();
  171. this.requestPersonals = new HashSet<int>();
  172. this.requestSeikeikens = new HashSet<Seikeiken>();
  173. this.requestContracts = new HashSet<Contract>();
  174. this.requestBillIds = new HashSet<int>();
  175. int cell_x = 1;
  176. if (!readOldCsv)
  177. {
  178. string cellAsString = acquiredConditionCsv.GetCellAsString(cell_x++, lineY);
  179. if (!string.IsNullOrEmpty(cellAsString))
  180. {
  181. string[] array = cellAsString.Split(new char[]
  182. {
  183. ','
  184. });
  185. foreach (string text in array)
  186. {
  187. int id = Personal.GetData(text.Trim()).id;
  188. if (!this.requestPersonals.Contains(id))
  189. {
  190. this.requestPersonals.Add(id);
  191. }
  192. }
  193. }
  194. cellAsString = acquiredConditionCsv.GetCellAsString(cell_x++, lineY);
  195. if (cellAsString == "〇")
  196. {
  197. foreach (Personal.Data data in Personal.GetAllDatas(false))
  198. {
  199. if (data.oldPersonal && !this.requestPersonals.Contains(data.id))
  200. {
  201. this.requestPersonals.Add(data.id);
  202. }
  203. }
  204. }
  205. cellAsString = acquiredConditionCsv.GetCellAsString(cell_x++, lineY);
  206. if (!string.IsNullOrEmpty(cellAsString))
  207. {
  208. string[] array3 = cellAsString.Split(new char[]
  209. {
  210. '|'
  211. });
  212. foreach (string value in array3)
  213. {
  214. this.requestSeikeikens.Add((Seikeiken)Enum.Parse(typeof(Seikeiken), value));
  215. }
  216. }
  217. cellAsString = acquiredConditionCsv.GetCellAsString(cell_x++, lineY);
  218. if (!string.IsNullOrEmpty(cellAsString))
  219. {
  220. string[] array5 = cellAsString.Split(new char[]
  221. {
  222. '|'
  223. });
  224. foreach (string value2 in array5)
  225. {
  226. this.requestContracts.Add((Contract)Enum.Parse(typeof(Contract), value2));
  227. }
  228. }
  229. cellAsString = acquiredConditionCsv.GetCellAsString(cell_x++, lineY);
  230. if (!string.IsNullOrEmpty(cellAsString))
  231. {
  232. string[] array7 = cellAsString.Split(new char[]
  233. {
  234. '|'
  235. });
  236. foreach (string s in array7)
  237. {
  238. this.requestBillIds.Add(int.Parse(s));
  239. }
  240. }
  241. }
  242. else
  243. {
  244. foreach (Personal.Data data2 in Personal.GetAllDatas(false))
  245. {
  246. if (data2.oldPersonal && !this.requestPersonals.Contains(data2.id))
  247. {
  248. this.requestPersonals.Add(data2.id);
  249. }
  250. }
  251. }
  252. while (acquiredConditionCsv.IsCellToExistData(cell_x, lineY))
  253. {
  254. string cellAsString2 = acquiredConditionCsv.GetCellAsString(cell_x++, lineY);
  255. int cellAsInteger = acquiredConditionCsv.GetCellAsInteger(cell_x++, lineY);
  256. if (cellAsString2 == "VIP")
  257. {
  258. if (!readOldCsv)
  259. {
  260. this.requestVipFlags.Add(cellAsInteger);
  261. }
  262. }
  263. else
  264. {
  265. ParametersPack.StatusType targetStatus = ParametersPack.NameToStatusType(cellAsString2);
  266. this.requestParameters.Set(targetStatus, cellAsInteger);
  267. }
  268. }
  269. }
  270. public bool isSpecialConditions()
  271. {
  272. return 0 < this.requestSeikeikens.Count || 0 < this.requestContracts.Count;
  273. }
  274. public bool CheckSpecialConditions(Status status)
  275. {
  276. return (0 >= this.requestSeikeikens.Count || this.requestSeikeikens.Contains(status.seikeiken)) && (0 >= this.requestContracts.Count || this.requestContracts.Contains(status.contract));
  277. }
  278. public bool isLearnPossiblePersonal(Personal.Data personalData)
  279. {
  280. return this.requestPersonals.Count == 0 || this.requestPersonals.Contains(personalData.id);
  281. }
  282. public bool isFutureLearnPossible(Status status)
  283. {
  284. return (0 >= this.requestContracts.Count || status.contract == Contract.Trainee || this.requestContracts.Contains(status.contract)) && (0 >= this.requestSeikeikens.Count || this.requestSeikeikens.Contains(status.seikeiken) || (!this.requestSeikeikens.Contains(Seikeiken.Yes_No) && !this.requestSeikeikens.Contains(Seikeiken.No_Yes)) || status.seikeiken == Seikeiken.No_No) && this.isLearnPossiblePersonal(status.personal);
  285. }
  286. public bool isLearnPossibleStatus(Status status)
  287. {
  288. if (0 < this.requestBillIds.Count)
  289. {
  290. bool flag = false;
  291. if (GameMain.Instance.FacilityMgr != null)
  292. {
  293. foreach (int facilityTypeID in this.requestBillIds)
  294. {
  295. flag |= GameMain.Instance.FacilityMgr.IsFacilityBuildFlag(facilityTypeID);
  296. }
  297. }
  298. if (!flag)
  299. {
  300. return false;
  301. }
  302. }
  303. if (!this.isLearnPossiblePersonal(status.personal) || !this.CheckSpecialConditions(status))
  304. {
  305. return false;
  306. }
  307. if (!this.requestParameters.GreaterThanOrEqualToStatus(status))
  308. {
  309. return false;
  310. }
  311. foreach (int key in this.requestVipFlags)
  312. {
  313. ReadOnlyDictionary<int, NightWorkState> night_works_state_dic = GameMain.Instance.CharacterMgr.status.night_works_state_dic;
  314. if (!night_works_state_dic.ContainsKey(key) || !night_works_state_dic[key].finish)
  315. {
  316. return false;
  317. }
  318. }
  319. return true;
  320. }
  321. public virtual List<KeyValuePair<string[], bool>> CreateConditionTextAndStaturResults(Status status)
  322. {
  323. List<KeyValuePair<string[], bool>> list = new List<KeyValuePair<string[], bool>>();
  324. if (0 < this.requestSeikeikens.Count)
  325. {
  326. string text = "MaidStatus/条件文/性経験 : ";
  327. List<string> list2 = new List<string>();
  328. int num = 0;
  329. bool flag = false;
  330. foreach (Seikeiken seikeiken in this.requestSeikeikens)
  331. {
  332. if (flag)
  333. {
  334. text += ",";
  335. }
  336. list2.Add(EnumConvert.GetTerm(seikeiken));
  337. string text2 = text;
  338. text = string.Concat(new object[]
  339. {
  340. text2,
  341. "{",
  342. num,
  343. "}"
  344. });
  345. flag = true;
  346. num++;
  347. }
  348. List<string> list3 = new List<string>();
  349. list3.Add(text);
  350. list3.AddRange(list2);
  351. list.Add(new KeyValuePair<string[], bool>(list3.ToArray(), this.requestSeikeikens.Contains(status.seikeiken)));
  352. }
  353. if (0 < this.requestContracts.Count)
  354. {
  355. string text3 = "MaidStatus/条件文/契約タイプ : ";
  356. List<string> list4 = new List<string>();
  357. int num2 = 0;
  358. bool flag2 = false;
  359. foreach (Contract contract in this.requestContracts)
  360. {
  361. if (flag2)
  362. {
  363. text3 += ",";
  364. }
  365. list4.Add(EnumConvert.GetTerm(contract));
  366. string text2 = text3;
  367. text3 = string.Concat(new object[]
  368. {
  369. text2,
  370. "{",
  371. num2,
  372. "}"
  373. });
  374. flag2 = true;
  375. num2++;
  376. }
  377. List<string> list5 = new List<string>();
  378. list5.Add(text3);
  379. list5.AddRange(list4);
  380. list.Add(new KeyValuePair<string[], bool>(list5.ToArray(), this.requestContracts.Contains(status.contract)));
  381. }
  382. if (0 < this.requestVipFlags.Count)
  383. {
  384. string empty = string.Empty;
  385. foreach (int key in this.requestVipFlags)
  386. {
  387. List<string> list6 = new List<string>();
  388. if (!ScheduleCSVData.AllData.ContainsKey(key) || ScheduleCSVData.AllData[key].type != ScheduleTaskCtrl.TaskType.Yotogi)
  389. {
  390. list6.Add("不明なVIP[{0}]を実行している");
  391. list6.Add(key.ToString());
  392. }
  393. else
  394. {
  395. ScheduleCSVData.ScheduleBase scheduleBase = ScheduleCSVData.AllData[key];
  396. ScheduleCSVData.Yotogi yotogi = (ScheduleCSVData.Yotogi)scheduleBase;
  397. list6.Add("「{0}」を実行している");
  398. list6.Add(yotogi.name);
  399. }
  400. if (!string.IsNullOrEmpty(empty))
  401. {
  402. ReadOnlyDictionary<int, NightWorkState> night_works_state_dic = GameMain.Instance.CharacterMgr.status.night_works_state_dic;
  403. bool value = night_works_state_dic.ContainsKey(key) && night_works_state_dic[key].finish;
  404. list.Add(new KeyValuePair<string[], bool>(list6.ToArray(), value));
  405. }
  406. }
  407. }
  408. List<KeyValuePair<string[], bool>> list7 = this.requestParameters.CreateConditionTextAndStaturResults(status);
  409. foreach (KeyValuePair<string[], bool> item in list7)
  410. {
  411. list.Add(item);
  412. }
  413. return list;
  414. }
  415. public readonly ParametersPack requestParameters;
  416. public readonly List<int> requestVipFlags;
  417. public readonly HashSet<int> requestPersonals;
  418. public readonly HashSet<Seikeiken> requestSeikeikens;
  419. public readonly HashSet<Contract> requestContracts;
  420. public readonly HashSet<int> requestBillIds;
  421. }
  422. }
  423. }