--- /dev/null
+using KancolleSniffer.Model;\r
+using Microsoft.VisualStudio.TestTools.UnitTesting;\r
+\r
+namespace KancolleSniffer.Test\r
+{\r
+ [TestClass]\r
+ public class ShipStatusTest\r
+ {\r
+ [TestClass]\r
+ public class OpeningSubmarineAttack\r
+ {\r
+ private static readonly ItemStatus 三式水中探信儀 = new ItemStatus\r
+ {\r
+ Id = 1,\r
+ Spec = new ItemSpec\r
+ {\r
+ Id = 47,\r
+ Name = "三式水中探信儀",\r
+ Type = 14,\r
+ AntiSubmarine = 10\r
+ }\r
+ };\r
+\r
+ /// <summary>\r
+ /// 通常の先制対潜\r
+ /// </summary>\r
+ [TestMethod]\r
+ public void CheckStandardCase()\r
+ {\r
+ var ship = new ShipStatus\r
+ {\r
+ Spec = new ShipSpec {ShipType = 3},\r
+ Slot = new[] {三式水中探信儀},\r
+ AntiSubmarine = 99\r
+ };\r
+ Assert.IsFalse(ship.CanOpeningAntiSubmarineAttack, "対潜不足");\r
+ ship.AntiSubmarine = 100;\r
+ Assert.IsTrue(ship.CanOpeningAntiSubmarineAttack);\r
+ ship.Slot = new[] {new ItemStatus()};\r
+ Assert.IsFalse(ship.CanOpeningAntiSubmarineAttack, "ソナー未搭載");\r
+ }\r
+\r
+\r
+ private static readonly ItemStatus 九五式爆雷 = new ItemStatus\r
+ {\r
+ Id = 1,\r
+ Spec = new ItemSpec\r
+ {\r
+ Id = 47,\r
+ Name = "九五式爆雷",\r
+ Type = 15,\r
+ AntiSubmarine = 4\r
+ }\r
+ };\r
+\r
+ /// <summary>\r
+ /// 海防艦の先制対潜\r
+ /// </summary>\r
+ [TestMethod]\r
+ public void CheckCoastGuard()\r
+ {\r
+ var ship = new ShipStatus\r
+ {\r
+ Spec = new ShipSpec {ShipType = 1},\r
+ Slot = new[] {九五式爆雷},\r
+ AntiSubmarine = 74\r
+ };\r
+ Assert.IsFalse(ship.CanOpeningAntiSubmarineAttack, "対潜不足");\r
+ ship.AntiSubmarine = 75;\r
+ Assert.IsTrue(ship.CanOpeningAntiSubmarineAttack);\r
+ ship.Slot[0].Spec.AntiSubmarine = 3;\r
+ Assert.IsFalse(ship.CanOpeningAntiSubmarineAttack, "装備対潜不足");\r
+ }\r
+\r
+ /// <summary>\r
+ /// 無条件で先制対潜が可能\r
+ /// </summary>\r
+ [DataTestMethod]\r
+ [DataRow("五十鈴改二")]\r
+ [DataRow("龍田改二")]\r
+ [DataRow("Jervis改")]\r
+ [DataRow("Samuel B.Roberts改")]\r
+ [DataRow("Johnston")]\r
+ [DataRow("Johnston改")]\r
+ public void CheckNonConditional(string name)\r
+ {\r
+ var ship = new ShipStatus\r
+ {\r
+ Spec = new ShipSpec\r
+ {\r
+ Name = name\r
+ }\r
+ };\r
+ Assert.IsTrue(ship.CanOpeningAntiSubmarineAttack);\r
+ }\r
+\r
+ private static readonly ItemStatus 流星改 = new ItemStatus\r
+ {\r
+ Id = 1,\r
+ Spec = new ItemSpec\r
+ {\r
+ Id = 52,\r
+ Name = "流星改",\r
+ Type = 8,\r
+ AntiSubmarine = 3\r
+ }\r
+ };\r
+\r
+ private static readonly ItemStatus カ号観測機 = new ItemStatus\r
+ {\r
+ Id = 1,\r
+ Spec = new ItemSpec\r
+ {\r
+ Id = 69,\r
+ Name = "カ号観測機",\r
+ Type = 25,\r
+ AntiSubmarine = 9\r
+ }\r
+ };\r
+\r
+ private static readonly ItemStatus 三式指揮連絡機対潜 = new ItemStatus\r
+ {\r
+ Id = 1,\r
+ Spec = new ItemSpec\r
+ {\r
+ Id = 70,\r
+ Name = "三式指揮連絡機(対潜)",\r
+ Type = 26,\r
+ AntiSubmarine = 7\r
+ }\r
+ };\r
+\r
+ private static readonly ItemStatus 九九式艦爆 = new ItemStatus\r
+ {\r
+ Id = 1,\r
+ Spec = new ItemSpec\r
+ {\r
+ Id = 23,\r
+ Name = "九九式艦爆",\r
+ Type = 7,\r
+ AntiSubmarine = 3\r
+ }\r
+ };\r
+\r
+ /// <summary>\r
+ /// 大鷹改・改二、神鷹改・改二\r
+ /// </summary>\r
+ [DataTestMethod]\r
+ [DataRow("大鷹改")]\r
+ [DataRow("大鷹改二")]\r
+ [DataRow("神鷹改")]\r
+ [DataRow("神鷹改二")]\r
+ public void CheckSpecialEscortCarrier(string name)\r
+ {\r
+ var ship = new ShipStatus\r
+ {\r
+ Spec = new ShipSpec\r
+ {\r
+ Name = name\r
+ },\r
+ Slot = new ItemStatus[0]\r
+ };\r
+ Assert.IsFalse(ship.CanOpeningAntiSubmarineAttack);\r
+\r
+ ship.Slot = new[] {流星改};\r
+ Assert.IsTrue(ship.CanOpeningAntiSubmarineAttack);\r
+\r
+ ship.Slot = new[] {カ号観測機};\r
+ Assert.IsTrue(ship.CanOpeningAntiSubmarineAttack);\r
+\r
+ ship.Slot = new[] {三式指揮連絡機対潜};\r
+ Assert.IsTrue(ship.CanOpeningAntiSubmarineAttack);\r
+\r
+ ship.Slot = new[] {九九式艦爆};\r
+ Assert.IsTrue(ship.CanOpeningAntiSubmarineAttack);\r
+ }\r
+\r
+ private static readonly ItemStatus 水中聴音機零式 = new ItemStatus\r
+ {\r
+ Id = 1,\r
+ Spec = new ItemSpec\r
+ {\r
+ Id = 132,\r
+ Name = "水中聴音機零式",\r
+ Type = 40,\r
+ AntiSubmarine = 11\r
+ }\r
+ };\r
+\r
+ private static readonly ItemStatus 九七式艦攻九三一空 = new ItemStatus\r
+ {\r
+ Id = 1,\r
+ Spec = new ItemSpec\r
+ {\r
+ Id = 82,\r
+ Name = "九七式艦攻(九三一空)",\r
+ Type = 8,\r
+ AntiSubmarine = 7\r
+ }\r
+ };\r
+\r
+ [DataTestMethod]\r
+ [DataRow("大鷹")]\r
+ [DataRow("Gambier Bay")]\r
+ [DataRow("Gambier Bay改")]\r
+ [DataRow("瑞鳳改二乙")]\r
+ [DataRow("神鷹")]\r
+ public void CheckEscortCarrierLevel50(string name)\r
+ {\r
+ var ship = new ShipStatus\r
+ {\r
+ Spec = new ShipSpec\r
+ {\r
+ Name = name\r
+ },\r
+ Slot = new ItemStatus[0]\r
+ };\r
+ Assert.IsFalse(ship.CanOpeningAntiSubmarineAttack);\r
+\r
+ ship.AntiSubmarine = 49;\r
+ ship.Slot = new[]\r
+ {\r
+ 水中聴音機零式,\r
+ 九七式艦攻九三一空\r
+ };\r
+ Assert.IsFalse(ship.CanOpeningAntiSubmarineAttack);\r
+\r
+ ship.AntiSubmarine = 50;\r
+ Assert.IsTrue(ship.CanOpeningAntiSubmarineAttack);\r
+\r
+ ship.Slot = new[]\r
+ {\r
+ 水中聴音機零式,\r
+ 三式指揮連絡機対潜\r
+ };\r
+ Assert.IsTrue(ship.CanOpeningAntiSubmarineAttack);\r
+\r
+ ship.Slot = new[]\r
+ {\r
+ 水中聴音機零式,\r
+ カ号観測機\r
+ };\r
+ Assert.IsTrue(ship.CanOpeningAntiSubmarineAttack);\r
+ }\r
+\r
+ [DataTestMethod]\r
+ [DataRow("大鷹")]\r
+ [DataRow("Gambier Bay")]\r
+ [DataRow("Gambier Bay改")]\r
+ [DataRow("瑞鳳改二乙")]\r
+ [DataRow("神鷹")]\r
+ public void CheckEscortCarrierLevel65(string name)\r
+ {\r
+ var ship = new ShipStatus\r
+ {\r
+ Spec = new ShipSpec\r
+ {\r
+ Name = name\r
+ },\r
+ Slot = new ItemStatus[0]\r
+ };\r
+ Assert.IsFalse(ship.CanOpeningAntiSubmarineAttack);\r
+\r
+ ship.AntiSubmarine = 64;\r
+ ship.Slot = new[]\r
+ {\r
+ 九七式艦攻九三一空\r
+ };\r
+ Assert.IsFalse(ship.CanOpeningAntiSubmarineAttack);\r
+\r
+ ship.AntiSubmarine = 65;\r
+ Assert.IsTrue(ship.CanOpeningAntiSubmarineAttack);\r
+\r
+ ship.Slot = new[]\r
+ {\r
+ カ号観測機\r
+ };\r
+ Assert.IsTrue(ship.CanOpeningAntiSubmarineAttack);\r
+\r
+ ship.Slot = new[]\r
+ {\r
+ 三式指揮連絡機対潜\r
+ };\r
+ Assert.IsTrue(ship.CanOpeningAntiSubmarineAttack);\r
+ }\r
+\r
+ [DataTestMethod]\r
+ [DataRow("大鷹")]\r
+ [DataRow("Gambier Bay")]\r
+ [DataRow("Gambier Bay改")]\r
+ [DataRow("瑞鳳改二乙")]\r
+ [DataRow("神鷹")]\r
+ public void CheckEscortCarrierLevel100(string name)\r
+ {\r
+ var ship = new ShipStatus\r
+ {\r
+ Spec = new ShipSpec\r
+ {\r
+ Name = name\r
+ },\r
+ Slot = new ItemStatus[0]\r
+ };\r
+ Assert.IsFalse(ship.CanOpeningAntiSubmarineAttack);\r
+\r
+ ship.AntiSubmarine = 100;\r
+ ship.Slot = new[]\r
+ {\r
+ 水中聴音機零式,\r
+ カ号観測機\r
+ };\r
+ Assert.IsFalse(ship.CanOpeningAntiSubmarineAttack);\r
+\r
+ ship.Slot = new[]\r
+ {\r
+ 水中聴音機零式,\r
+ 流星改\r
+ };\r
+ Assert.IsTrue(ship.CanOpeningAntiSubmarineAttack);\r
+\r
+ ship.AntiSubmarine = 99;\r
+ Assert.IsFalse(ship.CanOpeningAntiSubmarineAttack);\r
+\r
+ ship.AntiSubmarine = 100;\r
+ ship.Slot = new[]\r
+ {\r
+ 水中聴音機零式,\r
+ 九九式艦爆\r
+ };\r
+ Assert.IsTrue(ship.CanOpeningAntiSubmarineAttack);\r
+ }\r
+\r
+ [TestMethod]\r
+ public void 瑞鳳改二()\r
+ {\r
+ CheckEscortCarrierLevel50("瑞鳳改二");\r
+\r
+ var ship = new ShipStatus\r
+ {\r
+ Spec = new ShipSpec\r
+ {\r
+ Name = "瑞鳳改二"\r
+ },\r
+ Slot = new ItemStatus[0]\r
+ };\r
+ Assert.IsFalse(ship.CanOpeningAntiSubmarineAttack);\r
+\r
+ ship.AntiSubmarine = 65;\r
+ ship.Slot = new[]\r
+ {\r
+ カ号観測機\r
+ };\r
+ Assert.IsFalse(ship.CanOpeningAntiSubmarineAttack);\r
+\r
+ ship.AntiSubmarine = 100;\r
+ ship.Slot = new[]\r
+ {\r
+ 水中聴音機零式,\r
+ 流星改\r
+ };\r
+ Assert.IsFalse(ship.CanOpeningAntiSubmarineAttack);\r
+ }\r
+ }\r
+ }\r
+}
\ No newline at end of file
{\r
get\r
{\r
+ var specs = Slot.Select(item => item.Spec).ToArray();\r
switch (Name)\r
{\r
case "五十鈴改二":\r
case "龍田改二":\r
case "Jervis改":\r
case "Samuel B.Roberts改":\r
+ case "Johnston":\r
+ case "Johnston改":\r
return true;\r
case "大鷹改":\r
case "大鷹改二":\r
- return Slot.Any(item => item.Spec.IsAircraft && item.Spec.EffectiveAntiSubmarine > 0);\r
+ case "神鷹改":\r
+ case "神鷹改二":\r
+ return specs.Any(spec => spec.IsTorpedoBomber && spec.AntiSubmarine >= 1 ||\r
+ spec.IsArmyAircraft || spec.IsDiveBomber);\r
case "大鷹":\r
case "Gambier Bay":\r
case "Gambier Bay改":\r
case "瑞鳳改二乙":\r
case "神鷹":\r
- case "神鷹改":\r
- case "神鷹改二":\r
- return Slot.Any(item => item.Spec.IsAircraft && item.Spec.EffectiveAntiSubmarine >= 7) &&\r
- AntiSubmarine >= (HaveSonar ? 50 : 65);\r
+ if (AntiSubmarine < 50)\r
+ return false;\r
+ if (AntiSubmarine >= 50 && AntiSubmarine < 100)\r
+ return (AntiSubmarine >= 65 || HaveSonar) &&\r
+ specs.Any(spec => spec.IsTorpedoBomber && spec.AntiSubmarine >= 7 ||\r
+ spec.IsArmyAircraft);\r
+ return HaveSonar &&\r
+ specs.Any(spec => spec.IsTorpedoBomber && spec.AntiSubmarine >= 1 ||\r
+ spec.IsDiveBomber);\r
+ case "瑞鳳改二":\r
+ if (AntiSubmarine < 50)\r
+ return false;\r
+ return HaveSonar &&\r
+ specs.Any(spec => spec.IsTorpedoBomber && spec.AntiSubmarine >= 7 ||\r
+ spec.IsArmyAircraft);\r
default:\r
- return Spec.ShipType == 1\r
- ? Slot.Sum(item => item.Spec.AntiSubmarine) >= 4 && AntiSubmarine >= 75 ||\r
- HaveSonar && AntiSubmarine >= 60\r
- : HaveSonar && AntiSubmarine >= 100;\r
+ if (HaveSonar && AntiSubmarine >= 100)\r
+ return true;\r
+ if (Spec.ShipType != 1)\r
+ return false;\r
+ return Slot.Sum(item => item.Spec.AntiSubmarine) >= 4 && AntiSubmarine >= 75 ||\r
+ HaveSonar && AntiSubmarine >= 60;\r
}\r
}\r
}\r