OSDN Git Service

対空噴進弾幕の発動率を計算する
authorKazuhiro Fujieda <fujieda@users.osdn.me>
Mon, 8 Jul 2019 10:54:09 +0000 (19:54 +0900)
committerKazuhiro Fujieda <fujieda@users.osdn.me>
Mon, 8 Jul 2019 10:54:09 +0000 (19:54 +0900)
KancolleSniffer.Test/ShipStatusTest.cs
KancolleSniffer/Model/ShipStatus.cs

index 58c2e2a..e3ecbc0 100644 (file)
@@ -614,5 +614,105 @@ namespace KancolleSniffer.Test
                 Assert.AreEqual("83.8", ship.EffectiveAntiSubmarine.ToString("f1"), "三種コンビネーションにならない");\r
             }\r
         }\r
+\r
+        // ReSharper disable once InconsistentNaming\r
+        private static readonly ItemStatus A12cm30連装噴進砲改二 = new ItemStatus\r
+        {\r
+            Id = 1,\r
+            Spec = new ItemSpec\r
+            {\r
+                Id = 274,\r
+                Type = 21,\r
+                IconType = 15,\r
+                AntiAir = 8\r
+            }\r
+        };\r
+\r
+        // ReSharper disable once InconsistentNaming\r
+        private static readonly ItemStatus A25mm三連装機銃集中配備 = new ItemStatus\r
+        {\r
+            Id = 1,\r
+            Spec = new ItemSpec{\r
+                Id = 131,\r
+                Type = 21,\r
+                IconType = 15,\r
+                AntiAir = 9\r
+            }\r
+        };\r
+\r
+        [TestClass]\r
+        public class AntiAirPropellantBarrageChance\r
+        {\r
+            private ShipStatus _ship;\r
+\r
+            [TestInitialize]\r
+            public void Initialize()\r
+            {\r
+                _ship =new ShipStatus\r
+                {\r
+                    AntiAir = 93,\r
+                    Lucky = 46,\r
+                    Spec = new ShipSpec\r
+                    {\r
+                        ShipType = 4,\r
+                    },\r
+                    Slot = new ItemStatus[0]\r
+                };\r
+            }\r
+\r
+            [TestMethod]\r
+            public void 噴進砲改二なし()\r
+            {\r
+                Assert.AreEqual(0, _ship.AntiAirPropellantBarrageChance);\r
+            }\r
+\r
+            [TestMethod]\r
+            public void 噴進砲改二1つ()\r
+            {\r
+                _ship.AntiAir = 85 + 8;\r
+                _ship.Slot = new[]\r
+                {\r
+                    A12cm30連装噴進砲改二\r
+                };\r
+                Assert.AreEqual("63.1", _ship.AntiAirPropellantBarrageChance.ToString("f1"));\r
+            }\r
+\r
+            [TestMethod]\r
+            public void 噴進砲改二2つ()\r
+            {\r
+                _ship.AntiAir = 85 + 16;\r
+                _ship.Slot = new[]\r
+                {\r
+                    A12cm30連装噴進砲改二,\r
+                    A12cm30連装噴進砲改二\r
+                };\r
+                Assert.AreEqual("95.1", _ship.AntiAirPropellantBarrageChance.ToString("f1"));\r
+            }\r
+\r
+            [TestMethod]\r
+            public void 噴進砲改二2つと機銃()\r
+            {\r
+                _ship.AntiAir = 85 + 25;\r
+                _ship.Slot = new[]\r
+                {\r
+                    A12cm30連装噴進砲改二,\r
+                    A12cm30連装噴進砲改二,\r
+                    A25mm三連装機銃集中配備\r
+                };\r
+                Assert.AreEqual("114.3", _ship.AntiAirPropellantBarrageChance.ToString("f1"), "噴進砲改二2+機銃");\r
+            }\r
+\r
+            [TestMethod]\r
+            public void 伊勢型()\r
+            {\r
+                _ship.AntiAir = 85 + 8;\r
+                _ship.Slot = new[]\r
+                {\r
+                    A12cm30連装噴進砲改二\r
+                };\r
+                _ship.Spec.ShipClass = 2;\r
+                Assert.AreEqual("88.1", _ship.AntiAirPropellantBarrageChance.ToString("f1"));\r
+            }\r
+        }\r
     }\r
 }
\ No newline at end of file
index 96925c7..ff2953a 100644 (file)
@@ -363,6 +363,19 @@ namespace KancolleSniffer.Model
 \r
         public int EffectiveAntiAirForFleet => (int)AllSlot.Sum(item => item.EffectiveAntiAirForFleet);\r
 \r
+        public double AntiAirPropellantBarrageChance\r
+        {\r
+            get\r
+            {\r
+                var launcherCount = Slot.Count(item => item.Spec.Id == 274);\r
+                if (launcherCount == 0)\r
+                    return 0;\r
+                var iseClass = Spec.ShipClass == 2;\r
+                var baseChance = (EffectiveAntiAirForShip + Lucky) / 282.0;\r
+                return (baseChance + 0.15 * (launcherCount - 1) + (iseClass ? 0.25 : 0)) * 100;\r
+            }\r
+        }\r
+\r
         public int EffectiveFuelMax => Max((int)(Spec.FuelMax * (Level >= 100 ? 0.85 : 1.0)), 1);\r
 \r
         public int EffectiveBullMax => Max((int)(Spec.BullMax * (Level >= 100 ? 0.85 : 1.0)), 1);\r