コミットメタ情報

リビジョン8636c884ea8a71a9a35ef76c82872a08f986c40b (tree)
日時2018-04-03 22:21:37
作者Kazuhiro Fujieda <fujieda@user...>
コミッターKazuhiro Fujieda

ログメッセージ

装備を破棄する任務のカウンターの追加を容易にする

変更サマリ

差分

--- a/KancolleSniffer.Test/QuestInfoTest.cs
+++ b/KancolleSniffer.Test/QuestInfoTest.cs
@@ -998,26 +998,33 @@ namespace KancolleSniffer.Test
998998 new ItemSpec {Id = 28, Name = "22号水上電探", Type = 12},
999999 new ItemSpec {Id = 31, Name = "32号水上電探", Type = 13}
10001000 });
1001- itemInfo.InjectItems(new[] {1, 37, 19, 4, 11, 75, 7, 25, 13, 20, 28, 31});
1002- questInfo.InspectQuestList(CreateQuestList(new[] {613, 638, 663, 673, 674, 675, 676, 677, 678, 680}));
1001+ var items = new[] {1, 37, 19, 4, 11, 75, 7, 25, 13, 20, 28, 31};
1002+ itemInfo.InjectItems(items);
1003+ questInfo.InspectQuestList(CreateQuestList(new[]
1004+ {613, 638, 663, 673, 674, 675, 676, 677, 678, 680}));
10031005 questInfo.InspectDestroyItem(
1004- "api%5Fslotitem%5Fids=1%2C2%2C3%2C4%2C5%2C6%2C7%2C8%2C9%2C10%2C11%2C12&api%5Fverno=1", null);
1005- PAssert.That(() =>
1006- questInfo.Quests.Select(q => new {q.Id, q.Count.Now}).Take(5).SequenceEqual(new[]
1007- {
1008- new {Id = 613, Now = 1}, new {Id = 638, Now = 1}, new {Id = 663, Now = 1},
1009- new {Id = 673, Now = 1}, new {Id = 674, Now = 1}
1010- }));
1011- var q675 = questInfo.Quests[5];
1012- PAssert.That(() => q675.Id == 675 && q675.Count.NowArray.SequenceEqual(new[] {2, 1}));
1013- var q676 = questInfo.Quests[6];
1014- PAssert.That(() => q676.Id == 676 && q676.Count.NowArray.SequenceEqual(new[] {1, 1, 1}));
1015- var q677 = questInfo.Quests[7];
1016- PAssert.That(() => q677.Id == 677 && q677.Count.NowArray.SequenceEqual(new[] {1, 1, 1}));
1017- var q678 = questInfo.Quests[8];
1018- PAssert.That(() => q678.Id == 678 && q678.Count.NowArray.SequenceEqual(new[] {1, 1}));
1019- var q680 = questInfo.Quests[9];
1020- PAssert.That(() => q680.Id == 680 && q680.Count.NowArray.SequenceEqual(new[] {1, 2}));
1006+ $"api%5Fslotitem%5Fids={string.Join("%2C", Enumerable.Range(1, items.Length))}&api%5Fverno=1", null);
1007+ var scalar = new[]
1008+ {
1009+ new {Id = 613, Now = 1}, new {Id = 638, Now = 1},
1010+ new {Id = 663, Now = 1}, new {Id = 673, Now = 1}, new {Id = 674, Now = 1}
1011+ };
1012+ foreach (var e in scalar)
1013+ {
1014+ var c = Array.Find(questInfo.Quests, q => q.Id == e.Id).Count;
1015+ PAssert.That(() => c.Id == e.Id && c.Now == e.Now, $"{c.Id}");
1016+ }
1017+ var array = new[]
1018+ {
1019+ new {Id = 675, NowArray = new[] {2, 1}}, new {Id = 676, NowArray = new[] {1, 1, 1}},
1020+ new {Id = 677, NowArray = new[] {1, 1, 1}}, new {Id = 678, NowArray = new[] {1, 1}},
1021+ new {Id = 680, NowArray = new[] {1, 2}}
1022+ };
1023+ foreach (var e in array)
1024+ {
1025+ var c = Array.Find(questInfo.Quests, q => q.Id == e.Id).Count;
1026+ PAssert.That(() => c.Id == e.Id && c.NowArray.SequenceEqual(e.NowArray), $"{c.Id}");
1027+ }
10211028 }
10221029
10231030 /// <summary>
--- a/KancolleSniffer/QuestInfo.cs
+++ b/KancolleSniffer/QuestInfo.cs
@@ -108,8 +108,29 @@ namespace KancolleSniffer
108108
109109 public class QuestDestroyItem : QuestSpec
110110 {
111- public int[] Items { get; set; }
112- public bool Check(int id) => Items == null || Items.Contains(id);
111+ public int[] Types { get; set; }
112+ public int[] Ids { get; set; }
113+
114+ public bool Count(QuestCount count, ItemSpec[] specs)
115+ {
116+ if (count.NowArray == null)
117+ {
118+ var num = specs.Count(spec => Types?.Contains(spec.Type) ?? (Ids?.Contains(spec.Id) ?? true));
119+ count.Now += num;
120+ return num > 0;
121+ }
122+ if (Types == null && Ids == null)
123+ return false;
124+ var result = false;
125+ for (var i = 0; i < count.NowArray.Length; i++)
126+ {
127+ var num = specs.Count(spec => Types != null ? Types[i] == spec.Type : Ids[i] == spec.Id);
128+ count.NowArray[i] += num;
129+ if (num > 0)
130+ result = true;
131+ }
132+ return result;
133+ }
113134 }
114135
115136 public class QuestPowerup : QuestSpec
@@ -281,14 +302,14 @@ namespace KancolleSniffer
281302 {619, new QuestSpec {Interval = Daily, Max = 1, Material = new[] {0, 0, 0, 1}}}, // 619: 装備の改修強化
282303
283304 {613, new QuestSpec {Interval = Weekly, Max = 24, Material = new[] {0, 0, 0, 0}}}, // 613: 資源の再利用
284- {638, new QuestDestroyItem {Interval = Weekly, Max = 6, Items = new[] {21}, Material = new[] {0, 0, 2, 1}}}, // 638: 対空機銃量産
285- {663, new QuestDestroyItem {Interval = Quarterly, Max = 10, Items = new[] {3}, Material = new[] {0, 0, 3, 0}}}, // 663: 新型艤装の継続研究
286- {673, new QuestDestroyItem {Interval = Daily, Max = 4, Items = new[] {1}, Shift = 1, Material = new[] {0, 0, 1, 0}}}, // 673: 装備開発力の整備
287- {674, new QuestDestroyItem {Interval = Daily, Max = 3, Items = new[] {21}, Shift = 2, Material = new[] {0, 1, 1, 0}}}, // 674: 工廠環境の整備
288- {675, new QuestSpec {Interval = Quarterly, MaxArray = new[] {6, 4}, Material = new[] {0, 0, 0, 0}}}, // 675: 運用装備の統合整備
289- {676, new QuestSpec {Interval = Weekly, MaxArray = new[] {3, 3, 1}, Material = new[] {0, 1, 7, 0}}}, // 676: 装備開発力の集中整備
290- {677, new QuestSpec {Interval = Weekly, MaxArray = new[] {4, 2, 3}, Material = new[] {0, 5, 0, 0}}}, // 677: 継戦支援能力の整備
291- {678, new QuestSpec {Interval = Quarterly, MaxArray = new[] {3, 5}, Material = new[] {0, 0, 8, 0}}}, // 678: 主力艦上戦闘機の更新
305+ {638, new QuestDestroyItem {Interval = Weekly, Max = 6, Types = new[] {21}, Material = new[] {0, 0, 2, 1}}}, // 638: 対空機銃量産
306+ {663, new QuestDestroyItem {Interval = Quarterly, Max = 10, Types = new[] {3}, Material = new[] {0, 0, 3, 0}}}, // 663: 新型艤装の継続研究
307+ {673, new QuestDestroyItem {Interval = Daily, Max = 4, Types = new[] {1}, Shift = 1, Material = new[] {0, 0, 1, 0}}}, // 673: 装備開発力の整備
308+ {674, new QuestDestroyItem {Interval = Daily, Max = 3, Types = new[] {21}, Shift = 2, Material = new[] {0, 1, 1, 0}}}, // 674: 工廠環境の整備
309+ {675, new QuestDestroyItem {Interval = Quarterly, MaxArray = new[] {6, 4}, Types = new[] {6, 21}, Material = new[] {0, 0, 0, 0}}}, // 675: 運用装備の統合整備
310+ {676, new QuestDestroyItem {Interval = Weekly, MaxArray = new[] {3, 3, 1}, Types = new[] {2, 4, 30}, Material = new[] {0, 1, 7, 0}}}, // 676: 装備開発力の集中整備
311+ {677, new QuestDestroyItem {Interval = Weekly, MaxArray = new[] {4, 2, 3}, Types = new[] {3, 10, 5}, Material = new[] {0, 5, 0, 0}}}, // 677: 継戦支援能力の整備
312+ {678, new QuestDestroyItem {Interval = Quarterly, MaxArray = new[] {3, 5}, Ids = new[] {19, 20}, Material = new[] {0, 0, 8, 0}}}, // 678: 主力艦上戦闘機の更新
292313 {680, new QuestSpec {Interval = Quarterly, MaxArray = new[] {4, 4}, Material = new[] {0, 0, 6, 0}}}, // 680: 対空兵装の整備拡充
293314
294315 {702, new QuestPowerup {Interval = Daily, Max = 2, Material = new[] {0, 1, 0, 0}}}, // 702: 艦の「近代化改修」を実施せよ!
@@ -801,33 +822,8 @@ namespace KancolleSniffer
801822 var count = quest.Count;
802823 if (!(count.Spec is QuestDestroyItem destroy))
803824 continue;
804- AddCount(count, items.Count(spec => destroy.Check(spec.Type)));
805- }
806- if (_quests.TryGetValue(675, out var q675))
807- {
808- q675.Count.NowArray[0] += items.Count(spec => spec.Type == 6);
809- q675.Count.NowArray[1] += items.Count(spec => spec.Type == 21);
810- NeedSave = true;
811- }
812- if (_quests.TryGetValue(676, out var q676))
813- {
814- q676.Count.NowArray[0] += items.Count(spec => spec.Type == 2);
815- q676.Count.NowArray[1] += items.Count(spec => spec.Type == 4);
816- q676.Count.NowArray[2] += items.Count(spec => spec.Type == 30);
817- NeedSave = true;
818- }
819- if (_quests.TryGetValue(677, out var q677))
820- {
821- q677.Count.NowArray[0] += items.Count(spec => spec.Type == 3);
822- q677.Count.NowArray[1] += items.Count(spec => spec.Type == 10);
823- q677.Count.NowArray[2] += items.Count(spec => spec.Type == 5);
824- NeedSave = true;
825- }
826- if (_quests.TryGetValue(678, out var q678))
827- {
828- q678.Count.NowArray[0] += items.Count(spec => spec.Id == 19);
829- q678.Count.NowArray[1] += items.Count(spec => spec.Id == 20);
830- NeedSave = true;
825+ if (destroy.Count(count, items))
826+ NeedSave = true;
831827 }
832828 if (_quests.TryGetValue(680, out var q680))
833829 {
旧リポジトリブラウザで表示