OSDN Git Service

基地航空隊の配備のコストを資材の変動に反映する
[kancollesniffer/KancolleSniffer.git] / KancolleSniffer / EquipPanel.cs
index 96de315..fb1ae64 100644 (file)
@@ -1,24 +1,20 @@
-// Copyright (C) 2015 Kazuhiro Fujieda <fujieda@users.sourceforge.jp>\r
+// Copyright (C) 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;\r
 using System.Collections.Generic;\r
 using System.Drawing;\r
-using System.Linq;\r
 using System.Windows.Forms;\r
 \r
 namespace KancolleSniffer\r
@@ -30,18 +26,23 @@ namespace KancolleSniffer
         private EquipColumn[] _equipList;\r
         private readonly List<ShipLabel[]> _labelList = new List<ShipLabel[]>();\r
         private readonly List<Panel> _panelList = new List<Panel>();\r
+        private readonly ToolTip _toolTip = new ToolTip {ShowAlways = true};\r
 \r
         private class EquipColumn\r
         {\r
             public string Fleet { get; set; }\r
+            public string Fleet2 { get; set; }\r
             public string Ship { get; set; }\r
             public int Id { get; set; }\r
             public string Equip { get; set; }\r
             public Color Color { get; set; }\r
+            public string Spec { get; set; }\r
+            public string Spec2 { get; set; }\r
+            public string AircraftSpec { get; set; }\r
 \r
             public EquipColumn()\r
             {\r
-                Fleet = Ship = Equip = "";\r
+                Fleet = Ship = Equip = AircraftSpec = "";\r
                 Color = DefaultBackColor;\r
             }\r
         }\r
@@ -58,30 +59,90 @@ namespace KancolleSniffer
         private void CreateEquipList(Sniffer sniffer)\r
         {\r
             var list = new List<EquipColumn>();\r
-            var fleet = new[] { "第一艦隊", "第二艦隊", "第三艦隊", "第四艦隊" };\r
-            for (var i = 0; i < fleet.Length; i++)\r
+            var fn = new[] {"第一艦隊", "第二艦隊", "第三艦隊", "第四艦隊"};\r
+            var tp = 0.0;\r
+            for (var f = 0; f < fn.Length; f++)\r
             {\r
-                list.Add(new EquipColumn { Fleet = fleet[i] });\r
-                foreach (var s in sniffer.GetShipStatuses(i))\r
+                var drumTotal = 0;\r
+                var drumShips = 0;\r
+                var levelTotal = 0;\r
+                var ships = new List<EquipColumn>();\r
+                foreach (var s in sniffer.GetShipStatuses(f))\r
                 {\r
-                    list.Add(new EquipColumn { Ship = s.Name, Id = s.Id });\r
-                    list.AddRange(\r
-                        (from e in Enumerable.Range(0, s.Slot.Length)\r
-                         let slot = s.Slot[e]\r
-                         let onslot = s.OnSlot[e]\r
-                         let max = s.Spec.MaxEq[e]\r
-                         where slot != -1\r
-                         let item = sniffer.Item.ItemDict[slot]\r
-                         select\r
-                             new EquipColumn\r
-                             {\r
-                                 Equip = item.Spec.Name + (item.Level == 0 ? "" : "★" + item.Level) +\r
-                                         (!item.Spec.IsAircraft ? "" : " " + onslot + "/" + max),\r
-                                 Color = item.Spec.Color\r
-                             })\r
-                            .DefaultIfEmpty(new EquipColumn { Equip = "なし" }));\r
+                    var drum = 0;\r
+                    var equips = new List<EquipColumn>();\r
+                    for (var i = 0; i < s.Slot.Length; i++)\r
+                    {\r
+                        var item = s.Slot[i];\r
+                        var onslot = s.OnSlot[i];\r
+                        var max = s.Spec.MaxEq[i];\r
+                        if (item.Id == -1)\r
+                            continue;\r
+                        if (item.Spec.Name == "ドラム缶(輸送用)")\r
+                            drum++;\r
+                        var airspec = "";\r
+                        if (item.Spec.CanAirCombat)\r
+                        {\r
+                            if (item.Spec.Type == 7 || item.Spec.Type == 11) // 爆撃\r
+                            {\r
+                                airspec = "航空戦 " + (25 + (int)(item.Spec.Bomber * Math.Sqrt(onslot)));\r
+                            }\r
+                            else if (item.Spec.Type == 8)\r
+                            {\r
+                                var normal = 25 + item.Spec.Torpedo * Math.Sqrt(onslot);\r
+                                airspec = "航空戦 " + (int)(normal * 0.8) + "/" + (int)(normal * 1.5);\r
+                            }\r
+                        }\r
+                        equips.Add(new EquipColumn\r
+                        {\r
+                            Equip = item.Spec.Name +\r
+                                    (item.Alv == 0 ? "" : "+" + item.Alv) +\r
+                                    (item.Level == 0 ? "" : "★" + item.Level) +\r
+                                    (!item.Spec.IsAircraft ? "" : " " + onslot + "/" + max),\r
+                            AircraftSpec = airspec,\r
+                            Color = item.Spec.Color\r
+                        });\r
+                    }\r
+                    if (s.SlotEx.Id > 0)\r
+                    {\r
+                        var item = s.SlotEx;\r
+                        equips.Add(new EquipColumn {Equip = item.Spec.Name, Color = item.Spec.Color});\r
+                    }\r
+                    if (drum != 0)\r
+                        drumShips++;\r
+                    drumTotal += drum;\r
+                    levelTotal += s.Level;\r
+                    if (f < 2)\r
+                        tp += s.TransportPoint;\r
+                    var fire = s.RealFirepower;\r
+                    var subm = s.RealAntiSubmarine;\r
+                    var torp = s.RealTorpedo;\r
+                    var night = s.NightBattlePower;\r
+                    var ship = new EquipColumn\r
+                    {\r
+                        Ship = (s.Escaped ? "[避]" : "") + s.Name + " Lv" + s.Level,\r
+                        Id = s.Id,\r
+                        // ReSharper disable CompareOfFloatsByEqualityOperator\r
+                        Spec = (fire == 0 ? "" : $"砲{fire:f1}") + (subm == 0 ? "" : $" 潜{subm:f1}"),\r
+                        Spec2 = (torp == 0 ? "" : $"雷{torp:f1}") + (night == 0 ? "" : $" 夜{night:f1}")\r
+                        // ReSharper restore CompareOfFloatsByEqualityOperator\r
+                    };\r
+                    if (ship.Spec == "")\r
+                    {\r
+                        ship.Spec = ship.Spec2;\r
+                        ship.Spec2 = "";\r
+                    }\r
+                    ships.Add(ship);\r
+                    ships.AddRange(equips);\r
                 }\r
+                list.Add(new EquipColumn\r
+                {\r
+                    Fleet = fn[f] + (levelTotal == 0 ? "" : " 合計Lv" + levelTotal) +\r
+                            (drumTotal == 0 ? "" : " ドラム缶" + drumTotal + "(" + drumShips + "隻)")\r
+                });\r
+                list.AddRange(ships);\r
             }\r
+            list[0].Fleet2 = $"TP: S{(int)tp} A{(int)(tp * 0.7)}";\r
             _equipList = list.ToArray();\r
         }\r
 \r
@@ -108,7 +169,8 @@ namespace KancolleSniffer
                 new ShipLabel {Location = new Point(1, 2), AutoSize = true},\r
                 new ShipLabel {Location = new Point(10, 2), AutoSize = true},\r
                 new ShipLabel {Location = new Point(40, 2), AutoSize = true},\r
-                new ShipLabel {Location = new Point(37, 2), Size = new Size(4, LabelHeight - 2)}\r
+                new ShipLabel {Location = new Point(37, 2), Size = new Size(4, LabelHeight - 2)},\r
+                new ShipLabel {Location = new Point(217, 2), AutoSize = true, AnchorRight = true}\r
             };\r
             _labelList.Add(labels);\r
             _panelList.Add(lbp);\r
@@ -143,6 +205,11 @@ namespace KancolleSniffer
             labels[2].Text = e.Equip;\r
             labels[3].Visible = e.Equip != "";\r
             labels[3].BackColor = e.Color;\r
+            labels[4].Text = e.Spec;\r
+            if (e.Fleet != "" && e.Fleet2 != "")\r
+                _toolTip.SetToolTip(labels[0], e.Fleet2);\r
+            _toolTip.SetToolTip(labels[2], e.AircraftSpec != "" ? e.AircraftSpec : "");\r
+            _toolTip.SetToolTip(labels[4], e.Spec2 != "" ? e.Spec2 : "");\r
             lbp.Visible = true;\r
         }\r
 \r