コミットメタ情報

リビジョン5a3b2c1138c35e5df8bb6dd205aac8acdbd473f2 (tree)
日時2018-05-21 21:31:16
作者Kazuhiro Fujieda <fujieda@user...>
コミッターKazuhiro Fujieda

ログメッセージ

朝5時にデイリー以外の消さなくてもいい任務が消えるのを直す

変更サマリ

差分

--- a/KancolleSniffer.Test/QuestInfoTest.cs
+++ b/KancolleSniffer.Test/QuestInfoTest.cs
@@ -115,7 +115,7 @@ namespace KancolleSniffer.Test
115115 }
116116
117117 [TestMethod]
118- public void ResetQuest()
118+ public void ResetQuestCount()
119119 {
120120 var queue = new Queue<DateTime>(new[]
121121 {
@@ -148,6 +148,36 @@ namespace KancolleSniffer.Test
148148 PAssert.That(() => status.QuestCountList.Length == 0); // クォータリーが消える
149149 }
150150
151+ [TestMethod]
152+ public void ResetQuestList()
153+ {
154+ var queue = new Queue<DateTime>(new[]
155+ {
156+ new DateTime(2017, 11, 1, 5, 0, 0), new DateTime(2017, 11, 6, 5, 0, 0),
157+ new DateTime(2017, 12, 1, 5, 0, 0)
158+ });
159+ var questInfo = new QuestInfo(null, null, () => queue.Dequeue());
160+ var status = new Status
161+ {
162+ QuestList = new[]
163+ {
164+ new QuestStatus{Id = 201, Category = 2}, new QuestStatus{Id = 213, Category = 2},
165+ new QuestStatus{Id = 265, Category = 2}, new QuestStatus{Id = 822, Category = 8}
166+ },
167+ QuestLastReset = new DateTime(2017, 10, 31, 5, 0, 0)
168+ };
169+ questInfo.LoadState(status);
170+ questInfo.InspectQuestList(CreateQuestList(new int[0]));
171+ questInfo.SaveState(status);
172+ PAssert.That(() => status.QuestList.Select(q => q.Id).SequenceEqual(new []{213, 822})); // デイリーとマンスリーが消える
173+ questInfo.InspectQuestList(CreateQuestList(new int[0]));
174+ questInfo.SaveState(status);
175+ PAssert.That(() => status.QuestList.Select(q => q.Id).SequenceEqual(new []{822})); // ウィークリーが消える
176+ questInfo.InspectQuestList(CreateQuestList(new int[0]));
177+ questInfo.SaveState(status);
178+ PAssert.That(() => status.QuestList.Length == 0); // クォータリーが消える
179+ }
180+
151181 private JsonObject Js(object obj) => JsonObject.CreateJsonObject(obj);
152182
153183 private object CreateQuestList(int[] ids) => Js(new
--- a/KancolleSniffer/QuestInfo.cs
+++ b/KancolleSniffer/QuestInfo.cs
@@ -487,22 +487,36 @@ namespace KancolleSniffer
487487 var daily = now.Date.AddHours(5);
488488 if (!(_lastReset < daily && daily <= now))
489489 return;
490- _quests.Clear(); // 前日に未消化のデイリーを消す。
490+ RemoveQuest(QuestInterval.Daily);
491491 _countList.Remove(QuestInterval.Daily);
492492 var weekly = now.Date.AddDays(-((6 + (int)now.DayOfWeek) % 7)).AddHours(5);
493493 if (_lastReset < weekly && weekly <= now)
494+ {
495+ RemoveQuest(QuestInterval.Weekly);
494496 _countList.Remove(QuestInterval.Weekly);
497+ }
495498 var monthly = new DateTime(now.Year, now.Month, 1, 5, 0, 0);
496499 if (_lastReset < monthly && monthly <= now)
500+ {
501+ RemoveQuest(QuestInterval.Monthly);
497502 _countList.Remove(QuestInterval.Monthly);
503+ }
498504 var season = now.Month / 3;
499505 var quarterly = new DateTime(now.Year - (season == 0 ? 1 : 0), (season == 0 ? 12 : season * 3), 1, 5, 0, 0);
500506 if (_lastReset < quarterly && quarterly <= now)
507+ {
508+ RemoveQuest(QuestInterval.Quarterly);
501509 _countList.Remove(QuestInterval.Quarterly);
510+ }
502511 _lastReset = now;
503512 NeedSave = true;
504513 }
505514
515+ private void RemoveQuest(QuestInterval interval)
516+ {
517+ foreach (var id in (from kv in _quests where kv.Value.Count.Spec.Interval == interval select kv.Key).ToArray())
518+ _quests.Remove(id);
519+ }
506520
507521 private int _map;
508522 private bool _boss;
旧リポジトリブラウザで表示