OSDN Git Service

装備一覧に基地航空隊への配置状況を表示する
authorKazuhiro Fujieda <fujieda@users.osdn.me>
Sun, 14 Aug 2016 11:13:57 +0000 (20:13 +0900)
committerKazuhiro Fujieda <fujieda@users.osdn.me>
Tue, 16 Aug 2016 15:58:01 +0000 (00:58 +0900)
KancolleSniffer/BaseAirCoprs.cs
KancolleSniffer/ItemTreeView.cs
KancolleSniffer/ShipInfo.cs
KancolleSniffer/Sniffer.cs

index 43d1868..9965683 100644 (file)
@@ -12,6 +12,7 @@
 // See the License for the specific language governing permissions and\r
 // limitations under the License.\r
 \r
+using System.Collections.Generic;\r
 using System.Linq;\r
 using static System.Math;\r
 \r
@@ -20,6 +21,7 @@ namespace KancolleSniffer
     public class BaseAirCoprs\r
     {\r
         private readonly ItemInfo _itemInfo;\r
+        private List<int> _relocationgPlanes;\r
 \r
         public BaseAirCoprs(ItemInfo item)\r
         {\r
@@ -124,7 +126,11 @@ namespace KancolleSniffer
             var planeInfo = json.api_plane_info[0];\r
             var airCorps = AirCorps[int.Parse(values["api_base_id"]) - 1];\r
             airCorps.Distance = (int)json.api_distance;\r
-            airCorps.Planes[(int)planeInfo.api_squadron_id - 1] = new PlaneInfo\r
+            var planeId = (int)planeInfo.api_squadron_id - 1;\r
+            var prev = airCorps.Planes[planeId];\r
+            if (prev.Slot.Id != -1)\r
+                _relocationgPlanes.Add(prev.Slot.Id);\r
+            airCorps.Planes[planeId] = new PlaneInfo\r
             {\r
                 Slot = _itemInfo.GetStatus((int)planeInfo.api_slotid),\r
                 State = (int)planeInfo.api_state,\r
@@ -145,5 +151,35 @@ namespace KancolleSniffer
                 AirCorps[int.Parse(entry.baseId) - 1].Action = int.Parse(entry.action);\r
             }\r
         }\r
+\r
+        public void InspectEventObject(dynamic json)\r
+        {\r
+            _relocationgPlanes = json.api_base_convert_slot()\r
+                ? new List<int>((int[])json.api_base_convert_slot)\r
+                : new List<int>();\r
+        }\r
+\r
+        public void SetItemHolder()\r
+        {\r
+            if (AirCorps == null)\r
+                return;\r
+            var name = new[] {"第一", "第二", "第三"};\r
+            var i = 0;\r
+            foreach (var airCorps in AirCorps)\r
+            {\r
+                if (i >= name.Length)\r
+                    break;\r
+                var ship = new ShipStatus {Id = 1000 + i, Spec = new ShipSpec {Name = name[i++] + "基地航空隊"}};\r
+                foreach (var plane in airCorps.Planes)\r
+                {\r
+                    if (plane.State != 1)\r
+                        continue;\r
+                    _itemInfo.GetStatus(plane.Slot.Id).Holder = ship;\r
+                }\r
+            }\r
+            var relocating = new ShipStatus {Id = 1500, Spec = new ShipSpec {Name = "配置転換中"}};\r
+            foreach (var id in _relocationgPlanes)\r
+                _itemInfo.GetStatus(id).Holder = relocating;\r
+        }\r
     }\r
 }
\ No newline at end of file
index 975b9be..db3b608 100644 (file)
@@ -69,7 +69,7 @@ namespace KancolleSniffer
                         var name = byShip.Key == -1\r
                             ? "未装備x" + byShip.Count()\r
                             : (ship.Fleet != -1 ? ship.Fleet + 1 + " " : "") +\r
-                              ship.Name + "Lv" + ship.Level + "×" + byShip.Count();\r
+                              ship.Name + (ship.Level > 0 ? "Lv" + ship.Level : "") + "×" + byShip.Count();\r
                         itemNode.Nodes.Add(name, name);\r
                     }\r
                 }\r
@@ -90,7 +90,8 @@ namespace KancolleSniffer
         private class ItemStatusComparer : IEqualityComparer<ItemStatus>\r
         {\r
             public bool Equals(ItemStatus x, ItemStatus y)\r
-                => x.Level == y.Level && x.Spec == y.Spec && x.Holder.Id == y.Holder.Id && x.Holder.Fleet == y.Holder.Fleet;\r
+                => x.Level == y.Level && x.Spec == y.Spec && x.Holder.Id == y.Holder.Id &&\r
+                   x.Holder.Fleet == y.Holder.Fleet;\r
 \r
             public int GetHashCode(ItemStatus obj) => obj.Level + obj.Spec.GetHashCode() + obj.Holder.GetHashCode();\r
         }\r
index 6739618..e664fc2 100644 (file)
@@ -52,6 +52,7 @@ namespace KancolleSniffer
         public ShipStatus()\r
         {\r
             Id = -1;\r
+            Fleet = -1;\r
             Spec = new ShipSpec();\r
             OnSlot = new int[0];\r
             Slot = new ItemStatus[0];\r
index 1187013..4176f44 100644 (file)
@@ -136,6 +136,8 @@ namespace KancolleSniffer
             _achievement.InspectBasic(data.api_basic);\r
             if (data.api_parallel_quest_count()) // 昔のログにはないので\r
                 _questInfo.QuestCount = (int)data.api_parallel_quest_count;\r
+            if (data.api_event_object())\r
+                _baseAirCoprs.InspectEventObject(data.api_event_object);\r
             _battleInfo.CleanupResult();\r
             _battleInfo.InBattle = false;\r
             _shipInfo.ClearEscapedShips();\r
@@ -521,6 +523,7 @@ namespace KancolleSniffer
             {\r
                 _itemInfo.ClearHolder();\r
                 _shipInfo.SetItemHolder();\r
+                _baseAirCoprs.SetItemHolder();\r
                 return _itemInfo.ItemList;\r
             }\r
         }\r