1 // Copyright (C) 2013, 2015 Kazuhiro Fujieda <fujieda@users.osdn.me>
\r
3 // Licensed under the Apache License, Version 2.0 (the "License");
\r
4 // you may not use this file except in compliance with the License.
\r
5 // You may obtain a copy of the License at
\r
7 // http://www.apache.org/licenses/LICENSE-2.0
\r
9 // Unless required by applicable law or agreed to in writing, software
\r
10 // distributed under the License is distributed on an "AS IS" BASIS,
\r
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
12 // See the License for the specific language governing permissions and
\r
13 // limitations under the License.
\r
16 using System.Collections.Generic;
\r
17 using System.Drawing;
\r
19 using System.Windows.Forms;
\r
21 namespace KancolleSniffer
\r
23 public struct QuestStatus
\r
25 public int Category { get; set; }
\r
26 public string Name { get; set; }
\r
27 public int Progress { get; set; }
\r
28 public Color Color { get; set; }
\r
31 public class QuestInfo
\r
33 private DateTime _lastCreared;
\r
34 private readonly SortedDictionary<int, QuestStatus> _quests = new SortedDictionary<int, QuestStatus>();
\r
36 private readonly Color[] _color =
\r
38 Color.FromArgb(60, 141, 76), Color.FromArgb(232, 57, 41), Color.FromArgb(136, 204, 120),
\r
39 Color.FromArgb(52, 147, 185), Color.FromArgb(220, 198, 126), Color.FromArgb(168, 111, 76),
\r
40 Color.FromArgb(200, 148, 231), Color.FromArgb(232, 57, 41)
\r
43 public int QuestCount { get; set; }
\r
45 public void InspectQuestList(dynamic json)
\r
47 var resetTime = DateTime.Today.AddHours(5);
\r
48 if (DateTime.Now >= resetTime && _lastCreared < resetTime)
\r
50 _quests.Clear(); // 前日に未消化のデイリーを消す。
\r
51 _lastCreared = DateTime.Now;
\r
53 if (json.api_list == null)
\r
55 for (var i = 0; i < 2; i++)
\r
57 foreach (var entry in json.api_list)
\r
59 if (entry is double) // -1の場合がある。
\r
62 var id = (int)entry.api_no;
\r
63 var state = (int)entry.api_state;
\r
64 var progress = (int)entry.api_progress_flag;
\r
65 var cat = (int)entry.api_category;
\r
66 var name = (string)entry.api_title;
\r
88 _quests[id] = new QuestStatus
\r
92 Progress = progress,
\r
93 Color = cat <= _color.Length ? _color[cat - 1] : Control.DefaultBackColor
\r
98 if (_quests.Count <= QuestCount)
\r
101 * ほかのPCで任務を達成した場合、任務が消えずに受領した任務の数が_questCountを超えることがある。
\r
102 * その場合はいったん任務をクリアして、現在のページの任務だけを登録し直す。
\r
108 public void InspectStop(string request)
\r
110 var values = HttpUtility.ParseQueryString(request);
\r
111 _quests.Remove(int.Parse(values["api_quest_id"]));
\r
114 public void InspectClearItemGet(string request)
\r
116 InspectStop(request);
\r
119 public QuestStatus[] Quests => _quests.Values.ToArray();
\r