From de936cb3f3ef76407d2c5e5de39a685a340e912d Mon Sep 17 00:00:00 2001 From: Kazuhiro Fujieda Date: Sun, 14 Aug 2016 20:13:57 +0900 Subject: [PATCH] =?utf8?q?=E8=A3=85=E5=82=99=E4=B8=80=E8=A6=A7=E3=81=AB?= =?utf8?q?=E5=9F=BA=E5=9C=B0=E8=88=AA=E7=A9=BA=E9=9A=8A=E3=81=B8=E3=81=AE?= =?utf8?q?=E9=85=8D=E7=BD=AE=E7=8A=B6=E6=B3=81=E3=82=92=E8=A1=A8=E7=A4=BA?= =?utf8?q?=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- KancolleSniffer/BaseAirCoprs.cs | 38 +++++++++++++++++++++++++++++++++++++- KancolleSniffer/ItemTreeView.cs | 5 +++-- KancolleSniffer/ShipInfo.cs | 1 + KancolleSniffer/Sniffer.cs | 3 +++ 4 files changed, 44 insertions(+), 3 deletions(-) diff --git a/KancolleSniffer/BaseAirCoprs.cs b/KancolleSniffer/BaseAirCoprs.cs index 43d1868..9965683 100644 --- a/KancolleSniffer/BaseAirCoprs.cs +++ b/KancolleSniffer/BaseAirCoprs.cs @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +using System.Collections.Generic; using System.Linq; using static System.Math; @@ -20,6 +21,7 @@ namespace KancolleSniffer public class BaseAirCoprs { private readonly ItemInfo _itemInfo; + private List _relocationgPlanes; public BaseAirCoprs(ItemInfo item) { @@ -124,7 +126,11 @@ namespace KancolleSniffer var planeInfo = json.api_plane_info[0]; var airCorps = AirCorps[int.Parse(values["api_base_id"]) - 1]; airCorps.Distance = (int)json.api_distance; - airCorps.Planes[(int)planeInfo.api_squadron_id - 1] = new PlaneInfo + var planeId = (int)planeInfo.api_squadron_id - 1; + var prev = airCorps.Planes[planeId]; + if (prev.Slot.Id != -1) + _relocationgPlanes.Add(prev.Slot.Id); + airCorps.Planes[planeId] = new PlaneInfo { Slot = _itemInfo.GetStatus((int)planeInfo.api_slotid), State = (int)planeInfo.api_state, @@ -145,5 +151,35 @@ namespace KancolleSniffer AirCorps[int.Parse(entry.baseId) - 1].Action = int.Parse(entry.action); } } + + public void InspectEventObject(dynamic json) + { + _relocationgPlanes = json.api_base_convert_slot() + ? new List((int[])json.api_base_convert_slot) + : new List(); + } + + public void SetItemHolder() + { + if (AirCorps == null) + return; + var name = new[] {"第一", "第二", "第三"}; + var i = 0; + foreach (var airCorps in AirCorps) + { + if (i >= name.Length) + break; + var ship = new ShipStatus {Id = 1000 + i, Spec = new ShipSpec {Name = name[i++] + "基地航空隊"}}; + foreach (var plane in airCorps.Planes) + { + if (plane.State != 1) + continue; + _itemInfo.GetStatus(plane.Slot.Id).Holder = ship; + } + } + var relocating = new ShipStatus {Id = 1500, Spec = new ShipSpec {Name = "配置転換中"}}; + foreach (var id in _relocationgPlanes) + _itemInfo.GetStatus(id).Holder = relocating; + } } } \ No newline at end of file diff --git a/KancolleSniffer/ItemTreeView.cs b/KancolleSniffer/ItemTreeView.cs index 975b9be..db3b608 100644 --- a/KancolleSniffer/ItemTreeView.cs +++ b/KancolleSniffer/ItemTreeView.cs @@ -69,7 +69,7 @@ namespace KancolleSniffer var name = byShip.Key == -1 ? "未装備x" + byShip.Count() : (ship.Fleet != -1 ? ship.Fleet + 1 + " " : "") + - ship.Name + "Lv" + ship.Level + "×" + byShip.Count(); + ship.Name + (ship.Level > 0 ? "Lv" + ship.Level : "") + "×" + byShip.Count(); itemNode.Nodes.Add(name, name); } } @@ -90,7 +90,8 @@ namespace KancolleSniffer private class ItemStatusComparer : IEqualityComparer { public bool Equals(ItemStatus x, ItemStatus y) - => x.Level == y.Level && x.Spec == y.Spec && x.Holder.Id == y.Holder.Id && x.Holder.Fleet == y.Holder.Fleet; + => x.Level == y.Level && x.Spec == y.Spec && x.Holder.Id == y.Holder.Id && + x.Holder.Fleet == y.Holder.Fleet; public int GetHashCode(ItemStatus obj) => obj.Level + obj.Spec.GetHashCode() + obj.Holder.GetHashCode(); } diff --git a/KancolleSniffer/ShipInfo.cs b/KancolleSniffer/ShipInfo.cs index 6739618..e664fc2 100644 --- a/KancolleSniffer/ShipInfo.cs +++ b/KancolleSniffer/ShipInfo.cs @@ -52,6 +52,7 @@ namespace KancolleSniffer public ShipStatus() { Id = -1; + Fleet = -1; Spec = new ShipSpec(); OnSlot = new int[0]; Slot = new ItemStatus[0]; diff --git a/KancolleSniffer/Sniffer.cs b/KancolleSniffer/Sniffer.cs index 1187013..4176f44 100644 --- a/KancolleSniffer/Sniffer.cs +++ b/KancolleSniffer/Sniffer.cs @@ -136,6 +136,8 @@ namespace KancolleSniffer _achievement.InspectBasic(data.api_basic); if (data.api_parallel_quest_count()) // 昔のログにはないので _questInfo.QuestCount = (int)data.api_parallel_quest_count; + if (data.api_event_object()) + _baseAirCoprs.InspectEventObject(data.api_event_object); _battleInfo.CleanupResult(); _battleInfo.InBattle = false; _shipInfo.ClearEscapedShips(); @@ -521,6 +523,7 @@ namespace KancolleSniffer { _itemInfo.ClearHolder(); _shipInfo.SetItemHolder(); + _baseAirCoprs.SetItemHolder(); return _itemInfo.ItemList; } } -- 2.11.0