-// Copyright (C) 2014 Kazuhiro Fujieda <fujieda@users.osdn.me>\r
+// Copyright (C) 2014, 2015 Kazuhiro Fujieda <fujieda@users.osdn.me>\r
// \r
-// This program is part of KancolleSniffer.\r
+// Licensed under the Apache License, Version 2.0 (the "License");\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
//\r
-// KancolleSniffer is free software: you can redistribute it and/or modify\r
-// it under the terms of the GNU General Public License as published by\r
-// the Free Software Foundation, either version 3 of the License, or\r
-// (at your option) any later version.\r
+// http://www.apache.org/licenses/LICENSE-2.0\r
//\r
-// This program is distributed in the hope that it will be useful,\r
-// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-// GNU General Public License for more details.\r
-//\r
-// You should have received a copy of the GNU General Public License\r
-// along with this program; if not, see <http://www.gnu.org/licenses/>.\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
\r
using System.Collections.Generic;\r
\r
public const int NumSlots = 5;\r
private readonly Dictionary<int, ShipSpec> _shipSpecs = new Dictionary<int, ShipSpec>();\r
\r
+ public static bool IsEnemyId(int id) => id > 1500;\r
+\r
public void Inspect(dynamic json)\r
{\r
var dict = new Dictionary<double, string>();\r
foreach (var entry in json.api_mst_stype)\r
dict[entry.api_id] = entry.api_name;\r
- dict[8] = "高速戦艦" ;\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
Id = (int)entry.api_id,\r
+ SortNo = entry.api_sortno() ? (int)entry.api_sortno : 0,\r
Name = ShipName(entry),\r
FuelMax = entry.api_fuel_max() ? (int)entry.api_fuel_max : 0,\r
BullMax = entry.api_bull_max() ? (int)entry.api_bull_max : 0,\r
+ SlotNum = (int)entry.api_slot_num,\r
ShipType = (int)entry.api_stype,\r
ShipTypeName = dict[entry.api_stype]\r
};\r
- int[] maxEq;\r
+ if (entry.api_afterlv())\r
+ {\r
+ shipSpec.Remodel.Level = (int)entry.api_afterlv;\r
+ shipSpec.Remodel.After = int.Parse(entry.api_aftershipid);\r
+ }\r
shipSpec.MaxEq = entry.api_maxeq()\r
? entry.api_maxeq\r
- : MissingData.MaxEq.TryGetValue(shipSpec.Id, out maxEq) ? maxEq : null;\r
+ : DataLoader.EnemySlot(shipSpec.Id);\r
}\r
_shipSpecs[-1] = new ShipSpec();\r
+ SetRemodelBaseAndStep();\r
}\r
\r
// 深海棲艦の名前にelite/flagshipを付ける\r
{\r
var name = json.api_name;\r
var flagship = json.api_yomi;\r
- if ((int)json.api_id <= 500 || flagship == "-" || flagship == "")\r
+ if (!IsEnemyId((int)json.api_id) || flagship == "-" || flagship == "")\r
return name;\r
return name + "(" + flagship + ")";\r
}\r
\r
- public void InspectStype(dynamic json)\r
- {\r
- }\r
+ public ShipSpec GetSpec(int id) => _shipSpecs.TryGetValue(id, out var spec) ? spec : new ShipSpec();\r
\r
- public ShipSpec this[int id]\r
+ private void SetRemodelBaseAndStep()\r
{\r
- get { return _shipSpecs[id]; }\r
+ // 改造後のデータをマーク\r
+ foreach (var spec in _shipSpecs.Values)\r
+ {\r
+ if (spec.Remodel.After == 0)\r
+ continue;\r
+ _shipSpecs[spec.Remodel.After].Remodel.Base = 1;\r
+ }\r
+ foreach (var spec in _shipSpecs.Values)\r
+ {\r
+ if (spec.Remodel.Base != 0)\r
+ continue;\r
+ var step = 0;\r
+ var hash = new HashSet<int> {spec.Id};\r
+ var s = spec;\r
+ s.Remodel.Base = spec.Id;\r
+ while (s.Remodel.After != 0)\r
+ {\r
+ s.Remodel.Step = ++step;\r
+ if (!hash.Add(s.Remodel.After))\r
+ break;\r
+ s = _shipSpecs[s.Remodel.After];\r
+ s.Remodel.Base = spec.Id;\r
+ }\r
+ }\r
}\r
+\r
+ /// <summary>\r
+ /// テスト用\r
+ /// </summary>\r
+ /// <param name="id"></param>\r
+ public void InjectSpec(int id) => _shipSpecs[id] = new ShipSpec {Id = id};\r
}\r
\r
public class ShipSpec\r
{\r
public int Id { get; set; }\r
+ public bool IsEnemy => ShipMaster.IsEnemyId(Id);\r
+ public int SortNo { get; set; }\r
public string Name { get; set; }\r
public int FuelMax { get; set; }\r
public int BullMax { get; set; }\r
+ public int SlotNum { get; set; }\r
public int[] MaxEq { get; set; }\r
public int ShipType { get; set; }\r
public string ShipTypeName { get; set; }\r
+ public RemodelInfo Remodel { get; } = new RemodelInfo();\r
+\r
+ public class RemodelInfo\r
+ {\r
+ public int Level { get; set; }\r
+ public int After { get; set; }\r
+ public int Base { get; set; } // 艦隊晒しページ用\r
+ public int Step { get; set; } // 同上\r
+ }\r
\r
public ShipSpec()\r
{\r
{\r
switch (ShipType)\r
{\r
+ case 1: // 海防艦\r
case 13: // 潜水艦\r
return 0.5;\r
case 2: // 駆逐艦\r
case 16: // 水上機母艦\r
case 17: // 揚陸艦\r
case 21: // 練習巡洋艦\r
+ case 22: // 補給艦\r
return 1.0;\r
case 5: // 重巡洋艦\r
case 6: // 航空巡洋艦\r
}\r
}\r
\r
- public bool IsSubmarine\r
+ public double TransportPoint\r
{\r
- get { return ShipType == 13 || ShipType == 14; }\r
+ get\r
+ {\r
+ switch (ShipType)\r
+ {\r
+ case 2:\r
+ return 5.0;\r
+ case 3:\r
+ return Id == 487 ? 10.0 : 2.0; // 鬼怒改二は大発分を加算\r
+ case 6:\r
+ return 4.0;\r
+ case 10:\r
+ return 7.0;\r
+ case 16:\r
+ return 9.0;\r
+ case 17:\r
+ return 12.0;\r
+ case 20:\r
+ return 7.0;\r
+ case 21:\r
+ return 6.0;\r
+ case 22:\r
+ return 15.0;\r
+ default:\r
+ return 0;\r
+ }\r
+ }\r
}\r
\r
- public bool IsAircraftCarrier\r
- {\r
- get { return ShipType == 7 || ShipType == 11 || ShipType == 18; }\r
- }\r
+ public bool IsSubmarine => ShipType == 13 || ShipType == 14;\r
+\r
+ public bool IsAircraftCarrier => ShipType == 7 || ShipType == 11 || ShipType == 18;\r
\r
public bool IsAntiSubmarine\r
{\r
{\r
switch (ShipType)\r
{\r
+ case 1: // 海防艦\r
case 2: // 駆逐\r
case 3: // 軽巡\r
case 4: // 雷巡\r
case 16: // 水母\r
case 17: // 揚陸艦\r
case 21: // 練巡\r
+ case 22: // 補給艦\r
return true;\r
}\r
return false;\r
}\r
}\r
+\r
+ public bool IsRepairShip => ShipType == 19;\r
}\r
}
\ No newline at end of file