\r
namespace KancolleSniffer\r
{\r
- internal class MissingData\r
+ public static class DataLoader\r
{\r
private static readonly string EnemySlotFile =\r
Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "EnemySlot.csv");\r
\r
private static Dictionary<int, int[]> _maxEq;\r
\r
- public static Dictionary<int, int[]> MaxEq\r
+ public static void LoadEnemySlot()\r
{\r
- get\r
+ try\r
+ {\r
+ _maxEq = File.ReadLines(EnemySlotFile)\r
+ .Select(line => line.Split(',').Select(s => int.TryParse(s, out var num) ? num : 0))\r
+ .ToDictionary(nums => nums.First(), nums => nums.Skip(1).ToArray());\r
+ }\r
+ catch (IOException)\r
{\r
- if (_maxEq != null)\r
- return _maxEq;\r
- _maxEq = new Dictionary<int, int[]>();\r
- try\r
- {\r
- foreach (var line in File.ReadLines(EnemySlotFile))\r
- {\r
- int num;\r
- var entry = line.Split(',').Select(e => int.TryParse(e, out num) ? num : 0).ToArray();\r
- _maxEq[entry[0]] = entry.Skip(1).ToArray();\r
- }\r
- }\r
- catch (FileNotFoundException)\r
- {\r
- }\r
- return _maxEq;\r
}\r
}\r
+\r
+ public static int[] EnemySlot(int id) =>\r
+ _maxEq != null ? _maxEq.TryGetValue(id, out var slot) ? slot : null : null;\r
}\r
}
\ No newline at end of file
<Compile Include="LogServer.cs" />\r
<Compile Include="MaterialInfo.cs" />\r
<Compile Include="MiscTextInfo.cs" />\r
- <Compile Include="MissingData.cs" />\r
+ <Compile Include="DataLoader.cs" />\r
<Compile Include="NotificationConfigDialog.cs">\r
<SubType>Form</SubType>\r
</Compile>\r
foreach (var entry in json.api_mst_stype)\r
dict[entry.api_id] = entry.api_name;\r
dict[8] = "巡洋戦艦";\r
+ DataLoader.LoadEnemySlot();\r
foreach (var entry in json.api_mst_ship)\r
{\r
var shipSpec = _shipSpecs[(int)entry.api_id] = new ShipSpec\r
}\r
shipSpec.MaxEq = entry.api_maxeq()\r
? entry.api_maxeq\r
- : MissingData.MaxEq.TryGetValue(shipSpec.Id, out var maxEq)\r
- ? maxEq\r
- : null;\r
+ : DataLoader.EnemySlot(shipSpec.Id);\r
}\r
_shipSpecs[-1] = new ShipSpec();\r
SetRemodelBaseAndStep();\r