Revision | bdea6a71b3c92da88ed2ca8e80fdcb4ba95bce5b (tree) |
---|---|
Zeit | 2020-03-03 21:14:04 |
Autor | Kazuhiro Fujieda <fujieda@user...> |
Commiter | Kazuhiro Fujieda |
精鋭「十九駆」、躍り出る!のカウンターを実装する
@@ -1046,6 +1046,45 @@ namespace KancolleSniffer.Test | ||
1046 | 1046 | } |
1047 | 1047 | |
1048 | 1048 | /// <summary> |
1049 | + /// 904: 精鋭「十九駆」、躍り出る! | |
1050 | + /// </summary> | |
1051 | + [TestMethod] | |
1052 | + public void BattleResult_904() | |
1053 | + { | |
1054 | + var count = InjectQuest(904); | |
1055 | + _battleInfo.InjectResultStatus( | |
1056 | + new []{ShipStatus("綾波改二"), ShipStatus("敷波")}, | |
1057 | + new ShipStatus[0], new ShipStatus[0], new ShipStatus[0]); | |
1058 | + | |
1059 | + InjectMapNext(25, 5); | |
1060 | + InjectBattleResult("S"); | |
1061 | + PAssert.That(() => count.NowArray.SequenceEqual(new[] {0, 0, 0, 0}), "敷波はカウントしない"); | |
1062 | + | |
1063 | + _battleInfo.Result.Friend.Main[1] = ShipStatus("敷波改二"); | |
1064 | + InjectBattleResult("A"); | |
1065 | + PAssert.That(() => count.NowArray.SequenceEqual(new[] {0, 0, 0, 0}), "A勝利はカウントしない"); | |
1066 | + | |
1067 | + InjectBattleResult("S"); | |
1068 | + PAssert.That(() => count.NowArray.SequenceEqual(new[] {1, 0, 0, 0}), "2-5"); | |
1069 | + | |
1070 | + InjectMapNext(34, 4); | |
1071 | + InjectBattleResult("S"); | |
1072 | + PAssert.That(() => count.NowArray.SequenceEqual(new[] {1, 0, 0, 0}), "ボス以外はカウントしない"); | |
1073 | + | |
1074 | + InjectMapNext(34, 5); | |
1075 | + InjectBattleResult("S"); | |
1076 | + PAssert.That(() => count.NowArray.SequenceEqual(new[] {1, 1, 0, 0}), "3-4"); | |
1077 | + | |
1078 | + InjectMapNext(45, 5); | |
1079 | + InjectBattleResult("S"); | |
1080 | + PAssert.That(() => count.NowArray.SequenceEqual(new[] {1, 1, 1, 0}), "4-5"); | |
1081 | + | |
1082 | + InjectMapNext(53, 5); | |
1083 | + InjectBattleResult("S"); | |
1084 | + PAssert.That(() => count.NowArray.SequenceEqual(new[] {1, 1, 1, 1}), "5-3"); | |
1085 | + } | |
1086 | + | |
1087 | + /// <summary> | |
1049 | 1088 | /// 280と854以降を同時に遂行していると854以降がカウントされないことがある |
1050 | 1089 | /// </summary> |
1051 | 1090 | [TestMethod] |
@@ -31,7 +31,7 @@ namespace KancolleSniffer.Test | ||
31 | 31 | var queue = new Queue<DateTime>(new[] |
32 | 32 | { |
33 | 33 | new DateTime(2017, 11, 1, 5, 0, 0), new DateTime(2017, 11, 6, 5, 0, 0), |
34 | - new DateTime(2017, 12, 1, 5, 0, 0) | |
34 | + new DateTime(2017, 12, 1, 5, 0, 0), new DateTime(2018, 2, 1, 5, 0, 0) | |
35 | 35 | }); |
36 | 36 | var questInfo = new QuestInfo(() => queue.Dequeue()); |
37 | 37 | var status = new Status |
@@ -39,7 +39,8 @@ namespace KancolleSniffer.Test | ||
39 | 39 | QuestCountList = new[] |
40 | 40 | { |
41 | 41 | new QuestCount {Id = 201, Now = 1}, new QuestCount {Id = 213, Now = 1}, |
42 | - new QuestCount {Id = 265, Now = 1}, new QuestCount {Id = 822, Now = 1} | |
42 | + new QuestCount {Id = 265, Now = 1}, new QuestCount {Id = 822, Now = 1}, | |
43 | + new QuestCount {Id = 904, NowArray = new[] {1, 1, 1, 1}} | |
43 | 44 | }, |
44 | 45 | QuestLastReset = new DateTime(2017, 10, 31, 5, 0, 0) |
45 | 46 | }; |
@@ -47,16 +48,16 @@ namespace KancolleSniffer.Test | ||
47 | 48 | questInfo.InspectQuestList(CreateQuestList(new[] {201})); |
48 | 49 | questInfo.SaveState(status); |
49 | 50 | PAssert.That(() => |
50 | - status.QuestCountList.Select(qc => new {qc.Id, qc.Now}).SequenceEqual(new[] | |
51 | - {new {Id = 213, Now = 1}, new {Id = 822, Now = 1}})); // デイリーとマンスリーが消える | |
51 | + status.QuestCountList.Select(qc => qc.Id).SequenceEqual(new[] {213, 822, 904})); // デイリーとマンスリーが消える | |
52 | 52 | questInfo.InspectQuestList(CreateQuestList(new[] {201})); |
53 | 53 | questInfo.SaveState(status); |
54 | - PAssert.That(() => | |
55 | - status.QuestCountList.Select(qc => new {qc.Id, qc.Now}).SequenceEqual(new[] | |
56 | - {new {Id = 822, Now = 1}})); // ウィークリーが消える | |
54 | + PAssert.That(() => status.QuestCountList.Select(qc => qc.Id).SequenceEqual(new[] {822, 904})); // ウィークリーが消える | |
55 | + questInfo.InspectQuestList(CreateQuestList(new[] {201})); | |
56 | + questInfo.SaveState(status); | |
57 | + PAssert.That(() => status.QuestCountList.Select(qc => qc.Id).SequenceEqual(new[] {904})); // クォータリーが消える | |
57 | 58 | questInfo.InspectQuestList(CreateQuestList(new[] {201})); |
58 | 59 | questInfo.SaveState(status); |
59 | - PAssert.That(() => status.QuestCountList.Length == 0); // クォータリーが消える | |
60 | + PAssert.That(() => status.QuestCountList.Length == 0); // イヤーリーが消える | |
60 | 61 | } |
61 | 62 | |
62 | 63 | [TestMethod] |
@@ -23,6 +23,7 @@ namespace KancolleSniffer.Model | ||
23 | 23 | private const QuestInterval Weekly = QuestInterval.Weekly; |
24 | 24 | private const QuestInterval Monthly = QuestInterval.Monthly; |
25 | 25 | private const QuestInterval Quarterly = QuestInterval.Quarterly; |
26 | + private const QuestInterval Yearly = QuestInterval.Yearly; | |
26 | 27 | |
27 | 28 | /// <summary> |
28 | 29 | /// このテーブルは七四式電子観測儀を参考に作成した。 |
@@ -71,6 +72,7 @@ namespace KancolleSniffer.Model | ||
71 | 72 | {888, new QuestSortie {Interval = Quarterly, MaxArray = new[] {1, 1, 1}, Rank = "S", Maps = new[] {51, 53, 54}, Material = new[] {0, 0, 0, 0}}}, // 888: 新編成「三川艦隊」、鉄底海峡に突入せよ! |
72 | 73 | {893, new QuestSortie {Interval = Quarterly, MaxArray = new[] {3, 3, 3, 3}, Rank = "S", Maps = new[] {15, 71, 721, 722}, Material = new[] {0, 0, 0, 0}}}, // 893: 泊地周辺海域の安全確保を徹底せよ! |
73 | 74 | {894, new QuestSortie {Interval = Quarterly, MaxArray = new[] {1, 1, 1, 1, 1}, Rank = "S", Maps = new[] {13, 14, 21, 22, 23}, Material = new[] {0, 0, 0, 0}}}, // 894: 空母戦力の投入による兵站線戦闘哨戒 |
75 | + {904, new QuestSortie {Interval = Yearly, MaxArray = new[] {1, 1, 1, 1}, Rank = "S", Maps = new[] {25, 34, 45, 53}, Material = new[] {0, 8, 10, 4}}}, // 904: 精鋭「十九駆」、躍り出る! | |
74 | 76 | |
75 | 77 | {303, new QuestPractice {Interval = Daily, Max = 3, Rank = "E", Material = new[] {1, 0, 0, 0}}}, // 303: 「演習」で練度向上! |
76 | 78 | {304, new QuestPractice {Interval = Daily, Max = 5, Rank = "B", Material = new[] {0, 0, 1, 0}}}, // 304: 「演習」で他提督を圧倒せよ! |
@@ -313,6 +313,8 @@ namespace KancolleSniffer.Model | ||
313 | 313 | return specs.Names.Count("陽炎", "不知火", "霰", "霞") == 4; |
314 | 314 | case 339: |
315 | 315 | return specs.Names.Count("磯波", "浦波", "綾波", "敷波") == 4; |
316 | + case 904: | |
317 | + return specs.Names.Count("綾波改二", "敷波改二") == 2; | |
316 | 318 | default: |
317 | 319 | return true; |
318 | 320 | } |
@@ -62,7 +62,8 @@ namespace KancolleSniffer.Model | ||
62 | 62 | Daily, |
63 | 63 | Weekly, |
64 | 64 | Monthly, |
65 | - Quarterly | |
65 | + Quarterly, | |
66 | + Yearly | |
66 | 67 | } |
67 | 68 | |
68 | 69 | public class QuestInfo : IHaveState |
@@ -117,7 +118,7 @@ namespace KancolleSniffer.Model | ||
117 | 118 | private readonly QuestInterval[] _intervals = |
118 | 119 | { |
119 | 120 | QuestInterval.Daily, QuestInterval.Weekly, QuestInterval.Monthly, |
120 | - QuestInterval.Other, QuestInterval.Quarterly | |
121 | + QuestInterval.Other, QuestInterval.Quarterly, QuestInterval.Yearly | |
121 | 122 | }; |
122 | 123 | |
123 | 124 | private readonly int[] _progress = {0, 50, 80}; |
@@ -194,45 +195,37 @@ namespace KancolleSniffer.Model | ||
194 | 195 | private void ResetQuests() |
195 | 196 | { |
196 | 197 | _now = _nowFunc(); |
197 | - if (!CrossBoundary(LastMorning)) | |
198 | + if (!CrossBoundary(QuestInterval.Daily)) | |
198 | 199 | return; |
199 | - RemoveQuest(QuestInterval.Daily); | |
200 | - _countList.Remove(QuestInterval.Daily); | |
201 | - ResetWeekly(); | |
202 | - ResetMonthly(); | |
203 | - ResetQuarterly(); | |
200 | + foreach (var interval in (QuestInterval[])typeof(QuestInterval).GetEnumValues()) | |
201 | + { | |
202 | + if (!CrossBoundary(interval)) | |
203 | + continue; | |
204 | + RemoveQuest(interval); | |
205 | + _countList.Remove(interval); | |
206 | + } | |
204 | 207 | _lastReset = _now; |
205 | 208 | NeedSave = true; |
206 | 209 | } |
207 | 210 | |
208 | 211 | private DateTime LastMorning => _now.Date.AddDays(_now.Hour < 5 ? -1 : 0).AddHours(5); |
209 | 212 | |
210 | - private void ResetWeekly() | |
213 | + private bool CrossBoundary(QuestInterval interval) | |
211 | 214 | { |
212 | - if (!CrossBoundary(LastMonday.AddHours(5))) | |
213 | - return; | |
214 | - RemoveQuest(QuestInterval.Weekly); | |
215 | - _countList.Remove(QuestInterval.Weekly); | |
215 | + return interval switch | |
216 | + { | |
217 | + QuestInterval.Other => false, | |
218 | + QuestInterval.Daily => CrossBoundary(LastMorning), | |
219 | + QuestInterval.Weekly => CrossBoundary(LastMonday.AddHours(5)), | |
220 | + QuestInterval.Monthly => CrossBoundary(new DateTime(_now.Year, _now.Month, 1, 5, 0, 0)), | |
221 | + QuestInterval.Quarterly => CrossBoundary(QuarterlyBoundary.AddHours(5)), | |
222 | + QuestInterval.Yearly => CrossBoundary(new DateTime(_now.Year, 2, 1, 5, 0, 0)), | |
223 | + _ => false | |
224 | + }; | |
216 | 225 | } |
217 | 226 | |
218 | 227 | private DateTime LastMonday => _now.Date.AddDays(-((6 + (int)_now.DayOfWeek) % 7)); |
219 | 228 | |
220 | - private void ResetMonthly() | |
221 | - { | |
222 | - if (!CrossBoundary(new DateTime(_now.Year, _now.Month, 1, 5, 0, 0))) | |
223 | - return; | |
224 | - RemoveQuest(QuestInterval.Monthly); | |
225 | - _countList.Remove(QuestInterval.Monthly); | |
226 | - } | |
227 | - | |
228 | - private void ResetQuarterly() | |
229 | - { | |
230 | - if (!CrossBoundary(QuarterlyBoundary.AddHours(5))) | |
231 | - return; | |
232 | - RemoveQuest(QuestInterval.Quarterly); | |
233 | - _countList.Remove(QuestInterval.Quarterly); | |
234 | - } | |
235 | - | |
236 | 229 | private DateTime QuarterlyBoundary => |
237 | 230 | _now.Month / 3 == 0 |
238 | 231 | ? new DateTime(_now.Year - 1, 12, 1) |
@@ -247,12 +240,19 @@ namespace KancolleSniffer.Model | ||
247 | 240 | { |
248 | 241 | foreach (var id in |
249 | 242 | (from kv in _quests |
250 | - where kv.Value.Count.Spec.Interval == interval || // 輸送5と空母3はカウンタを見ないとデイリーにならない | |
251 | - kv.Value.Interval == interval | |
243 | + where MatchInterval(kv.Value, interval) | |
252 | 244 | select kv.Key).ToArray()) |
253 | 245 | _quests.Remove(id); |
254 | 246 | } |
255 | 247 | |
248 | + private bool MatchInterval(QuestStatus quest, QuestInterval interval) | |
249 | + { | |
250 | + var i = quest.Count.Spec.Interval; | |
251 | + return i == QuestInterval.Other // 定期任務の定義がない | |
252 | + ? quest.Interval == interval | |
253 | + : i == interval; | |
254 | + } | |
255 | + | |
256 | 256 | public void InspectStop(string request) |
257 | 257 | { |
258 | 258 | var values = HttpUtility.ParseQueryString(request); |
@@ -294,5 +294,4 @@ namespace KancolleSniffer.Model | ||
294 | 294 | } |
295 | 295 | } |
296 | 296 | } |
297 | - | |
298 | 297 | } |
\ No newline at end of file |