• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisionbdea6a71b3c92da88ed2ca8e80fdcb4ba95bce5b (tree)
Zeit2020-03-03 21:14:04
AutorKazuhiro Fujieda <fujieda@user...>
CommiterKazuhiro Fujieda

Log Message

精鋭「十九駆」、躍り出る!のカウンターを実装する

Ändern Zusammenfassung

Diff

--- a/KancolleSniffer.Test/QuestCounterTest.cs
+++ b/KancolleSniffer.Test/QuestCounterTest.cs
@@ -1046,6 +1046,45 @@ namespace KancolleSniffer.Test
10461046 }
10471047
10481048 /// <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>
10491088 /// 280と854以降を同時に遂行していると854以降がカウントされないことがある
10501089 /// </summary>
10511090 [TestMethod]
--- a/KancolleSniffer.Test/QuestInfoTest.cs
+++ b/KancolleSniffer.Test/QuestInfoTest.cs
@@ -31,7 +31,7 @@ namespace KancolleSniffer.Test
3131 var queue = new Queue<DateTime>(new[]
3232 {
3333 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)
3535 });
3636 var questInfo = new QuestInfo(() => queue.Dequeue());
3737 var status = new Status
@@ -39,7 +39,8 @@ namespace KancolleSniffer.Test
3939 QuestCountList = new[]
4040 {
4141 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}}
4344 },
4445 QuestLastReset = new DateTime(2017, 10, 31, 5, 0, 0)
4546 };
@@ -47,16 +48,16 @@ namespace KancolleSniffer.Test
4748 questInfo.InspectQuestList(CreateQuestList(new[] {201}));
4849 questInfo.SaveState(status);
4950 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})); // デイリーとマンスリーが消える
5252 questInfo.InspectQuestList(CreateQuestList(new[] {201}));
5353 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})); // クォータリーが消える
5758 questInfo.InspectQuestList(CreateQuestList(new[] {201}));
5859 questInfo.SaveState(status);
59- PAssert.That(() => status.QuestCountList.Length == 0); // クォータリーが消える
60+ PAssert.That(() => status.QuestCountList.Length == 0); // イヤーリーが消える
6061 }
6162
6263 [TestMethod]
--- a/KancolleSniffer/Model/QuestCountList.cs
+++ b/KancolleSniffer/Model/QuestCountList.cs
@@ -23,6 +23,7 @@ namespace KancolleSniffer.Model
2323 private const QuestInterval Weekly = QuestInterval.Weekly;
2424 private const QuestInterval Monthly = QuestInterval.Monthly;
2525 private const QuestInterval Quarterly = QuestInterval.Quarterly;
26+ private const QuestInterval Yearly = QuestInterval.Yearly;
2627
2728 /// <summary>
2829 /// このテーブルは七四式電子観測儀を参考に作成した。
@@ -71,6 +72,7 @@ namespace KancolleSniffer.Model
7172 {888, new QuestSortie {Interval = Quarterly, MaxArray = new[] {1, 1, 1}, Rank = "S", Maps = new[] {51, 53, 54}, Material = new[] {0, 0, 0, 0}}}, // 888: 新編成「三川艦隊」、鉄底海峡に突入せよ!
7273 {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: 泊地周辺海域の安全確保を徹底せよ!
7374 {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: 精鋭「十九駆」、躍り出る!
7476
7577 {303, new QuestPractice {Interval = Daily, Max = 3, Rank = "E", Material = new[] {1, 0, 0, 0}}}, // 303: 「演習」で練度向上!
7678 {304, new QuestPractice {Interval = Daily, Max = 5, Rank = "B", Material = new[] {0, 0, 1, 0}}}, // 304: 「演習」で他提督を圧倒せよ!
--- a/KancolleSniffer/Model/QuestCounter.cs
+++ b/KancolleSniffer/Model/QuestCounter.cs
@@ -313,6 +313,8 @@ namespace KancolleSniffer.Model
313313 return specs.Names.Count("陽炎", "不知火", "霰", "霞") == 4;
314314 case 339:
315315 return specs.Names.Count("磯波", "浦波", "綾波", "敷波") == 4;
316+ case 904:
317+ return specs.Names.Count("綾波改二", "敷波改二") == 2;
316318 default:
317319 return true;
318320 }
--- a/KancolleSniffer/Model/QuestInfo.cs
+++ b/KancolleSniffer/Model/QuestInfo.cs
@@ -62,7 +62,8 @@ namespace KancolleSniffer.Model
6262 Daily,
6363 Weekly,
6464 Monthly,
65- Quarterly
65+ Quarterly,
66+ Yearly
6667 }
6768
6869 public class QuestInfo : IHaveState
@@ -117,7 +118,7 @@ namespace KancolleSniffer.Model
117118 private readonly QuestInterval[] _intervals =
118119 {
119120 QuestInterval.Daily, QuestInterval.Weekly, QuestInterval.Monthly,
120- QuestInterval.Other, QuestInterval.Quarterly
121+ QuestInterval.Other, QuestInterval.Quarterly, QuestInterval.Yearly
121122 };
122123
123124 private readonly int[] _progress = {0, 50, 80};
@@ -194,45 +195,37 @@ namespace KancolleSniffer.Model
194195 private void ResetQuests()
195196 {
196197 _now = _nowFunc();
197- if (!CrossBoundary(LastMorning))
198+ if (!CrossBoundary(QuestInterval.Daily))
198199 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+ }
204207 _lastReset = _now;
205208 NeedSave = true;
206209 }
207210
208211 private DateTime LastMorning => _now.Date.AddDays(_now.Hour < 5 ? -1 : 0).AddHours(5);
209212
210- private void ResetWeekly()
213+ private bool CrossBoundary(QuestInterval interval)
211214 {
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+ };
216225 }
217226
218227 private DateTime LastMonday => _now.Date.AddDays(-((6 + (int)_now.DayOfWeek) % 7));
219228
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-
236229 private DateTime QuarterlyBoundary =>
237230 _now.Month / 3 == 0
238231 ? new DateTime(_now.Year - 1, 12, 1)
@@ -247,12 +240,19 @@ namespace KancolleSniffer.Model
247240 {
248241 foreach (var id in
249242 (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)
252244 select kv.Key).ToArray())
253245 _quests.Remove(id);
254246 }
255247
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+
256256 public void InspectStop(string request)
257257 {
258258 var values = HttpUtility.ParseQueryString(request);
@@ -294,5 +294,4 @@ namespace KancolleSniffer.Model
294294 }
295295 }
296296 }
297-
298297 }
\ No newline at end of file