1 // Copyright (C) 2013, 2015 Kazuhiro Fujieda <fujieda@users.sourceforge.jp>
\r
3 // This program is part of KancolleSniffer.
\r
5 // KancolleSniffer is free software: you can redistribute it and/or modify
\r
6 // it under the terms of the GNU General Public License as published by
\r
7 // the Free Software Foundation, either version 3 of the License, or
\r
8 // (at your option) any later version.
\r
10 // This program is distributed in the hope that it will be useful,
\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 // GNU General Public License for more details.
\r
15 // You should have received a copy of the GNU General Public License
\r
16 // along with this program; if not, see <http://www.gnu.org/licenses/>.
\r
19 using System.Collections.Generic;
\r
22 namespace KancolleSniffer
\r
24 public class QuestInfo
\r
26 private DateTime _lastCreared;
\r
27 private readonly SortedDictionary<int, NameAndProgress> _quests = new SortedDictionary<int, NameAndProgress>();
\r
28 private const int QuestCount = 5;
\r
30 public void Inspect(dynamic json)
\r
32 var resetTime = DateTime.Today.AddHours(5);
\r
33 if (DateTime.Now >= resetTime && _lastCreared < resetTime)
\r
35 _quests.Clear(); // 前日に未消化のデイリーを消す。
\r
36 _lastCreared = DateTime.Now;
\r
38 if (json.api_list == null)
\r
40 for (var i = 0; i < 2; i++)
\r
42 foreach (var entry in json.api_list)
\r
44 if (entry is double) // -1の場合がある。
\r
47 var id = (int)entry.api_no;
\r
48 var state = (int)entry.api_state;
\r
49 var progress = (int)entry.api_progress_flag;
\r
50 var name = (string)entry.api_title;
\r
66 _quests[id] = new NameAndProgress {Name = name, Progress = progress};
\r
74 if (_quests.Count <= QuestCount)
\r
77 * ほかのPCで任務を達成した場合、任務が消えずに受領した任務の数が_questCountを超えることがある。
\r
78 * その場合はいったん任務をクリアして、現在のページの任務だけを登録し直す。
\r
84 public NameAndProgress[] Quests
\r
86 get { return _quests.Values.ToArray(); }
\r
89 public struct NameAndProgress
\r
91 public string Name { get; set; }
\r
92 public int Progress { get; set; }
\r