OSDN Git Service

QuestCounterの見通しをよくする
authorKazuhiro Fujieda <fujieda@users.osdn.me>
Thu, 4 Jul 2019 11:55:26 +0000 (20:55 +0900)
committerKazuhiro Fujieda <fujieda@users.osdn.me>
Sat, 6 Jul 2019 09:14:05 +0000 (18:14 +0900)
KancolleSniffer/KancolleSniffer.csproj
KancolleSniffer/Model/QuestCounter.cs
KancolleSniffer/Model/QuestInfo.cs
KancolleSniffer/Model/QuestSpec.cs [new file with mode: 0644]

index dd9430b..120a909 100644 (file)
@@ -57,6 +57,7 @@
     <Compile Include="Model\AirBaseParams.cs" />\r
     <Compile Include="Model\QuestCounter.cs" />\r
     <Compile Include="Model\QuestCountList.cs" />\r
+    <Compile Include="Model\QuestSpec.cs" />\r
     <Compile Include="Privacy.cs" />\r
     <Compile Include="Log\LogProcessor.cs" />\r
     <Compile Include="Model\Achievement.cs" />\r
index aa66f17..b662e9f 100644 (file)
@@ -160,6 +160,26 @@ namespace KancolleSniffer.Model
         private int _cell;\r
         private bool _boss;\r
 \r
+        private class ResultShipSpecs\r
+        {\r
+            public ResultShipSpecs(BattleInfo battleInfo)\r
+            {\r
+                Specs = battleInfo.Result?.Friend.Main.Where(s => s.NowHp > 0).Select(ship => ship.Spec).ToArray() ?? new ShipSpec[0];\r
+                Ids = Specs.Select(spec => spec.Id).ToArray();\r
+                Types = Specs.Select(spec => spec.ShipType).ToArray();\r
+                Classes = Specs.Select(spec => spec.ShipClass).ToArray();\r
+                Flagship = Specs.FirstOrDefault();\r
+                FlagshipType = Types.FirstOrDefault();\r
+            }\r
+\r
+            public ShipSpec[] Specs { get; }\r
+            public int[] Ids { get; }\r
+            public int[] Types { get; }\r
+            public int[] Classes { get; }\r
+            public ShipSpec Flagship { get; }\r
+            public int FlagshipType { get; }\r
+        }\r
+\r
         public QuestCounter(QuestInfo questInfo, ItemInfo itemInfo, BattleInfo battleInfo)\r
         {\r
             _questInfo = questInfo;\r
@@ -186,272 +206,253 @@ namespace KancolleSniffer.Model
             _cell = json.api_no() ? (int)json.api_no : 0;\r
             _boss = (int)json.api_event_id == 5;\r
 \r
-            if (_quests.TryGetValue(861, out var q861))\r
+            if (_quests.TryGetValue(861, out var q861) && _map == 16 && (int)json.api_event_id == 8)\r
             {\r
-                if (_map == 16 && (int)json.api_event_id == 8)\r
-                {\r
-                    var fleet = _battleInfo.Result.Friend.Main.Where(s => s.NowHp > 0).Select(s => s.Spec.ShipType)\r
-                        .ToArray();\r
-                    if (fleet.Count(s => s == 10 || s == 22) == 2)\r
-                        Increment(q861.Count);\r
-                }\r
+                if (new ResultShipSpecs(_battleInfo).Types.Count(s => s == 10 || s == 22) == 2)\r
+                    Increment(q861.Count);\r
             }\r
         }\r
 \r
+        private class Rank\r
+        {\r
+            private readonly string _rank;\r
+\r
+            public Rank(string rank)\r
+            {\r
+                _rank = rank;\r
+            }\r
+\r
+            public bool S => QuestSortie.CompareRank(_rank, "S") == 0;\r
+            public bool A => QuestSortie.CompareRank(_rank, "A") <= 0;\r
+            public bool B => QuestSortie.CompareRank(_rank, "B") <= 0;\r
+        }\r
+\r
         public void InspectBattleResult(dynamic json)\r
         {\r
-            var rank = json.api_win_rank;\r
+            var rawRak = json.api_win_rank;\r
+            var rank = new Rank(rawRak);\r
+            var specs = new ResultShipSpecs(_battleInfo);\r
             foreach (var quest in _quests.Values)\r
             {\r
                 var count = quest.Count;\r
                 switch (count.Spec)\r
                 {\r
                     case QuestSortie sortie:\r
-                        if (count.Id == 216 && !_boss || sortie.Check(rank, _map, _boss))\r
+                        if (count.Id == 216 && !_boss || sortie.Check(rawRak, _map, _boss))\r
                             Increment(count);\r
-                        break;\r
+                        continue;\r
                     case QuestEnemyType enemyType:\r
                         var num = enemyType.CountResult(\r
                             _battleInfo.Result.Enemy.Main.Concat(_battleInfo.Result.Enemy.Guard));\r
                         if (num > 0)\r
                             Add(count, num);\r
-                        break;\r
-                }\r
-            }\r
-            if (_quests.TryGetValue(214, out var ago))\r
-            {\r
-                var count = ago.Count;\r
-                if (_boss)\r
-                {\r
-                    IncrementNth(count, 2);\r
-                    if (QuestSortie.CompareRank(rank, "B") <= 0)\r
-                        IncrementNth(count, 3);\r
-                }\r
-                if (rank == "S")\r
-                    IncrementNth(count, 1);\r
-            }\r
-            if (_quests.TryGetValue(249, out var q249))\r
-            {\r
-                if (_map == 25 && _boss && QuestSortie.CompareRank(rank, "S") == 0)\r
-                {\r
-                    var fleet = _battleInfo.Result.Friend.Main.Where(s => s.NowHp > 0).Select(s => s.Spec.Id)\r
-                        .ToArray();\r
-                    if (fleet.Intersect(new[] {62, 63, 64, 265, 266, 268, 319, 192, 194}).Count() == 3)\r
-                        Increment(q249.Count);\r
-                }\r
-            }\r
-            if (_quests.TryGetValue(257, out var q257))\r
-            {\r
-                if (_map == 14 && _boss && QuestSortie.CompareRank(rank, "S") == 0)\r
-                {\r
-                    var fleet = _battleInfo.Result.Friend.Main.Where(s => s.NowHp > 0).Select(s => s.Spec.ShipType)\r
-                        .ToArray();\r
-                    if (fleet[0] == 3 && fleet.Count(s => s == 3) <= 3 && fleet.All(s => s == 2 || s == 3))\r
-                        Increment(q257.Count);\r
-                }\r
-            }\r
-            if (_quests.TryGetValue(259, out var q259))\r
-            {\r
-                if (_map == 51 && _boss && QuestSortie.CompareRank(rank, "S") == 0)\r
-                {\r
-                    var fleet = _battleInfo.Result.Friend.Main.Where(s => s.NowHp > 0).Select(s => s.Spec).ToArray();\r
-                    // ReSharper disable once IdentifierTypo\r
-                    var ctype = new[]\r
-                    {\r
-                        2, // 伊勢型\r
-                        19, // 長門型\r
-                        26, // 扶桑型\r
-                        37 // 大和型\r
-                    };\r
-                    if (fleet.Select(s => s.ShipClass).Count(c => ctype.Contains(c)) == 3 &&\r
-                        fleet.Count(s => s.ShipType == 3) > 0)\r
-                    {\r
-                        Increment(q259.Count);\r
-                    }\r
-                }\r
-            }\r
-            if (_quests.TryGetValue(264, out var q264))\r
-            {\r
-                if (_map == 42 && _boss && QuestSortie.CompareRank(rank, "S") == 0)\r
-                {\r
-                    var fleet = _battleInfo.Result.Friend.Main.Where(s => s.NowHp > 0).Select(s => s.Spec)\r
-                        .ToArray();\r
-                    if (fleet.Count(spec => spec.ShipType == 2) >= 2 &&\r
-                        fleet.Count(spec => spec.IsAircraftCarrier) >= 2)\r
-                        Increment(q264.Count);\r
-                }\r
-            }\r
-            if (_quests.TryGetValue(266, out var q266))\r
-            {\r
-                if (_map == 25 && _boss && QuestSortie.CompareRank(rank, "S") == 0)\r
-                {\r
-                    var fleet = _battleInfo.Result.Friend.Main.Where(s => s.NowHp > 0).Select(s => s.Spec.ShipType)\r
-                        .ToArray();\r
-                    if (fleet[0] == 2 && fleet.OrderBy(x => x).SequenceEqual(new[] {2, 2, 2, 2, 3, 5}))\r
-                        Increment(q266.Count);\r
+                        continue;\r
                 }\r
-            }\r
-            if (_quests.TryGetValue(280, out var q280))\r
-            {\r
-                if (!(_boss && QuestSortie.CompareRank(rank, "S") == 0))\r
-                    return;\r
-                var shipTypes = _battleInfo.Result.Friend.Main.Where(s => s.NowHp > 0).Select(s => s.Spec.ShipType)\r
-                    .ToArray();\r
-                if (!(shipTypes.Count(type => type == 1 || type == 2) >= 3 &&\r
-                      shipTypes.Any(type => new[] {3, 4, 7, 21}.Contains(type))))\r
-                    return;\r
-                var count = q280.Count;\r
-                switch (_map)\r
+                switch (quest.Id)\r
                 {\r
-                    case 12:\r
-                        IncrementNth(count, 0);\r
-                        break;\r
-                    case 13:\r
-                        IncrementNth(count, 1);\r
-                        break;\r
-                    case 14:\r
-                        IncrementNth(count, 2);\r
-                        break;\r
-                    case 21:\r
-                        IncrementNth(count, 3);\r
-                        break;\r
-                }\r
-            }\r
-            if (_quests.TryGetValue(854, out var opz) && _boss)\r
-            {\r
-                var count = opz.Count;\r
-                switch (_map)\r
-                {\r
-                    case 24 when QuestSortie.CompareRank(rank, "A") <= 0:\r
-                        IncrementNth(count, 0);\r
-                        break;\r
-                    case 61 when QuestSortie.CompareRank(rank, "A") <= 0:\r
-                        IncrementNth(count, 1);\r
+                    case 214:\r
+                        if (rank.S)\r
+                            IncrementNth(count, 1);\r
+                        if (_boss)\r
+                        {\r
+                            IncrementNth(count, 2);\r
+                            if (rank.B)\r
+                                IncrementNth(count, 3);\r
+                        }\r
                         break;\r
-                    case 63 when QuestSortie.CompareRank(rank, "A") <= 0:\r
-                        IncrementNth(count, 2);\r
+                    case 249:\r
+                        if (_map == 25 && _boss && rank.S &&\r
+                            specs.Ids.Intersect(new[] {62, 63, 64, 265, 266, 268, 319, 192, 194}).Count() == 3)\r
+                        {\r
+                            Increment(count);\r
+                        }\r
                         break;\r
-                    case 64 when QuestSortie.CompareRank(rank, "S") <= 0:\r
-                        IncrementNth(count, 3);\r
+                    case 257:\r
+                        if (_map == 14 && _boss && rank.S &&\r
+                            specs.FlagshipType == 3 &&\r
+                            specs.Types.Count(s => s == 3) <= 3 &&\r
+                            specs.Types.All(s => s == 2 || s == 3))\r
+                        {\r
+                            Increment(count);\r
+                        }\r
                         break;\r
-                }\r
-            }\r
-            if (_quests.TryGetValue(862, out var q862))\r
-            {\r
-                if (_map == 63 && _boss && QuestSortie.CompareRank(rank, "A") <= 0)\r
-                {\r
-                    var fleet = _battleInfo.Result.Friend.Main.Where(s => s.NowHp > 0).Select(s => s.Spec.ShipType)\r
-                        .ToArray();\r
-                    if (fleet.Count(s => s == 3) >= 2 && fleet.Count(s => s == 16) >= 1)\r
-                        Increment(q862.Count);\r
-                }\r
-            }\r
-            if (_quests.TryGetValue(873, out var q873))\r
-            {\r
-                if (_battleInfo.Result.Friend.Main.Count(s => s.NowHp > 0 && s.Spec.ShipType == 3) >= 1 &&\r
-                    _boss && QuestSortie.CompareRank(rank, "A") <= 0)\r
-                {\r
-                    var count = q873.Count;\r
-                    switch (_map)\r
-                    {\r
-                        case 31:\r
-                            IncrementNth(count, 0);\r
-                            break;\r
-                        case 32:\r
-                            IncrementNth(count, 1);\r
-                            break;\r
-                        case 33:\r
-                            IncrementNth(count, 2);\r
-                            break;\r
-                    }\r
-                }\r
-            }\r
-            if (_quests.TryGetValue(875, out var q875))\r
-            {\r
-                if (_map == 54 && _boss && QuestSortie.CompareRank(rank, "S") == 0)\r
-                {\r
-                    var fleet = _battleInfo.Result.Friend.Main.Where(s => s.NowHp > 0).Select(s => s.Spec.Id).ToArray();\r
-                    if (fleet.Contains(543) && fleet.Intersect(new[] {344, 345, 359}).Any())\r
-                        Increment(q875.Count);\r
-                }\r
-            }\r
-            if (_quests.TryGetValue(888, out var q888))\r
-            {\r
-                if (!_boss || QuestSortie.CompareRank(rank, "S") != 0)\r
-                    return;\r
-                var fleet = from ship in _battleInfo.Result.Friend.Main where ship.NowHp > 0 select ship.Spec.Id;\r
-                var member = new[]\r
-                {\r
-                    69, 272, 427, // 鳥海\r
-                    61, 264, // 青葉\r
-                    123, 295, 142, // 衣笠\r
-                    59, 262, 416, // 古鷹\r
-                    60, 263, 417, // 加古\r
-                    51, 213, 477, // 天龍\r
-                    115, 293 // 夕張\r
-                };\r
-                if (fleet.Intersect(member).Count() < 4)\r
-                    return;\r
-                var count = q888.Count;\r
-                switch (_map)\r
-                {\r
-                    case 51:\r
-                        IncrementNth(count, 0);\r
+                    case 259:\r
+                        if (_map == 51 && _boss && rank.S &&\r
+                            specs.Types.Count(type => type == 3) > 0 &&\r
+                            specs.Classes.Count(c => new[]\r
+                            {\r
+                                2, // 伊勢型\r
+                                19, // 長門型\r
+                                26, // 扶桑型\r
+                                37 // 大和型\r
+                            }.Contains(c)) == 3)\r
+                        {\r
+                            Increment(count);\r
+                        }\r
                         break;\r
-                    case 53:\r
-                        IncrementNth(count, 1);\r
+                    case 264:\r
+                        if (_map == 42 && _boss && rank.S &&\r
+                            specs.Types.Count(type => type == 2) >= 2 &&\r
+                            specs.Specs.Count(spec => spec.IsAircraftCarrier) >= 2)\r
+                        {\r
+                            Increment(count);\r
+                        }\r
                         break;\r
-                    case 54:\r
-                        IncrementNth(count, 2);\r
+                    case 266:\r
+                        if (_map == 25 && _boss && rank.S &&\r
+                            specs.FlagshipType == 2 &&\r
+                            specs.Types.OrderBy(x => x).SequenceEqual(new[] {2, 2, 2, 2, 3, 5}))\r
+                        {\r
+                            Increment(count);\r
+                        }\r
                         break;\r
-                }\r
-            }\r
-            if (_quests.TryGetValue(893, out var q893))\r
-            {\r
-                if (!_boss || QuestSortie.CompareRank(rank, "S") != 0)\r
-                    return;\r
-                var count = q893.Count;\r
-                switch (_map)\r
-                {\r
-                    case 15:\r
-                        IncrementNth(count, 0);\r
+                    case 280:\r
+                        if (!(_boss && rank.S))\r
+                            return;\r
+                        if (!(specs.Types.Count(type => type == 1 || type == 2) >= 3 &&\r
+                              specs.Types.Any(type => new[] {3, 4, 7, 21}.Contains(type))))\r
+                            return;\r
+                        switch (_map)\r
+                        {\r
+                            case 12:\r
+                                IncrementNth(count, 0);\r
+                                break;\r
+                            case 13:\r
+                                IncrementNth(count, 1);\r
+                                break;\r
+                            case 14:\r
+                                IncrementNth(count, 2);\r
+                                break;\r
+                            case 21:\r
+                                IncrementNth(count, 3);\r
+                                break;\r
+                        }\r
                         break;\r
-                    case 71:\r
-                        IncrementNth(count, 1);\r
+                    case 854:\r
+                        if (_boss)\r
+                        {\r
+                            switch (_map)\r
+                            {\r
+                                case 24 when rank.A:\r
+                                    IncrementNth(count, 0);\r
+                                    break;\r
+                                case 61 when rank.A:\r
+                                    IncrementNth(count, 1);\r
+                                    break;\r
+                                case 63 when rank.A:\r
+                                    IncrementNth(count, 2);\r
+                                    break;\r
+                                case 64 when rank.S:\r
+                                    IncrementNth(count, 3);\r
+                                    break;\r
+                            }\r
+                        }\r
                         break;\r
-                    case 72:\r
-                        if (_cell == 7)\r
+                    case 862:\r
+                        if (_map == 63 && _boss && rank.A &&\r
+                            specs.Types.Count(s => s == 3) >= 2 &&\r
+                            specs.Types.Count(s => s == 16) >= 1)\r
                         {\r
-                            IncrementNth(count, 2);\r
-                            break;\r
+                            Increment(count);\r
                         }\r
-                        IncrementNth(count, 3);\r
                         break;\r
-                }\r
-            }\r
-            if (_quests.TryGetValue(894, out var q894))\r
-            {\r
-                if (!_boss ||\r
-                    QuestSortie.CompareRank(rank, "S") != 0 ||\r
-                    !_battleInfo.Result.Friend.Main.Any(s => s.Spec.IsAircraftCarrier && s.NowHp > 0))\r
-                    return;\r
-                var count = q894.Count;\r
-                switch (_map)\r
-                {\r
-                    case 13:\r
-                        IncrementNth(count, 0);\r
+                    case 873:\r
+                        if (_boss && rank.A &&\r
+                            specs.Types.Count(type => type == 3) >= 1)\r
+                        {\r
+                            switch (_map)\r
+                            {\r
+                                case 31:\r
+                                    IncrementNth(count, 0);\r
+                                    break;\r
+                                case 32:\r
+                                    IncrementNth(count, 1);\r
+                                    break;\r
+                                case 33:\r
+                                    IncrementNth(count, 2);\r
+                                    break;\r
+                            }\r
+                        }\r
                         break;\r
-                    case 14:\r
-                        IncrementNth(count, 1);\r
+                    case 875:\r
+                        if (_map == 54 && _boss && rank.S &&\r
+                            specs.Ids.Contains(543) &&\r
+                            specs.Ids.Intersect(new[] {344, 345, 359}).Any())\r
+                        {\r
+                            Increment(count);\r
+                        }\r
                         break;\r
-                    case 21:\r
-                        IncrementNth(count, 2);\r
+                    case 888:\r
+                        if (!_boss || !rank.S)\r
+                            return;\r
+                        var member = new[]\r
+                        {\r
+                            69, 272, 427, // 鳥海\r
+                            61, 264, // 青葉\r
+                            123, 295, 142, // 衣笠\r
+                            59, 262, 416, // 古鷹\r
+                            60, 263, 417, // 加古\r
+                            51, 213, 477, // 天龍\r
+                            115, 293 // 夕張\r
+                        };\r
+                        if (specs.Ids.Intersect(member).Count() < 4)\r
+                            return;\r
+                        switch (_map)\r
+                        {\r
+                            case 51:\r
+                                IncrementNth(count, 0);\r
+                                break;\r
+                            case 53:\r
+                                IncrementNth(count, 1);\r
+                                break;\r
+                            case 54:\r
+                                IncrementNth(count, 2);\r
+                                break;\r
+                        }\r
                         break;\r
-                    case 22:\r
-                        IncrementNth(count, 3);\r
+                    case 893:\r
+                        if (!_boss || !rank.S)\r
+                            return;\r
+                        switch (_map)\r
+                        {\r
+                            case 15:\r
+                                IncrementNth(count, 0);\r
+                                break;\r
+                            case 71:\r
+                                IncrementNth(count, 1);\r
+                                break;\r
+                            case 72:\r
+                                if (_cell == 7)\r
+                                {\r
+                                    IncrementNth(count, 2);\r
+                                    break;\r
+                                }\r
+                                IncrementNth(count, 3);\r
+                                break;\r
+                        }\r
                         break;\r
-                    case 23:\r
-                        IncrementNth(count, 4);\r
+                    case 894:\r
+                        if (!_boss || !rank.S ||\r
+                            !specs.Specs.Any(spec => spec.IsAircraftCarrier))\r
+                            return;\r
+                        switch (_map)\r
+                        {\r
+                            case 13:\r
+                                IncrementNth(count, 0);\r
+                                break;\r
+                            case 14:\r
+                                IncrementNth(count, 1);\r
+                                break;\r
+                            case 21:\r
+                                IncrementNth(count, 2);\r
+                                break;\r
+                            case 22:\r
+                                IncrementNth(count, 3);\r
+                                break;\r
+                            case 23:\r
+                                IncrementNth(count, 4);\r
+                                break;\r
+                        }\r
                         break;\r
                 }\r
             }\r
@@ -467,31 +468,35 @@ namespace KancolleSniffer.Model
 \r
         public void InspectPracticeResult(dynamic json)\r
         {\r
+            var rank = new Rank(json.api_win_rank);\r
+            var specs = new ResultShipSpecs(_battleInfo);\r
             foreach (var quest in _quests.Values)\r
             {\r
                 var count = quest.Count;\r
-                if (!(count.Spec is QuestPractice practice))\r
-                    continue;\r
-                if (practice.Check(json.api_win_rank))\r
-                    Increment(count);\r
-            }\r
-            if (_quests.TryGetValue(318, out var q318))\r
-            {\r
-                if (_questFleet == 0 && QuestSortie.CompareRank(json.api_win_rank, "B") <= 0 &&\r
-                    _battleInfo.Result.Friend.Main.Count(s => s.Spec.ShipType == 3) >= 2)\r
+                if (count.Spec is QuestPractice practice)\r
                 {\r
-                    Increment(q318.Count);\r
+                    if (practice.Check(json.api_win_rank))\r
+                        Increment(count);\r
+                    continue;\r
                 }\r
-            }\r
-            if (_quests.TryGetValue(330, out var q330))\r
-            {\r
-                var fleet = _battleInfo.Result.Friend.Main;\r
-                if (QuestSortie.CompareRank(json.api_win_rank, "B") <= 0 &&\r
-                    fleet.Count(s => s.Spec.IsAircraftCarrier) >= 2 &&\r
-                    fleet.Count(s => s.Spec.ShipType == 2) >= 2 &&\r
-                    fleet[0].Spec.IsAircraftCarrier)\r
+                switch (quest.Id)\r
                 {\r
-                    Increment(q330.Count);\r
+                    case 318:\r
+                        if (_questFleet == 0 && rank.B &&\r
+                            specs.Types.Count(type => type == 3) >= 2)\r
+                        {\r
+                            Increment(count);\r
+                        }\r
+                        break;\r
+                    case 330:\r
+                        if (rank.B &&\r
+                            specs.Flagship.IsAircraftCarrier &&\r
+                            specs.Specs.Count(spec => spec.IsAircraftCarrier) >= 2 &&\r
+                            specs.Types.Count(type => type == 2) >= 2)\r
+                        {\r
+                            Increment(count);\r
+                        }\r
+                        break;\r
                 }\r
             }\r
         }\r
@@ -514,43 +519,44 @@ namespace KancolleSniffer.Model
             foreach (var quest in _quests.Values)\r
             {\r
                 var count = quest.Count;\r
-                if (!(count.Spec is QuestMission mission))\r
-                    continue;\r
-                if (mission.Check(mid))\r
-                    Increment(count);\r
-            }\r
-            if (_quests.TryGetValue(426, out var q426))\r
-            {\r
-                var count = q426.Count;\r
-                switch (mid)\r
+                if (count.Spec is QuestMission mission)\r
                 {\r
-                    case 3:\r
-                        IncrementNth(count, 0);\r
-                        break;\r
-                    case 4:\r
-                        IncrementNth(count, 1);\r
-                        break;\r
-                    case 5:\r
-                        IncrementNth(count, 2);\r
-                        break;\r
-                    case 10:\r
-                        IncrementNth(count, 3);\r
-                        break;\r
+                    if (mission.Check(mid))\r
+                        Increment(count);\r
+                    continue;\r
                 }\r
-            }\r
-            if (_quests.TryGetValue(428, out var q428))\r
-            {\r
-                var count = q428.Count;\r
-                switch (mid)\r
+                switch (quest.Id)\r
                 {\r
-                    case 4:\r
-                        IncrementNth(count, 0);\r
-                        break;\r
-                    case 101:\r
-                        IncrementNth(count, 1);\r
+                    case 426:\r
+                        switch (mid)\r
+                        {\r
+                            case 3:\r
+                                IncrementNth(count, 0);\r
+                                break;\r
+                            case 4:\r
+                                IncrementNth(count, 1);\r
+                                break;\r
+                            case 5:\r
+                                IncrementNth(count, 2);\r
+                                break;\r
+                            case 10:\r
+                                IncrementNth(count, 3);\r
+                                break;\r
+                        }\r
                         break;\r
-                    case 102:\r
-                        IncrementNth(count, 2);\r
+                    case 428:\r
+                        switch (mid)\r
+                        {\r
+                            case 4:\r
+                                IncrementNth(count, 0);\r
+                                break;\r
+                            case 101:\r
+                                IncrementNth(count, 1);\r
+                                break;\r
+                            case 102:\r
+                                IncrementNth(count, 2);\r
+                                break;\r
+                        }\r
                         break;\r
                 }\r
             }\r
@@ -588,16 +594,18 @@ namespace KancolleSniffer.Model
             foreach (var quest in _quests.Values)\r
             {\r
                 var count = quest.Count;\r
-                if (!(count.Spec is QuestDestroyItem destroy))\r
+                if (count.Spec is QuestDestroyItem destroy)\r
+                {\r
+                    if (destroy.Count(count, items))\r
+                        NeedSave = true;\r
                     continue;\r
-                if (destroy.Count(count, items))\r
+                }\r
+                if (quest.Id == 680)\r
+                {\r
+                    count.NowArray[0] += items.Count(spec => spec.Type == 21);\r
+                    count.NowArray[1] += items.Count(spec => spec.Type == 12 || spec.Type == 13);\r
                     NeedSave = true;\r
-            }\r
-            if (_quests.TryGetValue(680, out var q680))\r
-            {\r
-                q680.Count.NowArray[0] += items.Count(spec => spec.Type == 21);\r
-                q680.Count.NowArray[1] += items.Count(spec => spec.Type == 12 || spec.Type == 13);\r
-                NeedSave = true;\r
+                }\r
             }\r
         }\r
 \r
index 0ef66cb..575c84a 100644 (file)
@@ -65,86 +65,6 @@ namespace KancolleSniffer.Model
         Quarterly\r
     }\r
 \r
-    public class QuestSpec\r
-    {\r
-        public QuestInterval Interval { get; set; }\r
-        public int Max { get; set; }\r
-        public int[] MaxArray { get; set; }\r
-        public bool AdjustCount { get; set; } = true;\r
-        public int Shift { get; set; }\r
-        public int[] Material { get; set; }\r
-    }\r
-\r
-    public class QuestSortie : QuestSpec\r
-    {\r
-        public string Rank { get; set; }\r
-        public int[] Maps { get; set; }\r
-\r
-        public static int CompareRank(string a, string b)\r
-        {\r
-            const string ranks = "SABCDE";\r
-            return ranks.IndexOf(a, StringComparison.Ordinal) -\r
-                   ranks.IndexOf(b, StringComparison.Ordinal);\r
-        }\r
-\r
-        public bool Check(string rank, int map, bool boss)\r
-        {\r
-            return (Rank == null || CompareRank(rank, Rank) <= 0) &&\r
-                   (Maps == null || Maps.Contains(map) && boss);\r
-        }\r
-    }\r
-\r
-    public class QuestEnemyType : QuestSpec\r
-    {\r
-        public int[] EnemyType { get; set; } = new int[0];\r
-\r
-        public int CountResult(IEnumerable<ShipStatus> enemyResult) =>\r
-            enemyResult.Count(ship => ship.NowHp == 0 && EnemyType.Contains(ship.Spec.ShipType));\r
-    }\r
-\r
-    public class QuestPractice : QuestSpec\r
-    {\r
-        public bool Win { get; set; }\r
-        public bool Check(string rank) => !Win || QuestSortie.CompareRank(rank, "B") <= 0;\r
-    }\r
-\r
-    public class QuestMission : QuestSpec\r
-    {\r
-        public int[] Ids { get; set; }\r
-        public bool Check(int id) => Ids == null || Ids.Contains(id);\r
-    }\r
-\r
-    public class QuestDestroyItem : QuestSpec\r
-    {\r
-        public int[] Types { get; set; }\r
-        public int[] Ids { get; set; }\r
-\r
-        public bool Count(QuestCount count, ItemSpec[] specs)\r
-        {\r
-            if (count.NowArray == null)\r
-            {\r
-                var num = specs.Count(spec => Types?.Contains(spec.Type) ?? (Ids?.Contains(spec.Id) ?? true));\r
-                count.Now += num;\r
-                return num > 0;\r
-            }\r
-            if (Types == null && Ids == null)\r
-                return false;\r
-            var result = false;\r
-            for (var i = 0; i < count.NowArray.Length; i++)\r
-            {\r
-                var num = specs.Count(spec => Types != null ? Types[i] == spec.Type : Ids[i] == spec.Id);\r
-                count.NowArray[i] += num;\r
-                if (num > 0)\r
-                    result = true;\r
-            }\r
-            return result;\r
-        }\r
-    }\r
-\r
-    public class QuestPowerUp : QuestSpec\r
-    {\r
-    }\r
-\r
     public class QuestInfo : IHaveState\r
     {\r
         private readonly SortedDictionary<int, QuestStatus> _quests = new SortedDictionary<int, QuestStatus>();\r
diff --git a/KancolleSniffer/Model/QuestSpec.cs b/KancolleSniffer/Model/QuestSpec.cs
new file mode 100644 (file)
index 0000000..9aac102
--- /dev/null
@@ -0,0 +1,100 @@
+// Copyright (C) 2019 Kazuhiro Fujieda <fujieda@users.osdn.me>\r
+//\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
+//    http://www.apache.org/licenses/LICENSE-2.0\r
+//\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.Linq;\r
+\r
+namespace KancolleSniffer.Model\r
+{\r
+    public class QuestSpec\r
+    {\r
+        public QuestInterval Interval { get; set; }\r
+        public int Max { get; set; }\r
+        public int[] MaxArray { get; set; }\r
+        public bool AdjustCount { get; set; } = true;\r
+        public int Shift { get; set; }\r
+        public int[] Material { get; set; }\r
+    }\r
+\r
+    public class QuestSortie : QuestSpec\r
+    {\r
+        public string Rank { get; set; }\r
+        public int[] Maps { get; set; }\r
+\r
+        public static int CompareRank(string a, string b)\r
+        {\r
+            const string ranks = "SABCDE";\r
+            return ranks.IndexOf(a, StringComparison.Ordinal) -\r
+                   ranks.IndexOf(b, StringComparison.Ordinal);\r
+        }\r
+\r
+        public bool Check(string rank, int map, bool boss)\r
+        {\r
+            return (Rank == null || CompareRank(rank, Rank) <= 0) &&\r
+                   (Maps == null || Maps.Contains(map) && boss);\r
+        }\r
+    }\r
+\r
+    public class QuestEnemyType : QuestSpec\r
+    {\r
+        public int[] EnemyType { get; set; } = new int[0];\r
+\r
+        public int CountResult(IEnumerable<ShipStatus> enemyResult) =>\r
+            enemyResult.Count(ship => ship.NowHp == 0 && EnemyType.Contains(ship.Spec.ShipType));\r
+    }\r
+\r
+    public class QuestPractice : QuestSpec\r
+    {\r
+        public bool Win { get; set; }\r
+        public bool Check(string rank) => !Win || QuestSortie.CompareRank(rank, "B") <= 0;\r
+    }\r
+\r
+    public class QuestMission : QuestSpec\r
+    {\r
+        public int[] Ids { get; set; }\r
+        public bool Check(int id) => Ids == null || Ids.Contains(id);\r
+    }\r
+\r
+    public class QuestDestroyItem : QuestSpec\r
+    {\r
+        public int[] Types { get; set; }\r
+        public int[] Ids { get; set; }\r
+\r
+        public bool Count(QuestCount count, ItemSpec[] specs)\r
+        {\r
+            if (count.NowArray == null)\r
+            {\r
+                var num = specs.Count(spec => Types?.Contains(spec.Type) ?? (Ids?.Contains(spec.Id) ?? true));\r
+                count.Now += num;\r
+                return num > 0;\r
+            }\r
+            if (Types == null && Ids == null)\r
+                return false;\r
+            var result = false;\r
+            for (var i = 0; i < count.NowArray.Length; i++)\r
+            {\r
+                var num = specs.Count(spec => Types != null ? Types[i] == spec.Type : Ids[i] == spec.Id);\r
+                count.NowArray[i] += num;\r
+                if (num > 0)\r
+                    result = true;\r
+            }\r
+            return result;\r
+        }\r
+    }\r
+\r
+    public class QuestPowerUp : QuestSpec\r
+    {\r
+    }\r
+}
\ No newline at end of file