X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=KancolleSniffer%2FModel%2FQuestCounter.cs;h=db979b96b4a2249b8feb617ae6644729431fd947;hb=44b9e6f019853b7d6ec83df56b71ffb6d8a20ea9;hp=339b3197e833e1530403a3f05c082e270d476320;hpb=02003d8e55d23de3558d09294841ce953de10964;p=kancollesniffer%2FKancolleSniffer.git diff --git a/KancolleSniffer/Model/QuestCounter.cs b/KancolleSniffer/Model/QuestCounter.cs index 339b319..db979b9 100644 --- a/KancolleSniffer/Model/QuestCounter.cs +++ b/KancolleSniffer/Model/QuestCounter.cs @@ -115,17 +115,19 @@ namespace KancolleSniffer.Model { if (NowArray == null) return ""; - if (Spec is QuestSortie spec && spec.Maps != null && spec.MaxArray != null) + switch (Spec) { - return string.Join(" ", spec.Maps.Zip(NowArray, (map, n) => $"{MapString(map)}:{n}")); + case QuestSortie sortie when sortie.Maps != null && sortie.MaxArray != null: + return string.Join(" ", sortie.Maps.Zip(NowArray, (map, n) => $"{MapString(map)}:{n}")); + case QuestMission mission when mission.Ids != null: + return string.Join(" ", mission.Names.Zip(NowArray, (name, n) => $"{name}{n}")); + default: + return string.Join(" ", (Id switch + { + 688 => new[] {"艦戦", "艦爆", "艦攻", "水偵"}, + _ => new string[0] + }).Zip(NowArray, (entry, n) => $"{entry}{n}")); } - return string.Join(" ", (Id switch - { - 426 => new[] {"警備任務", "対潜警戒任務", "海上護衛任務", "強硬偵察任務"}, - 428 => new[] {"対潜警戒任務", "海峡警備行動", "長時間対潜警戒"}, - 688 => new[] {"艦戦", "艦爆", "艦攻", "水偵"}, - _ => new string[0] - }).Zip(NowArray, (entry, n) => $"{entry}{n}")); } public bool Cleared => NowArray?.Zip(Spec.MaxArray, (n, m) => n >= m).All(x => x) ?? @@ -135,7 +137,8 @@ namespace KancolleSniffer.Model public class QuestCounter { private readonly QuestInfo _questInfo; - private readonly ItemInfo _itemInfo; + private readonly ItemInventory _itemInventory; + private readonly ShipInventory _shipInventory; private readonly BattleInfo _battleInfo; private readonly SortedDictionary _quests; private int _map; @@ -182,11 +185,12 @@ namespace KancolleSniffer.Model } } - public QuestCounter(QuestInfo questInfo, ItemInfo itemInfo, BattleInfo battleInfo) + public QuestCounter(QuestInfo questInfo, ItemInventory itemInventory, ShipInventory shipInventory, BattleInfo battleInfo) { _questInfo = questInfo; _quests = questInfo.QuestDictionary; - _itemInfo = itemInfo; + _itemInventory = itemInventory; + _shipInventory = shipInventory; _battleInfo = battleInfo; } @@ -205,14 +209,20 @@ namespace KancolleSniffer.Model public void InspectMapNext(dynamic json) { _map = (int)json.api_maparea_id * 10 + (int)json.api_mapinfo_no; + var cell = json.api_no() ? (int)json.api_no : 0; if (_map == 72) { - var cell = json.api_no() ? (int)json.api_no : 0; - _map *= 10; if (cell == 7) - _map++; - if (cell == 15) - _map += 2; + _map = 721; + else if (cell == 15) + _map = 722; + } + if (_map == 73) + { + if (cell == 5) + _map = 731; + else if (cell == 18) + _map = 732; } _boss = (int)json.api_event_id == 5; @@ -220,7 +230,7 @@ namespace KancolleSniffer.Model return; foreach (var count in _quests.Values.Select(q => q.Count)) { - if (!(count.Spec is QuestSortie sortie)) + if (!(count.Spec is QuestSortie sortie) || sortie.Maps == null) continue; if (!FleetCheck(count.Id)) continue; @@ -298,6 +308,9 @@ namespace KancolleSniffer.Model case 284: return specs.Types.Count(type => type == 1 || type == 2) >= 3 && specs.Types.Intersect(new[] {3, 4, 7, 21}).Any(); + case 840: + return new[] {3, 4, 7, 21}.Contains(specs.FlagshipType) && + specs.Types.Count(type => type == 2 || type == 1) >= 3; case 861: return specs.Types.Count(s => s == 10 || s == 22) == 2; case 862: @@ -311,8 +324,23 @@ namespace KancolleSniffer.Model return specs.Names.Count("鳥海", "青葉", "衣笠", "加古", "古鷹", "天龍", "夕張") >= 4; case 894: return specs.Specs.Any(spec => spec.IsAircraftCarrier); + case 903: + return specs.Flagship.Name.StartsWith("夕張改二") && + (specs.Names.Count("睦月", "如月", "弥生", "卯月", "菊月", "望月") >= 2 || specs.Names.Contains("由良改二")); + case 904: + return specs.Names.Count("綾波改二", "敷波改二") == 2; + case 905: + return specs.Types.Count(type => type == 1) >= 3 && specs.Types.Length <= 5; + case 912: + return specs.Flagship.Name.StartsWith("明石") && specs.Types.Count(type => type == 2) >= 3; + case 914: + return specs.Types.Count(type => type == 5) >= 3 && specs.Types.Count(type => type == 2) >= 1; + case 928: + return specs.Names.Count("羽黒", "足柄", "妙高", "高雄", "神風") >= 2; case 318: return specs.Types.Count(type => type == 3) >= 2; + case 329: + return specs.Types.Count(type => type == 2 || type == 1) >= 2; case 330: return specs.Flagship.IsAircraftCarrier && specs.Specs.Count(spec => spec.IsAircraftCarrier) >= 2 && @@ -321,10 +349,17 @@ namespace KancolleSniffer.Model return specs.Names.Count("陽炎", "不知火", "霰", "霞") == 4; case 339: return specs.Names.Count("磯波", "浦波", "綾波", "敷波") == 4; - case 904: - return specs.Names.Count("綾波改二", "敷波改二") == 2; - case 905: - return specs.Types.Count(type => type == 1) >= 3 && specs.Types.Length <= 5; + case 342: + var t12 = specs.Types.Count(type => type == 1 || type == 2); + return t12 >= 4 || t12 >= 3 && specs.Types.Intersect(new[] {3, 4, 7, 21}).Any(); + case 345: + return specs.Names.Count("Warspite", "金剛", "Ark Royal", "Nelson", "Jervis", "Janus") >= 4; + case 346: + return specs.Names.Count("夕雲改二", "巻雲改二", "風雲改二", "秋雲改二") == 4; + case 348: + return new[] {3, 21}.Contains(specs.FlagshipType) && + specs.Types.Skip(1).Count(type => new[] {3, 4, 21}.Contains(type)) >= 2 && + specs.Types.Count(type => type == 2) >= 2; default: return true; } @@ -402,11 +437,11 @@ namespace KancolleSniffer.Model public void CountRemodelSlot() => Increment(619); - public void InspectDestroyItem(string request, dynamic json) + public void InspectDestroyItem(string request) { var values = HttpUtility.ParseQueryString(request); var items = values["api_slotitem_ids"].Split(',') - .Select(id => _itemInfo.GetStatus(int.Parse(id)).Spec).ToArray(); + .Select(id => _itemInventory[int.Parse(id)].Spec).ToArray(); Increment(613); // 613: 資源の再利用 foreach (var quest in _quests.Values) { @@ -426,36 +461,67 @@ namespace KancolleSniffer.Model } } - public void InspectPowerUp(dynamic json) + public void InspectPowerUp(string request, dynamic json) { if ((int)json.api_powerup_flag == 0) return; + var values = HttpUtility.ParseQueryString(request); foreach (var quest in _quests.Values) { var count = quest.Count; if (!(count.Spec is QuestPowerUp)) continue; + if (quest.Id == 714 || quest.Id == 715) + { + if (ShipTypeById(values["api_id"]) != 2) + return; + var ships = values["api_id_items"].Split(',').Select(ShipTypeById).ToArray(); + var required = quest.Id == 714 ? 2 : quest.Id == 715 ? 3 : -1; + if (ships.Count(type => type == required) < 3) + return; + } + if (quest.Id == 716 || quest.Id == 717) + { + if (!new[] {3, 4, 21}.Contains(ShipTypeById(values["api_id"]))) + return; + var ships = values["api_id_items"].Split(',').Select(ShipTypeById).ToArray(); + if (quest.Id == 716) + { + if (ships.Count(type => new[] {3, 4, 21}.Contains(type)) < 3) + return; + } + else + { + if (ships.Count(type => new[] {5, 6}.Contains(type)) < 3) + return; + } + } Increment(count); } } - public void Increment(QuestCount count) + private int ShipTypeById(string id) + { + return _shipInventory[int.Parse(id)].Spec.ShipType; + } + + private void Increment(QuestCount count) { Add(count, 1); } - public void Add(QuestCount count, int value) + private void Add(QuestCount count, int value) { count.Now += value; NeedSave = true; } - public void Increment(int id) + private void Increment(int id) { Add(id, 1); } - public void Add(int id, int value) + private void Add(int id, int value) { if (!_quests.TryGetValue(id, out var quest)) return; @@ -463,7 +529,7 @@ namespace KancolleSniffer.Model NeedSave = true; } - public void IncrementNth(QuestCount count, int n) + private void IncrementNth(QuestCount count, int n) { count.NowArray[n]++; NeedSave = true;