OSDN Git Service

DPIスケーリング時に連合艦隊表示がずれるのを直す
[kancollesniffer/KancolleSniffer.git] / KancolleSniffer / ShipMaster.cs
index d1aef75..8debfab 100644 (file)
@@ -1,19 +1,16 @@
-// Copyright (C) 2014 Kazuhiro Fujieda <fujieda@users.sourceforge.jp>\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
@@ -26,44 +23,65 @@ namespace KancolleSniffer
 \r
         public void Inspect(dynamic json)\r
         {\r
-            foreach (var entry in json)\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
+            foreach (var entry in json.api_mst_ship)\r
             {\r
-                _shipSpecs[(int)entry.api_id] = new ShipSpec\r
+                var shipSpec = _shipSpecs[(int)entry.api_id] = new ShipSpec\r
                 {\r
                     Id = (int)entry.api_id,\r
-                    Name = entry.api_name,\r
-                    FuelMax = (int)entry.api_fuel_max,\r
-                    BullMax = (int)entry.api_bull_max,\r
-                    MaxEq = (int[])entry.api_maxeq,\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
                     ShipType = (int)entry.api_stype,\r
+                    ShipTypeName = dict[entry.api_stype]\r
                 };\r
+                int[] maxEq;\r
+                shipSpec.MaxEq = entry.api_maxeq()\r
+                    ? entry.api_maxeq\r
+                    : MissingData.MaxEq.TryGetValue(shipSpec.Id, out maxEq) ? maxEq : null;\r
             }\r
-            _shipSpecs[-1] = new ShipSpec {Name = "不明", MaxEq = new int[NumSlots]};\r
+            _shipSpecs[-1] = new ShipSpec();\r
         }\r
 \r
-        public ShipSpec this[int id]\r
+        // 深海棲艦の名前にelite/flagshipを付ける\r
+        private string ShipName(dynamic json)\r
         {\r
-            get { return _shipSpecs[id]; }\r
+            var name = json.api_name;\r
+            var flagship = json.api_yomi;\r
+            if ((int)json.api_id <= 500 || flagship == "-" || flagship == "")\r
+                return name;\r
+            return name + "(" + flagship + ")";\r
         }\r
+\r
+        public ShipSpec this[int id] => _shipSpecs[id];\r
     }\r
 \r
-    public struct ShipSpec\r
+    public class ShipSpec\r
     {\r
         public int Id { get; set; }\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[] MaxEq { get; set; }\r
         public int ShipType { get; set; }\r
+        public string ShipTypeName { get; set; }\r
 \r
-        public bool IsSubmarine\r
+        public ShipSpec()\r
         {\r
-            get { return ShipType == 13 || ShipType == 14; }\r
+            Id = -1;\r
+            Name = "";\r
+            MaxEq = new int[0];\r
         }\r
 \r
         public double RepairWeight\r
         {\r
-            get {\r
+            get\r
+            {\r
                 switch (ShipType)\r
                 {\r
                     case 13: // 潜水艦\r
@@ -74,6 +92,7 @@ namespace KancolleSniffer
                     case 14: // 潜水空母\r
                     case 16: // 水上機母艦\r
                     case 17: // 揚陸艦\r
+                    case 21: // 練習巡洋艦\r
                         return 1.0;\r
                     case 5: // 重巡洋艦\r
                     case 6: // 航空巡洋艦\r
@@ -91,5 +110,63 @@ namespace KancolleSniffer
                 return 1.0;\r
             }\r
         }\r
+\r
+        public double TransportPoint\r
+        {\r
+            get\r
+            {\r
+                switch (ShipType)\r
+                {\r
+                    case 2:\r
+                        return 5.0;\r
+                    case 3:\r
+                        return 2.0;\r
+                    case 6:\r
+                        return 4.0;\r
+                    case 10:\r
+                        return 7.0;\r
+                    case 15:\r
+                        return 15.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
+                    default:\r
+                        return 0;\r
+                }\r
+            }\r
+        }\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
+            get\r
+            {\r
+                switch (ShipType)\r
+                {\r
+                    case 2: // 駆逐\r
+                    case 3: // 軽巡\r
+                    case 4: // 雷巡\r
+                    case 6: // 航巡\r
+                    case 7: // 軽空\r
+                    case 10: // 航戦\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