123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454 |
- using System;
- using System.Collections.Generic;
- using PlayerStatus;
- using Schedule;
- using UnityEngine;
- using wf;
- namespace MaidStatus.CsvData
- {
- public abstract class AbstractClassData : IComparable, IComparable<AbstractClassData>
- {
- public AbstractClassData(string uniqueName, CsvParser basicCsv, CsvParser acquiredConditionCsv, CsvParser bonusCsv, CsvParser experienceCsv)
- {
- Func<CsvParser, int> func = delegate(CsvParser csv)
- {
- int cell_x = (basicCsv != csv) ? 0 : 1;
- for (int j = 1; j < csv.max_cell_y; j++)
- {
- if (csv.IsCellToExistData(cell_x, j))
- {
- if (uniqueName == csv.GetCellAsString(cell_x, j))
- {
- return j;
- }
- }
- }
- Debug.LogError("csv情報が不正です\n[" + uniqueName + "]を見つけられませんでした");
- return -1;
- };
- CsvParser basicCsv2 = basicCsv;
- int i = 0;
- int num = func(basicCsv2);
- this.id = basicCsv2.GetCellAsInteger(i++, num);
- this.uniqueName = basicCsv2.GetCellAsString(i++, num);
- this.drawName = basicCsv2.GetCellAsString(i++, num);
- this.sortId = basicCsv2.GetCellAsInteger(i++, num);
- this.explanatoryText = basicCsv2.GetCellAsString(i++, num);
- num = func(experienceCsv);
- List<int> list = new List<int>();
- i = 1;
- while (experienceCsv.IsCellToExistData(i, num))
- {
- list.Add(experienceCsv.GetCellAsInteger(i, num));
- i++;
- }
- this.experiences = list.ToArray();
- num = func(bonusCsv);
- ParametersPack parametersPack = new ParametersPack();
- this.levelBonuss = new ParametersPack[this.experiences.Length];
- for (i = 1; i <= this.levelBonuss.Length; i++)
- {
- this.levelBonuss[i - 1] = new ParametersPack();
- this.levelBonuss[i - 1].Parse(bonusCsv.GetCellAsString(i, num), ',');
- parametersPack += this.levelBonuss[i - 1];
- this.levelBonuss[i - 1] = new ParametersPack(parametersPack);
- }
- num = func(acquiredConditionCsv);
- this.learnConditions = new AbstractClassData.LearnConditions(acquiredConditionCsv, num, false);
- this.classType = AbstractClassData.ClassType.New;
- }
- public AbstractClassData(string uniqueName, string drawName, CsvParser infoCsv, CsvParser acquiredConditionCsv, CsvParser bonusCsv, CsvParser experienceCsv)
- {
- Func<CsvParser, int> func = delegate(CsvParser csv)
- {
- int cell_x = (infoCsv != csv) ? 0 : 1;
- if (infoCsv == csv && !infoCsv.IsCellToExistData(2, 0))
- {
- cell_x = 0;
- }
- for (int j = 1; j < csv.max_cell_y; j++)
- {
- if (csv.IsCellToExistData(cell_x, j))
- {
- if (uniqueName == csv.GetCellAsString(cell_x, j))
- {
- return j;
- }
- }
- }
- Debug.LogError("csv情報が不正です\n[" + uniqueName + "]を見つけられませんでした");
- return -1;
- };
- CsvParser infoCsv2 = infoCsv;
- int i = 0;
- int num = func(infoCsv2);
- if (!infoCsv2.IsCellToExistData(2, num))
- {
- this.id = num - 1;
- this.uniqueName = infoCsv2.GetCellAsString(i++, num);
- this.drawName = drawName;
- }
- else
- {
- this.id = infoCsv2.GetCellAsInteger(i++, num);
- this.uniqueName = infoCsv2.GetCellAsString(i++, num);
- this.drawName = drawName;
- }
- this.sortId = this.id;
- this.explanatoryText = infoCsv2.GetCellAsString(i++, num);
- num = func(experienceCsv);
- List<int> list = new List<int>();
- i = 1;
- while (experienceCsv.IsCellToExistData(i, num))
- {
- list.Add(experienceCsv.GetCellAsInteger(i, num));
- i++;
- }
- this.experiences = list.ToArray();
- num = func(bonusCsv);
- ParametersPack parametersPack = new ParametersPack();
- this.levelBonuss = new ParametersPack[this.experiences.Length];
- for (i = 1; i <= this.levelBonuss.Length; i++)
- {
- this.levelBonuss[i - 1] = new ParametersPack();
- this.levelBonuss[i - 1].Parse(bonusCsv.GetCellAsString(i, num).Replace("精神力", "精神"), ',');
- parametersPack += this.levelBonuss[i - 1];
- this.levelBonuss[i - 1] = new ParametersPack(parametersPack);
- }
- num = func(acquiredConditionCsv);
- this.learnConditions = new AbstractClassData.LearnConditions(acquiredConditionCsv, num, true);
- this.classType = AbstractClassData.ClassType.Old;
- }
- public int CompareTo(AbstractClassData other)
- {
- return this.sortId.CompareTo(other.sortId);
- }
- public int CompareTo(object other)
- {
- return this.sortId.CompareTo(((AbstractClassData)other).sortId);
- }
- public void SetClassType(AbstractClassData.ClassType classType)
- {
- this.classType = classType;
- }
- public AbstractClassData.ClassType classType { get; private set; }
- protected abstract string termCategoryName { get; }
- public string termName
- {
- get
- {
- return "MaidStatus/" + this.termCategoryName + "/" + this.uniqueName;
- }
- }
- public string termExplanatoryText
- {
- get
- {
- return "MaidStatus/" + this.termCategoryName + "/説明/" + this.uniqueName;
- }
- }
- public readonly int id;
- public readonly string uniqueName;
- public readonly int sortId;
- public readonly string drawName;
- public readonly string explanatoryText;
- public readonly int[] experiences;
- public readonly ParametersPack[] levelBonuss;
- public readonly AbstractClassData.LearnConditions learnConditions;
- [Flags]
- public enum ClassType
- {
- Share = 1,
- New = 2,
- Old = 4
- }
- public class LearnConditions
- {
- public LearnConditions(CsvParser acquiredConditionCsv, int lineY, bool readOldCsv)
- {
- this.requestParameters = new ParametersPack();
- this.requestVipFlags = new List<int>();
- this.requestPersonals = new HashSet<int>();
- this.requestSeikeikens = new HashSet<Seikeiken>();
- this.requestContracts = new HashSet<Contract>();
- this.requestBillIds = new HashSet<int>();
- int cell_x = 1;
- if (!readOldCsv)
- {
- string cellAsString = acquiredConditionCsv.GetCellAsString(cell_x++, lineY);
- if (!string.IsNullOrEmpty(cellAsString))
- {
- string[] array = cellAsString.Split(new char[]
- {
- ','
- });
- foreach (string text in array)
- {
- int id = Personal.GetData(text.Trim()).id;
- if (!this.requestPersonals.Contains(id))
- {
- this.requestPersonals.Add(id);
- }
- }
- }
- cellAsString = acquiredConditionCsv.GetCellAsString(cell_x++, lineY);
- if (cellAsString == "〇")
- {
- foreach (Personal.Data data in Personal.GetAllDatas(false))
- {
- if (data.oldPersonal && !this.requestPersonals.Contains(data.id))
- {
- this.requestPersonals.Add(data.id);
- }
- }
- }
- cellAsString = acquiredConditionCsv.GetCellAsString(cell_x++, lineY);
- if (!string.IsNullOrEmpty(cellAsString))
- {
- string[] array3 = cellAsString.Split(new char[]
- {
- '|'
- });
- foreach (string value in array3)
- {
- this.requestSeikeikens.Add((Seikeiken)Enum.Parse(typeof(Seikeiken), value));
- }
- }
- cellAsString = acquiredConditionCsv.GetCellAsString(cell_x++, lineY);
- if (!string.IsNullOrEmpty(cellAsString))
- {
- string[] array5 = cellAsString.Split(new char[]
- {
- '|'
- });
- foreach (string value2 in array5)
- {
- this.requestContracts.Add((Contract)Enum.Parse(typeof(Contract), value2));
- }
- }
- cellAsString = acquiredConditionCsv.GetCellAsString(cell_x++, lineY);
- if (!string.IsNullOrEmpty(cellAsString))
- {
- string[] array7 = cellAsString.Split(new char[]
- {
- '|'
- });
- foreach (string s in array7)
- {
- this.requestBillIds.Add(int.Parse(s));
- }
- }
- }
- else
- {
- foreach (Personal.Data data2 in Personal.GetAllDatas(false))
- {
- if (data2.oldPersonal && !this.requestPersonals.Contains(data2.id))
- {
- this.requestPersonals.Add(data2.id);
- }
- }
- }
- while (acquiredConditionCsv.IsCellToExistData(cell_x, lineY))
- {
- string cellAsString2 = acquiredConditionCsv.GetCellAsString(cell_x++, lineY);
- int cellAsInteger = acquiredConditionCsv.GetCellAsInteger(cell_x++, lineY);
- if (cellAsString2 == "VIP")
- {
- if (!readOldCsv)
- {
- this.requestVipFlags.Add(cellAsInteger);
- }
- }
- else
- {
- ParametersPack.StatusType targetStatus = ParametersPack.NameToStatusType(cellAsString2);
- this.requestParameters.Set(targetStatus, cellAsInteger);
- }
- }
- }
- public bool isSpecialConditions()
- {
- return 0 < this.requestSeikeikens.Count || 0 < this.requestContracts.Count;
- }
- public bool CheckSpecialConditions(Status status)
- {
- return (0 >= this.requestSeikeikens.Count || this.requestSeikeikens.Contains(status.seikeiken)) && (0 >= this.requestContracts.Count || this.requestContracts.Contains(status.contract));
- }
- public bool isLearnPossiblePersonal(Personal.Data personalData)
- {
- return this.requestPersonals.Count == 0 || this.requestPersonals.Contains(personalData.id);
- }
- public bool isFutureLearnPossible(Status status)
- {
- 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);
- }
- public bool isLearnPossibleStatus(Status status)
- {
- if (0 < this.requestBillIds.Count)
- {
- bool flag = false;
- if (GameMain.Instance.FacilityMgr != null)
- {
- foreach (int facilityTypeID in this.requestBillIds)
- {
- flag |= GameMain.Instance.FacilityMgr.IsFacilityBuildFlag(facilityTypeID);
- }
- }
- if (!flag)
- {
- return false;
- }
- }
- if (!this.isLearnPossiblePersonal(status.personal) || !this.CheckSpecialConditions(status))
- {
- return false;
- }
- if (!this.requestParameters.GreaterThanOrEqualToStatus(status))
- {
- return false;
- }
- foreach (int key in this.requestVipFlags)
- {
- ReadOnlyDictionary<int, NightWorkState> night_works_state_dic = GameMain.Instance.CharacterMgr.status.night_works_state_dic;
- if (!night_works_state_dic.ContainsKey(key) || !night_works_state_dic[key].finish)
- {
- return false;
- }
- }
- return true;
- }
- public virtual List<KeyValuePair<string[], bool>> CreateConditionTextAndStaturResults(Status status)
- {
- List<KeyValuePair<string[], bool>> list = new List<KeyValuePair<string[], bool>>();
- if (0 < this.requestSeikeikens.Count)
- {
- string text = "MaidStatus/条件文/性経験 : ";
- List<string> list2 = new List<string>();
- int num = 0;
- bool flag = false;
- foreach (Seikeiken seikeiken in this.requestSeikeikens)
- {
- if (flag)
- {
- text += ",";
- }
- list2.Add(EnumConvert.GetTerm(seikeiken));
- string text2 = text;
- text = string.Concat(new object[]
- {
- text2,
- "{",
- num,
- "}"
- });
- flag = true;
- num++;
- }
- List<string> list3 = new List<string>();
- list3.Add(text);
- list3.AddRange(list2);
- list.Add(new KeyValuePair<string[], bool>(list3.ToArray(), this.requestSeikeikens.Contains(status.seikeiken)));
- }
- if (0 < this.requestContracts.Count)
- {
- string text3 = "MaidStatus/条件文/契約タイプ : ";
- List<string> list4 = new List<string>();
- int num2 = 0;
- bool flag2 = false;
- foreach (Contract contract in this.requestContracts)
- {
- if (flag2)
- {
- text3 += ",";
- }
- list4.Add(EnumConvert.GetTerm(contract));
- string text2 = text3;
- text3 = string.Concat(new object[]
- {
- text2,
- "{",
- num2,
- "}"
- });
- flag2 = true;
- num2++;
- }
- List<string> list5 = new List<string>();
- list5.Add(text3);
- list5.AddRange(list4);
- list.Add(new KeyValuePair<string[], bool>(list5.ToArray(), this.requestContracts.Contains(status.contract)));
- }
- if (0 < this.requestVipFlags.Count)
- {
- string empty = string.Empty;
- foreach (int key in this.requestVipFlags)
- {
- List<string> list6 = new List<string>();
- if (!ScheduleCSVData.AllData.ContainsKey(key) || ScheduleCSVData.AllData[key].type != ScheduleTaskCtrl.TaskType.Yotogi)
- {
- list6.Add("不明なVIP[{0}]を実行している");
- list6.Add(key.ToString());
- }
- else
- {
- ScheduleCSVData.ScheduleBase scheduleBase = ScheduleCSVData.AllData[key];
- ScheduleCSVData.Yotogi yotogi = (ScheduleCSVData.Yotogi)scheduleBase;
- list6.Add("「{0}」を実行している");
- list6.Add(yotogi.name);
- }
- if (!string.IsNullOrEmpty(empty))
- {
- ReadOnlyDictionary<int, NightWorkState> night_works_state_dic = GameMain.Instance.CharacterMgr.status.night_works_state_dic;
- bool value = night_works_state_dic.ContainsKey(key) && night_works_state_dic[key].finish;
- list.Add(new KeyValuePair<string[], bool>(list6.ToArray(), value));
- }
- }
- }
- List<KeyValuePair<string[], bool>> list7 = this.requestParameters.CreateConditionTextAndStaturResults(status);
- foreach (KeyValuePair<string[], bool> item in list7)
- {
- list.Add(item);
- }
- return list;
- }
- public readonly ParametersPack requestParameters;
- public readonly List<int> requestVipFlags;
- public readonly HashSet<int> requestPersonals;
- public readonly HashSet<Seikeiken> requestSeikeikens;
- public readonly HashSet<Contract> requestContracts;
- public readonly HashSet<int> requestBillIds;
- }
- }
- }
|