using System; using System.Collections.Generic; using System.IO; using wf; namespace MaidStatus { public static class Personal { public static int Count { get { Personal.CreateData(); return Personal.commonIdManager.idMap.Count; } } public static bool Contains(string name) { return Personal.commonIdManager.nameMap.ContainsKey(name); } public static bool Contains(int id) { return Personal.commonIdManager.idMap.ContainsKey(id); } public static int uniqueNameToId(string name) { Personal.CreateData(); NDebug.Assert(Personal.commonIdManager.nameMap.ContainsKey(name), "性格\nユニーク名[" + name + "]をIDに変換できませんでした"); return Personal.commonIdManager.nameMap[name]; } public static string IdToUniqueName(int id) { Personal.CreateData(); NDebug.Assert(Personal.commonIdManager.idMap.ContainsKey(id), "性格\nID[" + id + "]をユニーク名に変換できませんでした"); return Personal.commonIdManager.idMap[id].Key; } public static Personal.Data GetData(int id) { Personal.CreateData(); NDebug.Assert(Personal.basicDatas.ContainsKey(id), "性格\nID[" + id + "]のデータは存在しません"); return Personal.basicDatas[id]; } public static Personal.Data GetData(string uniqueName) { return Personal.GetData(Personal.uniqueNameToId(uniqueName)); } public static bool IsEnabled(string uniqueName) { Personal.CreateData(); return Personal.commonIdManager.enabledIdList.Contains(Personal.uniqueNameToId(uniqueName)); } public static bool IsEnabled(int id) { Personal.CreateData(); return Personal.commonIdManager.enabledIdList.Contains(id); } public static List GetAllDatas(bool onlyEnabled) { Personal.CreateData(); List list = new List(); foreach (KeyValuePair> keyValuePair in Personal.commonIdManager.idMap) { if (!onlyEnabled || Personal.commonIdManager.enabledIdList.Contains(keyValuePair.Key)) { list.Add(Personal.basicDatas[keyValuePair.Key]); } } return list; } public static void CreateData() { if (Personal.commonIdManager != null) { return; } Personal.commonIdManager = new CsvCommonIdManager("maid_status_personal", "性格", CsvCommonIdManager.Type.IdAndUniqueName, null); Personal.basicDatas = new Dictionary(); using (AFileBase afileBase = GameUty.FileSystem.FileOpen("maid_status_personal_request_plugin.nei")) { using (CsvParser csvParser = new CsvParser()) { csvParser.Open(afileBase); NDebug.Assert(csvParser.IsValid(), "maid_status_personal_request_plugin\nopen failed."); for (int i = 1; i < csvParser.max_cell_y; i++) { int cellAsInteger = csvParser.GetCellAsInteger(0, i); string cellAsString = csvParser.GetCellAsString(3, i); if (!string.IsNullOrEmpty(cellAsString)) { if (Personal.commonIdManager.enabledIdList.Contains(cellAsInteger) && !PluginData.IsEnabled(cellAsString)) { Personal.commonIdManager.enabledIdList.Remove(cellAsInteger); } } } } } string[] array = new string[] { "list", "feature_condition" }; KeyValuePair[] array2 = new KeyValuePair[array.Length]; for (int j = 0; j < array2.Length; j++) { string text = "maid_status_personal_" + array[j] + ".nei"; AFileBase afileBase2 = GameUty.FileSystem.FileOpen(text); CsvParser csvParser2 = new CsvParser(); bool condition = csvParser2.Open(afileBase2); NDebug.Assert(condition, text + "\nopen failed."); array2[j] = new KeyValuePair(afileBase2, csvParser2); } foreach (KeyValuePair> keyValuePair in Personal.commonIdManager.idMap) { Personal.basicDatas.Add(keyValuePair.Key, new Personal.Data(keyValuePair.Key, array2[0].Value, array2[1].Value)); } foreach (KeyValuePair keyValuePair2 in array2) { keyValuePair2.Value.Dispose(); keyValuePair2.Key.Dispose(); } } private const string csvTopCommonName = "maid_status_personal"; private const string typeNameForErrorLog = "性格"; private static CsvCommonIdManager commonIdManager; private static Dictionary basicDatas; public class Data { public Data(int id, CsvParser basicCsv, CsvParser featureConditionsCsv) { List list = new List(); for (int i = 0; i < basicCsv.max_cell_y; i++) { if (basicCsv.IsCellToExistData(0, i) && basicCsv.GetCellAsInteger(0, i) == id) { this.id = id; int num = 1; this.uniqueName = basicCsv.GetCellAsString(num++, i); this.drawName = basicCsv.GetCellAsString(num++, i); this.replaceText = basicCsv.GetCellAsString(num++, i); this.bgmFileName = Path.ChangeExtension(basicCsv.GetCellAsString(num++, i), ".ogg"); string cellAsString = basicCsv.GetCellAsString(num++, i); this.oldPersonal = (cellAsString == "〇"); string[] array = basicCsv.GetCellAsString(num++, i).Split(new char[] { '/' }); this.competitiveMotionFileVictory = new KeyValuePair(Path.ChangeExtension(array[0], ".ks"), array[1]); array = basicCsv.GetCellAsString(num++, i).Split(new char[] { '/' }); this.competitiveMotionFileDefeat = new KeyValuePair(Path.ChangeExtension(array[0], ".ks"), array[1]); break; } } this.acquisitionFeatureList = new List(); for (int j = 0; j < featureConditionsCsv.max_cell_y; j++) { if (featureConditionsCsv.IsCellToExistData(0, j) && featureConditionsCsv.GetCellAsString(0, j) == this.uniqueName) { int num2 = 0; while (featureConditionsCsv.IsCellToExistData(1, j + num2)) { this.acquisitionFeatureList.Add(new Personal.Data.LearnFeature(featureConditionsCsv, j + num2)); num2++; } break; } } } public readonly int id; public readonly string uniqueName; public readonly string drawName; public readonly string replaceText; public readonly string bgmFileName; public readonly bool oldPersonal; public readonly KeyValuePair competitiveMotionFileVictory; public readonly KeyValuePair competitiveMotionFileDefeat; public readonly List acquisitionFeatureList; public class LearnFeature { public LearnFeature(CsvParser featureConditionsCsv, int lineY) { this.requestParameters = new ParametersPack(); int cell_x = 1; string cellAsString = featureConditionsCsv.GetCellAsString(cell_x++, lineY); this.feature = Feature.GetData(cellAsString); this.requestSeikeikens = true; string cellAsString2 = featureConditionsCsv.GetCellAsString(cell_x++, lineY); if (cellAsString2 == "両穴") { this.needSeikeiken = Seikeiken.Yes_Yes; } else if (cellAsString2 == "前穴") { this.needSeikeiken = Seikeiken.Yes_No; } else if (cellAsString2 == "後穴") { this.needSeikeiken = Seikeiken.No_Yes; } else { this.requestSeikeikens = false; } while (featureConditionsCsv.IsCellToExistData(cell_x, lineY)) { string cellAsString3 = featureConditionsCsv.GetCellAsString(cell_x++, lineY); int cellAsInteger = featureConditionsCsv.GetCellAsInteger(cell_x++, lineY); this.requestParameters.Add(ParametersPack.NameToStatusType(cellAsString3), cellAsInteger); } } public bool isLearnPossible(Status status) { return (!this.requestSeikeikens || this.needSeikeiken == status.seikeiken) && this.requestParameters.GreaterThanOrEqualToStatus(status); } public readonly Feature.Data feature; public readonly bool requestSeikeikens; public readonly Seikeiken needSeikeiken; public readonly ParametersPack requestParameters; } } } }