OSDN Git Service

修復時間が1分以内の入渠で艦娘が即座に回復するのを反映する
[kancollesniffer/KancolleSniffer.git] / KancolleSniffer / QuestInfo.cs
index 72e81cb..626e0d3 100644 (file)
@@ -1,23 +1,22 @@
-// Copyright (C) 2013, 2015 Kazuhiro Fujieda <fujieda@users.sourceforge.jp>\r
+// Copyright (C) 2013, 2015 Kazuhiro Fujieda <fujieda@users.osdn.me>\r
 // \r
-// This program is part of KancolleSniffer.\r
+// Licensed under the Apache License, Version 2.0 (the "License");\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
 //\r
-// KancolleSniffer is free software: you can redistribute it and/or modify\r
-// it under the terms of the GNU General Public License as published by\r
-// the Free Software Foundation, either version 3 of the License, or\r
-// (at your option) any later version.\r
+//    http://www.apache.org/licenses/LICENSE-2.0\r
 //\r
-// This program is distributed in the hope that it will be useful,\r
-// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-// GNU General Public License for more details.\r
-//\r
-// You should have received a copy of the GNU General Public License\r
-// along with this program; if not, see <http://www.gnu.org/licenses/>.\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
 \r
 using System;\r
 using System.Collections.Generic;\r
+using System.Drawing;\r
 using System.Linq;\r
+using System.Windows.Forms;\r
 \r
 namespace KancolleSniffer\r
 {\r
@@ -26,6 +25,7 @@ namespace KancolleSniffer
         public int Category { get; set; }\r
         public string Name { get; set; }\r
         public int Progress { get; set; }\r
+        public Color Color { get; set; }\r
     }\r
 \r
     public class QuestInfo\r
@@ -33,9 +33,16 @@ namespace KancolleSniffer
         private DateTime _lastCreared;\r
         private readonly SortedDictionary<int, QuestStatus> _quests = new SortedDictionary<int, QuestStatus>();\r
 \r
+        private readonly Color[] _color =\r
+        {\r
+            Color.FromArgb(60, 141, 76), Color.FromArgb(232, 57, 41), Color.FromArgb(136, 204, 120),\r
+            Color.FromArgb(52, 147, 185), Color.FromArgb(220, 198, 126), Color.FromArgb(168, 111, 76),\r
+            Color.FromArgb(200, 148, 231), Color.FromArgb(232, 57, 41)\r
+        };\r
+\r
         public int QuestCount { get; set; }\r
 \r
-        public void Inspect(dynamic json)\r
+        public void InspectQuestList(dynamic json)\r
         {\r
             var resetTime = DateTime.Today.AddHours(5);\r
             if (DateTime.Now >= resetTime && _lastCreared < resetTime)\r
@@ -71,13 +78,21 @@ namespace KancolleSniffer
                     }\r
                     switch (state)\r
                     {\r
-                        case 2:\r
-                            _quests[id] = new QuestStatus {Category = cat, Name = name, Progress = progress};\r
-                            break;\r
                         case 1:\r
-                        case 3:\r
                             _quests.Remove(id);\r
-                            continue;\r
+                            break;\r
+                        case 3:\r
+                            progress = 100;\r
+                            goto case 2;\r
+                        case 2:\r
+                            _quests[id] = new QuestStatus\r
+                            {\r
+                                Category = cat,\r
+                                Name = name,\r
+                                Progress = progress,\r
+                                Color = cat <= _color.Length ? _color[cat - 1] : Control.DefaultBackColor\r
+                            };\r
+                            break;\r
                     }\r
                 }\r
                 if (_quests.Count <= QuestCount)\r
@@ -90,9 +105,17 @@ namespace KancolleSniffer
             }\r
         }\r
 \r
-        public QuestStatus[] Quests\r
+        public void InspectStop(string request)\r
         {\r
-            get { return _quests.Values.ToArray(); }\r
+            var values = HttpUtility.ParseQueryString(request);\r
+            _quests.Remove(int.Parse(values["api_quest_id"]));\r
         }\r
+\r
+        public void InspectClearItemGet(string request)\r
+        {\r
+            InspectStop(request);\r
+        }\r
+\r
+        public QuestStatus[] Quests => _quests.Values.ToArray();\r
     }\r
 }
\ No newline at end of file