AbstractClassData.cs 12 KB

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