OSDN Git Service

出撃から戻ったときに装備数が更新されないのを直す
[kancollesniffer/KancolleSniffer.git] / KancolleSniffer / Sniffer.cs
index 9151cf2..2632c7e 100644 (file)
@@ -1,19 +1,16 @@
 // Copyright (C) 2013, 2014, 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
@@ -91,9 +88,8 @@ namespace KancolleSniffer
         {\r
             if (!json.api_result())\r
                 return Update.Error;\r
-            var r = (int)json.api_result;\r
-            if (r != 1)\r
-                return r == 201 ? Update.None : Update.Error;\r
+            if ((int)json.api_result != 1)\r
+                return Update.None;\r
             var data = json.api_data() ? json.api_data : new object();\r
 \r
             if (url.EndsWith("api_start2"))\r
@@ -150,6 +146,12 @@ namespace KancolleSniffer
         {\r
             var data = json.api_data() ? json.api_data : new object();\r
 \r
+            if (url.EndsWith("api_get_member/require_info"))\r
+            {\r
+                _itemInfo.InspectSlotItem(data.api_slot_item, true);\r
+                _dockInfo.InspectKDock(data.api_kdock);\r
+                return Update.Timer;\r
+            }\r
             if (url.EndsWith("api_get_member/basic"))\r
             {\r
                 _itemInfo.InspectBasic(data);\r
@@ -159,7 +161,7 @@ namespace KancolleSniffer
             if (url.EndsWith("api_get_member/slot_item"))\r
             {\r
                 _itemInfo.InspectSlotItem(data, true);\r
-                return Update.None;\r
+                return Update.Item;\r
             }\r
             if (url.EndsWith("api_get_member/kdock"))\r
             {\r
@@ -176,7 +178,7 @@ namespace KancolleSniffer
             }\r
             if (url.EndsWith("api_get_member/questlist"))\r
             {\r
-                _questInfo.Inspect(data);\r
+                _questInfo.InspectQuestList(data);\r
                 return Update.QuestList;\r
             }\r
             if (url.EndsWith("api_get_member/deck"))\r
@@ -288,7 +290,7 @@ namespace KancolleSniffer
         {\r
             if (IsNormalBattleAPI(url))\r
             {\r
-                _battleInfo.InspectBattle(data);\r
+                _battleInfo.InspectBattle(data, url);\r
                 _logger.InspectBattle(data);\r
                 return Update.Ship | Update.Battle;\r
             }\r
@@ -300,7 +302,7 @@ namespace KancolleSniffer
                     _conditionTimer.InvalidateCond();\r
                     _miscTextInfo.ClearFlag = true;\r
                 }\r
-                _battleInfo.InspectBattle(data);\r
+                _battleInfo.InspectBattle(data, url);\r
                 return Update.Ship | Update.Battle | Update.Timer;\r
             }\r
             if (url.EndsWith("api_req_sortie/battleresult"))\r
@@ -317,7 +319,7 @@ namespace KancolleSniffer
             }\r
             if (IsCombinedBattleAPI(url))\r
             {\r
-                _battleInfo.InspectCombinedBattle(data, url.EndsWith("battle_water"));\r
+                _battleInfo.InspectCombinedBattle(data, url);\r
                 _logger.InspectBattle(data);\r
                 return Update.Ship | Update.Battle;\r
             }\r
@@ -339,6 +341,7 @@ namespace KancolleSniffer
         {\r
             return url.EndsWith("api_req_sortie/battle") ||\r
                    url.EndsWith("api_req_sortie/airbattle") ||\r
+                   url.EndsWith("api_req_sortie/ld_airbattle") ||\r
                    url.EndsWith("api_req_battle_midnight/battle") ||\r
                    url.EndsWith("api_req_battle_midnight/sp_midnight");\r
         }\r
@@ -347,6 +350,7 @@ namespace KancolleSniffer
         {\r
             return url.EndsWith("api_req_combined_battle/battle") ||\r
                    url.EndsWith("api_req_combined_battle/airbattle") ||\r
+                   url.EndsWith("api_req_combined_battle/ld_airbattle") ||\r
                    url.EndsWith("api_req_combined_battle/battle_water") ||\r
                    url.EndsWith("api_req_combined_battle/midnight_battle") ||\r
                    url.EndsWith("api_req_combined_battle/sp_midnight");\r
@@ -399,6 +403,11 @@ namespace KancolleSniffer
                 _shipInfo.InspectSlotExchange(request, data);\r
                 return Update.Ship;\r
             }\r
+            if (url.EndsWith("api_req_kaisou/slot_deprive"))\r
+            {\r
+                _shipInfo.InspectSlotDeprive(data);\r
+                return Update.Ship;\r
+            }\r
             if (url.EndsWith("api_req_nyukyo/start"))\r
             {\r
                 _dockInfo.InspectNyukyo(request);\r
@@ -423,6 +432,7 @@ namespace KancolleSniffer
             }\r
             if (url.EndsWith("api_req_map/next"))\r
             {\r
+                _battleInfo.InspectMapNext(request);\r
                 _exMapInfo.InspectMapNext(data);\r
                 _logger.InspectMapNext(data);\r
                 return Update.None;\r
@@ -433,6 +443,26 @@ namespace KancolleSniffer
                 _logger.InspectMissionResult(data);\r
                 return Update.Item;\r
             }\r
+            if (url.EndsWith("api_req_quest/stop"))\r
+            {\r
+                _questInfo.InspectStop(request);\r
+                return Update.QuestList;\r
+            }\r
+            if (url.EndsWith("api_req_quest/clearitemget"))\r
+            {\r
+                _questInfo.InspectClearItemGet(request);\r
+                return Update.QuestList;\r
+            }\r
+            if (url.EndsWith("api_req_air_corps/supply"))\r
+            {\r
+                _materialInfo.InspectAirCorpsSupply(data);\r
+                return Update.Item;\r
+            }\r
+            if (url.EndsWith("api_req_air_corps/set_plane"))\r
+            {\r
+                _materialInfo.InspectAirCorpsSetPlane(data);\r
+                return Update.Item;\r
+            }\r
             return Update.None;\r
         }\r
 \r
@@ -462,6 +492,8 @@ namespace KancolleSniffer
 \r
         public int[] GetFighterPower(int fleet) => _shipInfo.GetFighterPower(fleet);\r
 \r
+        public double GetContactTriggerRate(int fleet) => _shipInfo.GetContactTriggerRate(fleet);\r
+\r
         public double GetFleetLineOfSights(int fleet) => _shipInfo.GetLineOfSights(fleet);\r
 \r
         public ShipStatus[] DamagedShipList => _shipInfo.GetDamagedShipList(_dockInfo);\r
@@ -562,5 +594,10 @@ namespace KancolleSniffer
             if (prev > _spare && _spare >= Rest)\r
                 NeedRing = true;\r
         }\r
+\r
+        public string ToString(bool finish = false)\r
+            => EndTime == DateTime.MinValue\r
+                ? ""\r
+                : finish ? EndTime.ToString(@"dd\ HH\:mm") : $@"{(int)Rest.TotalHours:d2}:{Rest:mm\:ss}";\r
     }\r
 }
\ No newline at end of file