修订版 | 230f955774daf88ce397a9dcb4659ab38e182dec (tree) |
---|---|
时间 | 2020-08-30 14:58:22 |
作者 | Kazuhiro Fujieda <fujieda@user...> |
Commiter | Kazuhiro Fujieda |
questlistがすべての任務を返す仕様変更に対応する
@@ -238,10 +238,15 @@ namespace KancolleSniffer.Test | ||
238 | 238 | |
239 | 239 | private QuestCount InjectQuest(int id) |
240 | 240 | { |
241 | - _questInfo.InspectQuestList(CreateQuestList(new[] {id})); | |
241 | + InjectQuestList(new[] {id}); | |
242 | 242 | return _questInfo.Quests[0].Count; |
243 | 243 | } |
244 | 244 | |
245 | + private void InjectQuestList(int[] ids) | |
246 | + { | |
247 | + _questInfo.InspectQuestList("api_tab_id=0", CreateQuestList(ids)); | |
248 | + } | |
249 | + | |
245 | 250 | private void InjectMapStart(int map, int eventId) |
246 | 251 | { |
247 | 252 | _questCounter.InspectMapStart(CreateMap(map, eventId)); |
@@ -304,7 +309,7 @@ namespace KancolleSniffer.Test | ||
304 | 309 | { |
305 | 310 | _battleInfo = new BattleInfo(null, null, null); |
306 | 311 | _itemInfo = new ItemInfo(new ItemMaster(), new ItemInventory()); |
307 | - _questInfo = new QuestInfo(() => new DateTime(2015, 1, 1)) {AcceptMax = 10}; | |
312 | + _questInfo = new QuestInfo(() => new DateTime(2015, 1, 1)); | |
308 | 313 | _questCounter = new QuestCounter(_questInfo, _itemInfo, _battleInfo); |
309 | 314 | } |
310 | 315 |
@@ -317,7 +322,7 @@ namespace KancolleSniffer.Test | ||
317 | 322 | [TestMethod] |
318 | 323 | public void BattleResult_201_216_210_214() |
319 | 324 | { |
320 | - _questInfo.InspectQuestList(CreateQuestList(new[] {201, 216, 210, 214})); | |
325 | + InjectQuestList(new[] {201, 216, 210, 214}); | |
321 | 326 | |
322 | 327 | InjectMapStart(11, 4); |
323 | 328 | var counts = _questInfo.Quests.Select(q => q.Count).ToArray(); |
@@ -361,7 +366,7 @@ namespace KancolleSniffer.Test | ||
361 | 366 | [TestMethod] |
362 | 367 | public void BattleResult_211_212_213_218_220_221() |
363 | 368 | { |
364 | - _questInfo.InspectQuestList(CreateQuestList(new[] {211, 212, 213, 218, 220, 221})); | |
369 | + InjectQuestList(new[] {211, 212, 213, 218, 220, 221}); | |
365 | 370 | // 補給艦1隻と空母2隻 |
366 | 371 | _battleInfo.InjectResultStatus(new ShipStatus[0], new ShipStatus[0], new[] |
367 | 372 | { |
@@ -389,7 +394,7 @@ namespace KancolleSniffer.Test | ||
389 | 394 | [TestMethod] |
390 | 395 | public void BattleResult_228_230() |
391 | 396 | { |
392 | - _questInfo.InspectQuestList(CreateQuestList(new[] {228, 230})); | |
397 | + InjectQuestList(new[] {228, 230}); | |
393 | 398 | // 潜水艦3 |
394 | 399 | _battleInfo.InjectResultStatus(new ShipStatus[0], new ShipStatus[0], new[] |
395 | 400 | { |
@@ -721,7 +726,7 @@ namespace KancolleSniffer.Test | ||
721 | 726 | [TestMethod] |
722 | 727 | public void BattleResult_822_854() |
723 | 728 | { |
724 | - _questInfo.InspectQuestList(CreateQuestList(new[] {822, 854})); | |
729 | + InjectQuestList(new[] {822, 854}); | |
725 | 730 | var c822 = _questInfo.Quests[0].Count; |
726 | 731 | var c854 = _questInfo.Quests[1].Count; |
727 | 732 |
@@ -1320,7 +1325,7 @@ namespace KancolleSniffer.Test | ||
1320 | 1325 | [TestMethod] |
1321 | 1326 | public void BattleResult_280_854() |
1322 | 1327 | { |
1323 | - _questInfo.InspectQuestList(CreateQuestList(new[] {280, 854})); | |
1328 | + InjectQuestList(new[] {280, 854}); | |
1324 | 1329 | |
1325 | 1330 | _battleInfo.InjectResultStatus( |
1326 | 1331 | ShipStatusList(1, 1, 1, 1, 1, 1), new ShipStatus[0], |
@@ -1337,7 +1342,7 @@ namespace KancolleSniffer.Test | ||
1337 | 1342 | [TestMethod] |
1338 | 1343 | public void BattleResult_888_893() |
1339 | 1344 | { |
1340 | - _questInfo.InspectQuestList(CreateQuestList(new[] {888, 893})); | |
1345 | + InjectQuestList(new[] {888, 893}); | |
1341 | 1346 | |
1342 | 1347 | _battleInfo.InjectResultStatus( |
1343 | 1348 | ShipStatusList(1, 1, 1, 1, 1, 1), new ShipStatus[0], |
@@ -1358,7 +1363,7 @@ namespace KancolleSniffer.Test | ||
1358 | 1363 | [TestMethod] |
1359 | 1364 | public void PracticeResult_303_304_302_311_315() |
1360 | 1365 | { |
1361 | - _questInfo.InspectQuestList(CreateQuestList(new[] {302, 303, 304, 311, 315})); | |
1366 | + InjectQuestList(new[] {302, 303, 304, 311, 315}); | |
1362 | 1367 | |
1363 | 1368 | _battleInfo.InjectResultStatus(new[] |
1364 | 1369 | { |
@@ -1401,7 +1406,7 @@ namespace KancolleSniffer.Test | ||
1401 | 1406 | Assert.AreEqual(1, count.Now); |
1402 | 1407 | |
1403 | 1408 | count.Now = 2; |
1404 | - _questInfo.InspectQuestList(CreateQuestList(new[] {318})); | |
1409 | + InjectQuestList(new[] {318}); | |
1405 | 1410 | Assert.AreEqual(2, count.Now, "進捗調節しない"); |
1406 | 1411 | } |
1407 | 1412 |
@@ -1535,7 +1540,7 @@ namespace KancolleSniffer.Test | ||
1535 | 1540 | [TestMethod] |
1536 | 1541 | public void MissionResult_402_403_404_410_411() |
1537 | 1542 | { |
1538 | - _questInfo.InspectQuestList(CreateQuestList(new[] {402, 403, 404, 410, 411})); | |
1543 | + InjectQuestList(new[] {402, 403, 404, 410, 411}); | |
1539 | 1544 | |
1540 | 1545 | _questCounter.InspectDeck(Js( |
1541 | 1546 | new[] |
@@ -1672,7 +1677,7 @@ namespace KancolleSniffer.Test | ||
1672 | 1677 | [TestMethod] |
1673 | 1678 | public void PowerUp_503_504() |
1674 | 1679 | { |
1675 | - _questInfo.InspectQuestList(CreateQuestList(new[] {503, 504})); | |
1680 | + InjectQuestList(new[] {503, 504}); | |
1676 | 1681 | |
1677 | 1682 | _questCounter.CountNyukyo(); |
1678 | 1683 | _questCounter.CountCharge(); |
@@ -1692,7 +1697,7 @@ namespace KancolleSniffer.Test | ||
1692 | 1697 | [TestMethod] |
1693 | 1698 | public void Kousyou_605_606_607_608_609_619() |
1694 | 1699 | { |
1695 | - _questInfo.InspectQuestList(CreateQuestList(new[] {605, 606, 607, 608, 609, 619})); | |
1700 | + InjectQuestList(new[] {605, 606, 607, 608, 609, 619}); | |
1696 | 1701 | |
1697 | 1702 | _questCounter.InspectCreateItem( |
1698 | 1703 | "api_verno=1&api_item1=10&api_item2=10&api_item3=30&api_item4=10&api_multiple_flag=0"); |
@@ -1752,8 +1757,7 @@ namespace KancolleSniffer.Test | ||
1752 | 1757 | var items = new[] {1, 37, 19, 4, 11, 75, 7, 25, 13, 20, 28, 31, 35, 23, 16, 3, 121}; |
1753 | 1758 | _itemInfo.InjectItems(items); |
1754 | 1759 | var questList = new[] {613, 638, 643, 645, 653, 663, 673, 674, 675, 676, 677, 678, 680, 686, 688}; |
1755 | - _questInfo.AcceptMax = questList.Length; | |
1756 | - _questInfo.InspectQuestList(CreateQuestList(questList)); | |
1760 | + InjectQuestList(questList); | |
1757 | 1761 | _questCounter.InspectDestroyItem( |
1758 | 1762 | $"api%5Fslotitem%5Fids={string.Join("%2C", Enumerable.Range(1, items.Length))}&api%5Fverno=1", null); |
1759 | 1763 | var scalar = new[] |
@@ -1789,7 +1793,7 @@ namespace KancolleSniffer.Test | ||
1789 | 1793 | [TestMethod] |
1790 | 1794 | public void PowerUp_702_703() |
1791 | 1795 | { |
1792 | - _questInfo.InspectQuestList(CreateQuestList(new[] {702, 703})); | |
1796 | + InjectQuestList(new[] {702, 703}); | |
1793 | 1797 | _questCounter.InspectPowerUp(Js(new {api_powerup_flag = 1})); |
1794 | 1798 | PAssert.That(() => |
1795 | 1799 | _questInfo.Quests.Select(q => new {q.Id, q.Count.Now}) |
@@ -59,42 +59,12 @@ namespace KancolleSniffer.Test | ||
59 | 59 | |
60 | 60 | private void CheckQuestCountList(QuestInfo questInfo, Status status, int[] quests) |
61 | 61 | { |
62 | - questInfo.InspectQuestList(CreateQuestList(new[] {201})); | |
62 | + InspectQuestList(questInfo, new[] {201}); | |
63 | 63 | questInfo.SaveState(status); |
64 | 64 | PAssert.That(() => status.QuestCountList.Select(qc => qc.Id).SequenceEqual(quests)); |
65 | 65 | } |
66 | 66 | |
67 | 67 | [TestMethod] |
68 | - public void ResetQuestList() | |
69 | - { | |
70 | - var queue = new Queue<DateTime>(new[] | |
71 | - { | |
72 | - new DateTime(2017, 11, 1, 5, 0, 0), new DateTime(2017, 11, 6, 5, 0, 0), | |
73 | - new DateTime(2017, 12, 1, 5, 0, 0) | |
74 | - }); | |
75 | - var questInfo = new QuestInfo(() => queue.Dequeue()); | |
76 | - var status = new Status | |
77 | - { | |
78 | - QuestList = new[] | |
79 | - { | |
80 | - new QuestStatus {Id = 201, Category = 2}, new QuestStatus {Id = 213, Category = 2}, | |
81 | - new QuestStatus {Id = 265, Category = 2}, new QuestStatus {Id = 822, Category = 8} | |
82 | - }, | |
83 | - QuestLastReset = new DateTime(2017, 10, 31, 5, 0, 0) | |
84 | - }; | |
85 | - questInfo.LoadState(status); | |
86 | - questInfo.InspectQuestList(CreateQuestList(new int[0])); | |
87 | - questInfo.SaveState(status); | |
88 | - PAssert.That(() => status.QuestList.Select(q => q.Id).SequenceEqual(new[] {213, 822})); // デイリーとマンスリーが消える | |
89 | - questInfo.InspectQuestList(CreateQuestList(new int[0])); | |
90 | - questInfo.SaveState(status); | |
91 | - PAssert.That(() => status.QuestList.Select(q => q.Id).SequenceEqual(new[] {822})); // ウィークリーが消える | |
92 | - questInfo.InspectQuestList(CreateQuestList(new int[0])); | |
93 | - questInfo.SaveState(status); | |
94 | - PAssert.That(() => status.QuestList.Length == 0); // クォータリーが消える | |
95 | - } | |
96 | - | |
97 | - [TestMethod] | |
98 | 68 | public void ResetFrom0To5OClock() |
99 | 69 | { |
100 | 70 | var queue = new Queue<DateTime>(new[] |
@@ -108,7 +78,7 @@ namespace KancolleSniffer.Test | ||
108 | 78 | QuestLastReset = new DateTime(2019, 1, 20, 5, 16, 22) |
109 | 79 | }; |
110 | 80 | questInfo.LoadState(status); |
111 | - questInfo.InspectQuestList(CreateQuestList(new[] {201})); | |
81 | + InspectQuestList(questInfo, new[] {201}); | |
112 | 82 | questInfo.SaveState(status); |
113 | 83 | PAssert.That(() => status.QuestCountList.Length == 0); |
114 | 84 | } |
@@ -127,13 +97,21 @@ namespace KancolleSniffer.Test | ||
127 | 97 | QuestLastReset = new DateTime(2019, 1, 27, 5, 0, 0) |
128 | 98 | }; |
129 | 99 | questInfo.LoadState(status); |
130 | - questInfo.InspectQuestList( // 2019-1-27 10:00 | |
131 | - CreateQuestList(new[] {237})); // 【節分拡張任務】南方海域 艦隊決戦 | |
100 | + InspectQuestList(questInfo, // 2019-1-27 10:00 | |
101 | + new[] {237}); // 【節分拡張任務】南方海域 艦隊決戦 | |
132 | 102 | PAssert.That(() => questInfo.Quests[0].Id == 237); |
133 | - questInfo.InspectQuestList(CreateQuestList(new[] {201})); // 2019-1-28 05:00 | |
103 | + InspectQuestList(questInfo, new[] {201}); // 2019-1-28 05:00 | |
134 | 104 | PAssert.That(() => questInfo.Quests[0].Id == 201); |
135 | 105 | } |
136 | 106 | |
107 | + [TestMethod] | |
108 | + public void NotImplemented() | |
109 | + { | |
110 | + var questInfo = new QuestInfo(() => new DateTime(2015, 1, 1)); | |
111 | + InspectQuestList(questInfo, new[] {679}); | |
112 | + PAssert.That(() => questInfo.Quests[0].Count.Spec.Material.Length == 0); | |
113 | + } | |
114 | + | |
137 | 115 | private JsonObject Js(object obj) => new JsonObject(obj); |
138 | 116 | |
139 | 117 | private object CreateQuestList(int[] ids) => Js(new |
@@ -156,14 +134,12 @@ namespace KancolleSniffer.Test | ||
156 | 134 | }; |
157 | 135 | } |
158 | 136 | |
159 | - [TestMethod] | |
160 | - public void NotImplemented() | |
137 | + private void InspectQuestList(QuestInfo questInfo, int[] ids) | |
161 | 138 | { |
162 | - var questInfo = new QuestInfo(() => new DateTime(2015, 1, 1)); | |
163 | - questInfo.InspectQuestList(CreateQuestList(new[] {679})); | |
164 | - PAssert.That(() => questInfo.Quests[0].Count.Spec.Material.Length == 0); | |
139 | + questInfo.InspectQuestList("api_tab_id=0", CreateQuestList(ids)); | |
165 | 140 | } |
166 | 141 | |
142 | + | |
167 | 143 | /// <summary> |
168 | 144 | /// 状態をロードするときに獲得資材に特殊資材のリストを追加しない |
169 | 145 | /// </summary> |
@@ -192,35 +168,5 @@ namespace KancolleSniffer.Test | ||
192 | 168 | questInfo.LoadState(status); |
193 | 169 | PAssert.That(() => questInfo.Quests[0].Material.Length == 8); |
194 | 170 | } |
195 | - | |
196 | - /// <summary> | |
197 | - /// 任務を受領したときにNeedSaveを設定する | |
198 | - /// </summary> | |
199 | - [TestMethod] | |
200 | - public void SetNeedSaveOnStartQuest() | |
201 | - { | |
202 | - var questInfo = new QuestInfo(() => new DateTime(2019, 1, 1)); | |
203 | - // _lastResetが未設定だと必ずResetQuestsが動いてNeedSaveがtrueになる | |
204 | - questInfo.LoadState(new Status {QuestLastReset = new DateTime(2019, 1, 1)}); | |
205 | - questInfo.InspectQuestList(Js( | |
206 | - new | |
207 | - { | |
208 | - api_list = new[] | |
209 | - { | |
210 | - CreateQuest(213, 1), | |
211 | - CreateQuest(214, 1) | |
212 | - } | |
213 | - })); | |
214 | - Assert.IsFalse(questInfo.NeedSave); | |
215 | - questInfo.InspectQuestList(Js(new | |
216 | - { | |
217 | - api_list = new[] | |
218 | - { | |
219 | - CreateQuest(213, 1), | |
220 | - CreateQuest(214, 2) | |
221 | - } | |
222 | - })); | |
223 | - Assert.IsTrue(questInfo.NeedSave); | |
224 | - } | |
225 | 171 | } |
226 | 172 | } |
\ No newline at end of file |
@@ -55,7 +55,6 @@ namespace KancolleSniffer | ||
55 | 55 | this.labelMaterialCaption = new System.Windows.Forms.Label(); |
56 | 56 | this.label31 = new System.Windows.Forms.Label(); |
57 | 57 | this.labelAkashiRepair = new System.Windows.Forms.Label(); |
58 | - this.labelClearQuest = new System.Windows.Forms.Label(); | |
59 | 58 | this.dropDownButtonRepairList = new KancolleSniffer.View.DropDownButton(); |
60 | 59 | this.labelQuestCount = new System.Windows.Forms.Label(); |
61 | 60 | this.kdockPanel = new KancolleSniffer.View.KDockPanel(); |
@@ -149,19 +148,6 @@ namespace KancolleSniffer | ||
149 | 148 | this.labelAkashiRepair.TabIndex = 54; |
150 | 149 | this.labelAkashiRepair.Text = "修理"; |
151 | 150 | // |
152 | - // labelClearQuest | |
153 | - // | |
154 | - this.labelClearQuest.AutoSize = true; | |
155 | - this.labelClearQuest.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; | |
156 | - this.labelClearQuest.Location = new System.Drawing.Point(49, 340); | |
157 | - this.labelClearQuest.Name = "labelClearQuest"; | |
158 | - this.labelClearQuest.Size = new System.Drawing.Size(15, 14); | |
159 | - this.labelClearQuest.TabIndex = 55; | |
160 | - this.labelClearQuest.Text = "↺"; | |
161 | - this.labelClearQuest.Click += new System.EventHandler(this.labelClearQuest_Click); | |
162 | - this.labelClearQuest.MouseDown += new System.Windows.Forms.MouseEventHandler(this.labelClearQuest_MouseDown); | |
163 | - this.labelClearQuest.MouseUp += new System.Windows.Forms.MouseEventHandler(this.labelClearQuest_MouseUp); | |
164 | - // | |
165 | 151 | // dropDownButtonRepairList |
166 | 152 | // |
167 | 153 | this.dropDownButtonRepairList.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; |
@@ -273,7 +259,6 @@ namespace KancolleSniffer | ||
273 | 259 | this.Controls.Add(this.missionPanel); |
274 | 260 | this.Controls.Add(this.labelQuestCount); |
275 | 261 | this.Controls.Add(this.questPanel); |
276 | - this.Controls.Add(this.labelClearQuest); | |
277 | 262 | this.Controls.Add(this.labelAkashiRepair); |
278 | 263 | this.Controls.Add(this.labelAkashiRepairTimer); |
279 | 264 | this.Controls.Add(this.dropDownButtonRepairList); |
@@ -305,7 +290,6 @@ namespace KancolleSniffer | ||
305 | 290 | private System.Windows.Forms.Label labelAkashiRepairTimer; |
306 | 291 | private System.Windows.Forms.Label labelAkashiRepair; |
307 | 292 | private RepairListForMain panelRepairList; |
308 | - private System.Windows.Forms.Label labelClearQuest; | |
309 | 293 | private QuestPanel questPanel; |
310 | 294 | private System.Windows.Forms.Label labelQuestCount; |
311 | 295 | private MissionPanel missionPanel; |
@@ -428,21 +428,5 @@ namespace KancolleSniffer | ||
428 | 428 | panelRepairList.Visible = false; |
429 | 429 | dropDownButtonRepairList.BackColor = DefaultBackColor; |
430 | 430 | } |
431 | - | |
432 | - private void labelClearQuest_Click(object sender, EventArgs e) | |
433 | - { | |
434 | - Sniffer.ClearQuests(); | |
435 | - UpdateQuestList(); | |
436 | - } | |
437 | - | |
438 | - private void labelClearQuest_MouseDown(object sender, MouseEventArgs e) | |
439 | - { | |
440 | - labelClearQuest.BackColor = CustomColors.ActiveButtonColor; | |
441 | - } | |
442 | - | |
443 | - private void labelClearQuest_MouseUp(object sender, MouseEventArgs e) | |
444 | - { | |
445 | - labelClearQuest.BackColor = DefaultBackColor; | |
446 | - } | |
447 | 431 | } |
448 | 432 | } |
\ No newline at end of file |
@@ -26,7 +26,6 @@ namespace KancolleSniffer.Model | ||
26 | 26 | { |
27 | 27 | public int Id { get; set; } |
28 | 28 | public int Category { get; set; } |
29 | - public QuestInterval Interval { get; set; } | |
30 | 29 | public string Name { get; set; } |
31 | 30 | public string Detail { get; set; } |
32 | 31 | public int[] Material { get; set; } |
@@ -70,7 +69,6 @@ namespace KancolleSniffer.Model | ||
70 | 69 | |
71 | 70 | public class QuestInfo : IHaveState |
72 | 71 | { |
73 | - private readonly SortedDictionary<int, QuestStatus> _quests = new SortedDictionary<int, QuestStatus>(); | |
74 | 72 | private readonly QuestCountList _countList = new QuestCountList(); |
75 | 73 | private readonly Func<DateTime> _nowFunc = () => DateTime.Now; |
76 | 74 | private DateTime _now; |
@@ -84,11 +82,9 @@ namespace KancolleSniffer.Model | ||
84 | 82 | Color.FromArgb(200, 148, 231), Color.FromArgb(232, 57, 41), Color.FromArgb(232, 57, 41) |
85 | 83 | }; |
86 | 84 | |
87 | - public int AcceptMax { get; set; } = 5; | |
85 | + public SortedDictionary<int, QuestStatus> QuestDictionary { get; } = new SortedDictionary<int, QuestStatus>(); | |
88 | 86 | |
89 | - public SortedDictionary<int, QuestStatus> QuestDictionary => _quests; | |
90 | - | |
91 | - public QuestStatus[] Quests => _quests.Values.ToArray(); | |
87 | + public QuestStatus[] Quests => QuestDictionary.Values.ToArray(); | |
92 | 88 | |
93 | 89 | public QuestInfo(Func<DateTime> nowFunc = null) |
94 | 90 | { |
@@ -98,7 +94,7 @@ namespace KancolleSniffer.Model | ||
98 | 94 | |
99 | 95 | public void GetNotifications(out string[] notify, out string[] stop) |
100 | 96 | { |
101 | - var cleared = _quests.Values.Where(q => q.Count.Cleared).ToArray(); | |
97 | + var cleared = QuestDictionary.Values.Where(q => q.Count.Cleared).ToArray(); | |
102 | 98 | notify = cleared.Except(_clearedQuest, new QuestComparer()).Select(q => q.Name).ToArray(); |
103 | 99 | stop = _clearedQuest.Except(cleared, new QuestComparer()).Select(q => q.Name).ToArray(); |
104 | 100 | _clearedQuest = cleared; |
@@ -117,84 +113,61 @@ namespace KancolleSniffer.Model | ||
117 | 113 | } |
118 | 114 | } |
119 | 115 | |
120 | - private readonly QuestInterval[] _intervals = | |
121 | - { | |
122 | - QuestInterval.Daily, QuestInterval.Weekly, QuestInterval.Monthly, | |
123 | - QuestInterval.Other, QuestInterval.Quarterly, QuestInterval.Yearly2 | |
124 | - }; | |
125 | - | |
126 | 116 | private readonly int[] _progress = {0, 50, 80}; |
127 | 117 | |
128 | - public void InspectQuestList(dynamic json) | |
118 | + public void InspectQuestList(string request, dynamic json) | |
129 | 119 | { |
130 | - ResetQuests(); | |
120 | + ResetCounts(); | |
121 | + var values = HttpUtility.ParseQueryString(request); | |
122 | + if (values["api_tab_id"] == "0") | |
123 | + QuestDictionary.Clear(); | |
131 | 124 | if (json.api_list == null) |
132 | 125 | return; |
133 | - for (var i = 0; i < 2; i++) | |
126 | + foreach (var entry in json.api_list) | |
134 | 127 | { |
135 | - foreach (var entry in json.api_list) | |
128 | + if (entry is double) // -1の場合がある。 | |
129 | + continue; | |
130 | + var quest = new QuestStatus | |
131 | + { | |
132 | + Id = (int)entry.api_no, | |
133 | + Category = (int)entry.api_category, | |
134 | + Progress = _progress[(int)entry.api_progress_flag], | |
135 | + Name = (string)entry.api_title, | |
136 | + Detail = ((string)entry.api_detail).Replace("<br>", "\r\n"), | |
137 | + Material = (int[])entry.api_get_material | |
138 | + }; | |
139 | + var state = (int)entry.api_state; | |
140 | + switch (state) | |
136 | 141 | { |
137 | - if (entry is double) // -1の場合がある。 | |
138 | - continue; | |
139 | - var quest = new QuestStatus | |
140 | - { | |
141 | - Id = (int)entry.api_no, | |
142 | - Category = (int)entry.api_category, | |
143 | - Progress = _progress[(int)entry.api_progress_flag], | |
144 | - Interval = _intervals[(int)entry.api_type - 1], | |
145 | - Name = (string)entry.api_title, | |
146 | - Detail = ((string)entry.api_detail).Replace("<br>", "\r\n"), | |
147 | - Material = (int[])entry.api_get_material | |
148 | - }; | |
149 | - var state = (int)entry.api_state; | |
150 | - switch (state) | |
151 | - { | |
152 | - case 1: | |
153 | - if (_quests.Remove(quest.Id)) | |
154 | - NeedSave = true; | |
155 | - break; | |
156 | - case 3: | |
157 | - quest.Progress = 100; | |
158 | - goto case 2; | |
159 | - case 2: | |
160 | - SetProcessedQuest(quest); | |
161 | - break; | |
162 | - } | |
142 | + case 3: | |
143 | + quest.Progress = 100; | |
144 | + goto case 2; | |
145 | + case 2: | |
146 | + AdjustQuest(quest); | |
147 | + SetQuest(quest); | |
148 | + break; | |
163 | 149 | } |
164 | - if (_quests.Count <= AcceptMax) | |
165 | - break; | |
166 | - /* | |
167 | - * ほかのPCで任務を達成した場合、任務が消えずに受領した任務の数がAcceptMaxを超えることがある。 | |
168 | - * その場合はいったん任務をクリアして、現在のページの任務だけを登録し直す。 | |
169 | - */ | |
170 | - _quests.Clear(); | |
171 | 150 | } |
172 | 151 | } |
173 | 152 | |
174 | - private void SetProcessedQuest(QuestStatus quest) | |
153 | + private void AdjustQuest(QuestStatus quest) | |
175 | 154 | { |
176 | - var count = _countList.GetCount(quest.Id); | |
177 | - if (count.AdjustCount(quest.Progress)) | |
155 | + quest.Count = _countList.GetCount(quest.Id); | |
156 | + if (quest.Count.AdjustCount(quest.Progress)) | |
178 | 157 | NeedSave = true; |
179 | - quest.Material = quest.Material.Concat(count.Spec.Material).ToArray(); | |
180 | - if (!_quests.ContainsKey(quest.Id)) | |
158 | + quest.Material = quest.Material.Concat(quest.Count.Spec.Material).ToArray(); | |
159 | + if (!QuestDictionary.ContainsKey(quest.Id)) | |
181 | 160 | NeedSave = true; |
182 | - SetQuest(quest); | |
183 | 161 | } |
184 | 162 | |
185 | 163 | private void SetQuest(QuestStatus quest) |
186 | 164 | { |
187 | 165 | quest.Count = _countList.GetCount(quest.Id); |
188 | 166 | quest.Color = quest.Category <= _color.Length ? _color[quest.Category - 1] : Control.DefaultBackColor; |
189 | - _quests[quest.Id] = quest; | |
167 | + QuestDictionary[quest.Id] = quest; | |
190 | 168 | } |
191 | 169 | |
192 | - public void ClearQuests() | |
193 | - { | |
194 | - _quests.Clear(); | |
195 | - } | |
196 | - | |
197 | - private void ResetQuests() | |
170 | + private void ResetCounts() | |
198 | 171 | { |
199 | 172 | _now = _nowFunc(); |
200 | 173 | if (!CrossBoundary(QuestInterval.Daily)) |
@@ -203,7 +176,6 @@ namespace KancolleSniffer.Model | ||
203 | 176 | { |
204 | 177 | if (!CrossBoundary(interval)) |
205 | 178 | continue; |
206 | - RemoveQuest(interval); | |
207 | 179 | _countList.Remove(interval); |
208 | 180 | } |
209 | 181 | _lastReset = _now; |
@@ -240,27 +212,10 @@ namespace KancolleSniffer.Model | ||
240 | 212 | return _lastReset < boundary && boundary <= _now; |
241 | 213 | } |
242 | 214 | |
243 | - private void RemoveQuest(QuestInterval interval) | |
244 | - { | |
245 | - foreach (var id in | |
246 | - (from kv in _quests | |
247 | - where MatchInterval(kv.Value, interval) | |
248 | - select kv.Key).ToArray()) | |
249 | - _quests.Remove(id); | |
250 | - } | |
251 | - | |
252 | - private bool MatchInterval(QuestStatus quest, QuestInterval interval) | |
253 | - { | |
254 | - var i = quest.Count.Spec.Interval; | |
255 | - return i == QuestInterval.Other // 定期任務の定義がない | |
256 | - ? quest.Interval == interval | |
257 | - : i == interval; | |
258 | - } | |
259 | - | |
260 | 215 | public void InspectStop(string request) |
261 | 216 | { |
262 | 217 | var values = HttpUtility.ParseQueryString(request); |
263 | - _quests.Remove(int.Parse(values["api_quest_id"])); | |
218 | + QuestDictionary.Remove(int.Parse(values["api_quest_id"])); | |
264 | 219 | NeedSave = true; |
265 | 220 | } |
266 | 221 |
@@ -269,7 +224,7 @@ namespace KancolleSniffer.Model | ||
269 | 224 | var values = HttpUtility.ParseQueryString(request); |
270 | 225 | var id = int.Parse(values["api_quest_id"]); |
271 | 226 | _countList.Remove(id); |
272 | - _quests.Remove(id); | |
227 | + QuestDictionary.Remove(id); | |
273 | 228 | NeedSave = true; |
274 | 229 | } |
275 | 230 |
@@ -279,8 +234,8 @@ namespace KancolleSniffer.Model | ||
279 | 234 | { |
280 | 235 | NeedSave = false; |
281 | 236 | status.QuestLastReset = _lastReset; |
282 | - if (_quests != null) | |
283 | - status.QuestList = _quests.Values.ToArray(); | |
237 | + if (QuestDictionary != null) | |
238 | + status.QuestList = QuestDictionary.Values.ToArray(); | |
284 | 239 | if (_countList != null) |
285 | 240 | status.QuestCountList = _countList.NonZeroCountList.ToArray(); |
286 | 241 | } |
@@ -292,7 +247,7 @@ namespace KancolleSniffer.Model | ||
292 | 247 | _countList.SetCountList(status.QuestCountList); |
293 | 248 | if (status.QuestList != null) |
294 | 249 | { |
295 | - _quests.Clear(); | |
250 | + QuestDictionary.Clear(); | |
296 | 251 | foreach (var quest in status.QuestList) |
297 | 252 | SetQuest(quest); |
298 | 253 | } |
@@ -152,7 +152,7 @@ namespace KancolleSniffer | ||
152 | 152 | if (url.EndsWith("api_port/port")) |
153 | 153 | return ApiPort(data); |
154 | 154 | if (url.Contains("member")) |
155 | - return ApiMember(url, json); | |
155 | + return ApiMember(url, request,json); | |
156 | 156 | if (url.Contains("kousyou")) |
157 | 157 | return ApiKousyou(url, request, data); |
158 | 158 | if (url.Contains("practice")) |
@@ -213,8 +213,6 @@ namespace KancolleSniffer | ||
213 | 213 | _questCounter.InspectDeck(data.api_deck_port); |
214 | 214 | _dockInfo.InspectNDock(data.api_ndock); |
215 | 215 | _achievement.InspectBasic(data.api_basic); |
216 | - if (data.api_parallel_quest_count()) // 昔のログにはないので | |
217 | - _questInfo.AcceptMax = (int)data.api_parallel_quest_count; | |
218 | 216 | if (data.api_event_object()) |
219 | 217 | _airBase.InspectEventObject(data.api_event_object); |
220 | 218 | if (data.api_plane_info()) |
@@ -228,7 +226,7 @@ namespace KancolleSniffer | ||
228 | 226 | return Update.All; |
229 | 227 | } |
230 | 228 | |
231 | - private Update ApiMember(string url, dynamic json) | |
229 | + private Update ApiMember(string url, string request, dynamic json) | |
232 | 230 | { |
233 | 231 | var data = json.api_data() ? json.api_data : new object(); |
234 | 232 |
@@ -274,7 +272,7 @@ namespace KancolleSniffer | ||
274 | 272 | } |
275 | 273 | if (url.EndsWith("api_get_member/questlist")) |
276 | 274 | { |
277 | - _questInfo.InspectQuestList(data); | |
275 | + _questInfo.InspectQuestList(request, data); | |
278 | 276 | return Update.QuestList; |
279 | 277 | } |
280 | 278 | if (url.EndsWith("api_get_member/deck")) |
@@ -632,8 +630,6 @@ namespace KancolleSniffer | ||
632 | 630 | public void GetQuestNotifications(out string[] notify, out string[] stop) => |
633 | 631 | _questInfo.GetNotifications(out notify, out stop); |
634 | 632 | |
635 | - public void ClearQuests() => _questInfo.ClearQuests(); | |
636 | - | |
637 | 633 | public NameAndTimer[] Missions => _missionInfo.Missions; |
638 | 634 | |
639 | 635 | public DateTime GetConditionTimer(int fleet) => _conditionTimer.GetTimer(fleet); |