1 // Copyright (C) 2014, 2015 Kazuhiro Fujieda <fujieda@users.osdn.me>
\r
3 // This program is part of KancolleSniffer.
\r
5 // KancolleSniffer is free software: you can redistribute it and/or modify
\r
6 // it under the terms of the GNU General Public License as published by
\r
7 // the Free Software Foundation, either version 3 of the License, or
\r
8 // (at your option) any later version.
\r
10 // This program is distributed in the hope that it will be useful,
\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 // GNU General Public License for more details.
\r
15 // You should have received a copy of the GNU General Public License
\r
16 // along with this program; if not, see <http://www.gnu.org/licenses/>.
\r
18 using System.Collections.Generic;
\r
20 namespace KancolleSniffer
\r
22 public class ShipMaster
\r
24 public const int NumSlots = 5;
\r
25 private readonly Dictionary<int, ShipSpec> _shipSpecs = new Dictionary<int, ShipSpec>();
\r
27 public void Inspect(dynamic json)
\r
29 var dict = new Dictionary<double, string>();
\r
30 foreach (var entry in json.api_mst_stype)
\r
31 dict[entry.api_id] = entry.api_name;
\r
33 foreach (var entry in json.api_mst_ship)
\r
35 var shipSpec = _shipSpecs[(int)entry.api_id] = new ShipSpec
\r
37 Id = (int)entry.api_id,
\r
38 Name = ShipName(entry),
\r
39 FuelMax = entry.api_fuel_max() ? (int)entry.api_fuel_max : 0,
\r
40 BullMax = entry.api_bull_max() ? (int)entry.api_bull_max : 0,
\r
41 ShipType = (int)entry.api_stype,
\r
42 ShipTypeName = dict[entry.api_stype]
\r
45 shipSpec.MaxEq = entry.api_maxeq()
\r
47 : MissingData.MaxEq.TryGetValue(shipSpec.Id, out maxEq) ? maxEq : null;
\r
49 _shipSpecs[-1] = new ShipSpec();
\r
52 // 深海棲艦の名前にelite/flagshipを付ける
\r
53 private string ShipName(dynamic json)
\r
55 var name = json.api_name;
\r
56 var flagship = json.api_yomi;
\r
57 if ((int)json.api_id <= 500 || flagship == "-" || flagship == "")
\r
59 return name + "(" + flagship + ")";
\r
62 public ShipSpec this[int id] => _shipSpecs[id];
\r
65 public class ShipSpec
\r
67 public int Id { get; set; }
\r
68 public string Name { get; set; }
\r
69 public int FuelMax { get; set; }
\r
70 public int BullMax { get; set; }
\r
71 public int[] MaxEq { get; set; }
\r
72 public int ShipType { get; set; }
\r
73 public string ShipTypeName { get; set; }
\r
82 public double RepairWeight
\r
115 public bool IsSubmarine => ShipType == 13 || ShipType == 14;
\r
117 public bool IsAircraftCarrier => ShipType == 7 || ShipType == 11 || ShipType == 18;
\r
119 public bool IsAntiSubmarine
\r