AbstractClassData.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  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. public readonly int id;
  136. public readonly string uniqueName;
  137. public readonly int sortId;
  138. public readonly string drawName;
  139. public readonly string explanatoryText;
  140. public readonly int[] experiences;
  141. public readonly ParametersPack[] levelBonuss;
  142. public readonly AbstractClassData.LearnConditions learnConditions;
  143. [Flags]
  144. public enum ClassType
  145. {
  146. Share = 1,
  147. New = 2,
  148. Old = 4
  149. }
  150. public class LearnConditions
  151. {
  152. public LearnConditions(CsvParser acquiredConditionCsv, int lineY, bool readOldCsv)
  153. {
  154. this.requestParameters = new ParametersPack();
  155. this.requestVipFlags = new List<int>();
  156. this.requestPersonals = new HashSet<int>();
  157. this.requestSeikeikens = new HashSet<Seikeiken>();
  158. this.requestContracts = new HashSet<Contract>();
  159. this.requestBillIds = new HashSet<int>();
  160. int cell_x = 1;
  161. if (!readOldCsv)
  162. {
  163. string cellAsString = acquiredConditionCsv.GetCellAsString(cell_x++, lineY);
  164. if (!string.IsNullOrEmpty(cellAsString))
  165. {
  166. string[] array = cellAsString.Split(new char[]
  167. {
  168. ','
  169. });
  170. foreach (string text in array)
  171. {
  172. int id = Personal.GetData(text.Trim()).id;
  173. if (!this.requestPersonals.Contains(id))
  174. {
  175. this.requestPersonals.Add(id);
  176. }
  177. }
  178. }
  179. cellAsString = acquiredConditionCsv.GetCellAsString(cell_x++, lineY);
  180. if (cellAsString == "〇")
  181. {
  182. foreach (Personal.Data data in Personal.GetAllDatas(false))
  183. {
  184. if (data.oldPersonal && !this.requestPersonals.Contains(data.id))
  185. {
  186. this.requestPersonals.Add(data.id);
  187. }
  188. }
  189. }
  190. cellAsString = acquiredConditionCsv.GetCellAsString(cell_x++, lineY);
  191. if (!string.IsNullOrEmpty(cellAsString))
  192. {
  193. string[] array3 = cellAsString.Split(new char[]
  194. {
  195. '|'
  196. });
  197. foreach (string value in array3)
  198. {
  199. this.requestSeikeikens.Add((Seikeiken)Enum.Parse(typeof(Seikeiken), value));
  200. }
  201. }
  202. cellAsString = acquiredConditionCsv.GetCellAsString(cell_x++, lineY);
  203. if (!string.IsNullOrEmpty(cellAsString))
  204. {
  205. string[] array5 = cellAsString.Split(new char[]
  206. {
  207. '|'
  208. });
  209. foreach (string value2 in array5)
  210. {
  211. this.requestContracts.Add((Contract)Enum.Parse(typeof(Contract), value2));
  212. }
  213. }
  214. cellAsString = acquiredConditionCsv.GetCellAsString(cell_x++, lineY);
  215. if (!string.IsNullOrEmpty(cellAsString))
  216. {
  217. string[] array7 = cellAsString.Split(new char[]
  218. {
  219. '|'
  220. });
  221. foreach (string s in array7)
  222. {
  223. this.requestBillIds.Add(int.Parse(s));
  224. }
  225. }
  226. }
  227. else
  228. {
  229. foreach (Personal.Data data2 in Personal.GetAllDatas(false))
  230. {
  231. if (data2.oldPersonal && !this.requestPersonals.Contains(data2.id))
  232. {
  233. this.requestPersonals.Add(data2.id);
  234. }
  235. }
  236. }
  237. while (acquiredConditionCsv.IsCellToExistData(cell_x, lineY))
  238. {
  239. string cellAsString2 = acquiredConditionCsv.GetCellAsString(cell_x++, lineY);
  240. int cellAsInteger = acquiredConditionCsv.GetCellAsInteger(cell_x++, lineY);
  241. if (cellAsString2 == "VIP")
  242. {
  243. if (!readOldCsv)
  244. {
  245. this.requestVipFlags.Add(cellAsInteger);
  246. }
  247. }
  248. else
  249. {
  250. ParametersPack.StatusType targetStatus = ParametersPack.NameToStatusType(cellAsString2);
  251. this.requestParameters.Set(targetStatus, cellAsInteger);
  252. }
  253. }
  254. }
  255. public bool isSpecialConditions()
  256. {
  257. return 0 < this.requestSeikeikens.Count || 0 < this.requestContracts.Count;
  258. }
  259. public bool CheckSpecialConditions(Status status)
  260. {
  261. return (0 >= this.requestSeikeikens.Count || this.requestSeikeikens.Contains(status.seikeiken)) && (0 >= this.requestContracts.Count || this.requestContracts.Contains(status.contract));
  262. }
  263. public bool isLearnPossiblePersonal(Personal.Data personalData)
  264. {
  265. return this.requestPersonals.Count == 0 || this.requestPersonals.Contains(personalData.id);
  266. }
  267. public bool isFutureLearnPossible(Status status)
  268. {
  269. 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);
  270. }
  271. public bool isLearnPossibleStatus(Status status)
  272. {
  273. if (0 < this.requestBillIds.Count)
  274. {
  275. bool flag = false;
  276. if (GameMain.Instance.FacilityMgr != null)
  277. {
  278. foreach (int facilityTypeID in this.requestBillIds)
  279. {
  280. flag |= GameMain.Instance.FacilityMgr.IsFacilityBuildFlag(facilityTypeID);
  281. }
  282. }
  283. if (!flag)
  284. {
  285. return false;
  286. }
  287. }
  288. if (!this.isLearnPossiblePersonal(status.personal) || !this.CheckSpecialConditions(status))
  289. {
  290. return false;
  291. }
  292. if (!this.requestParameters.GreaterThanOrEqualToStatus(status))
  293. {
  294. return false;
  295. }
  296. foreach (int key in this.requestVipFlags)
  297. {
  298. ReadOnlyDictionary<int, NightWorkState> night_works_state_dic = GameMain.Instance.CharacterMgr.status.night_works_state_dic;
  299. if (!night_works_state_dic.ContainsKey(key) || !night_works_state_dic[key].finish)
  300. {
  301. return false;
  302. }
  303. }
  304. return true;
  305. }
  306. public virtual List<KeyValuePair<string, bool>> CreateConditionTextAndStaturResults(Status status)
  307. {
  308. List<KeyValuePair<string, bool>> list = new List<KeyValuePair<string, bool>>();
  309. if (0 < this.requestSeikeikens.Count)
  310. {
  311. string text = "性経験 : ";
  312. bool flag = false;
  313. foreach (Seikeiken seikeiken in this.requestSeikeikens)
  314. {
  315. if (flag)
  316. {
  317. text += ",";
  318. }
  319. text += EnumConvert.GetString(seikeiken);
  320. flag = true;
  321. }
  322. list.Add(new KeyValuePair<string, bool>(text, this.requestSeikeikens.Contains(status.seikeiken)));
  323. }
  324. if (0 < this.requestContracts.Count)
  325. {
  326. string text2 = "契約タイプ : ";
  327. bool flag2 = false;
  328. foreach (Contract contract in this.requestContracts)
  329. {
  330. if (flag2)
  331. {
  332. text2 += ",";
  333. }
  334. text2 += EnumConvert.GetString(contract);
  335. flag2 = true;
  336. }
  337. list.Add(new KeyValuePair<string, bool>(text2, this.requestContracts.Contains(status.contract)));
  338. }
  339. if (0 < this.requestVipFlags.Count)
  340. {
  341. string text3 = string.Empty;
  342. foreach (int num in this.requestVipFlags)
  343. {
  344. if (!ScheduleCSVData.AllData.ContainsKey(num) || ScheduleCSVData.AllData[num].type != ScheduleTaskCtrl.TaskType.Yotogi)
  345. {
  346. text3 = "不明なVIP[" + num + "]を実行している";
  347. }
  348. else
  349. {
  350. ScheduleCSVData.ScheduleBase scheduleBase = ScheduleCSVData.AllData[num];
  351. ScheduleCSVData.Yotogi yotogi = (ScheduleCSVData.Yotogi)scheduleBase;
  352. text3 = "「" + yotogi.name + "」を実行している";
  353. }
  354. if (!string.IsNullOrEmpty(text3))
  355. {
  356. ReadOnlyDictionary<int, NightWorkState> night_works_state_dic = GameMain.Instance.CharacterMgr.status.night_works_state_dic;
  357. bool value = night_works_state_dic.ContainsKey(num) && night_works_state_dic[num].finish;
  358. list.Add(new KeyValuePair<string, bool>(text3, value));
  359. }
  360. }
  361. }
  362. List<KeyValuePair<string, bool>> list2 = this.requestParameters.CreateConditionTextAndStaturResults(status);
  363. foreach (KeyValuePair<string, bool> item in list2)
  364. {
  365. list.Add(item);
  366. }
  367. return list;
  368. }
  369. public readonly ParametersPack requestParameters;
  370. public readonly List<int> requestVipFlags;
  371. public readonly HashSet<int> requestPersonals;
  372. public readonly HashSet<Seikeiken> requestSeikeikens;
  373. public readonly HashSet<Contract> requestContracts;
  374. public readonly HashSet<int> requestBillIds;
  375. }
  376. }
  377. }