// 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
\r
public Update Sniff(string url, string request, dynamic json)\r
{\r
- if (!json.api_result() || (int)json.api_result != 1)\r
+ if (!json.api_result())\r
return 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
_logger.InspectBasic(data.api_basic);\r
_logger.InspectMaterial(data.api_material);\r
_shipInfo.InspectShip(data);\r
+ _shipInfo.ClearBadlyDamagedShips();\r
_conditionTimer.CalcRegenTime();\r
_missionInfo.InspectDeck(data.api_deck_port);\r
_dockInfo.InspectNDock(data.api_ndock);\r
- _akashiTimer.SetTimer(true);\r
+ _akashiTimer.Port();\r
_achievement.InspectBasic(data.api_basic);\r
if (data.api_parallel_quest_count()) // 昔のログにはないので\r
_questInfo.QuestCount = (int)data.api_parallel_quest_count;\r
_battleInfo.CleanupResult();\r
_battleInfo.InBattle = false;\r
- _battleInfo.HasDamagedShip = false;\r
_shipInfo.ClearEscapedShips();\r
_miscTextInfo.ClearIfNeeded();\r
SaveState();\r
{\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
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
{\r
_dockInfo.InspectNDock(data);\r
_conditionTimer.CheckCond();\r
- _akashiTimer.SetTimer();\r
+ _akashiTimer.CheckFleet();\r
return Update.NDock | Update.Timer | Update.Ship;\r
}\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
{\r
_shipInfo.InspectDeck(data);\r
_missionInfo.InspectDeck(data);\r
- _akashiTimer.SetTimer();\r
+ _akashiTimer.CheckFleet();\r
return Update.Mission | Update.Timer;\r
}\r
if (url.EndsWith("api_get_member/ship2"))\r
{\r
// ここだけjsonなので注意\r
_shipInfo.InspectShip(json);\r
- _akashiTimer.SetTimer();\r
+ _akashiTimer.CheckFleet();\r
_battleInfo.InBattle = false;\r
return Update.Item | Update.Ship | Update.Battle;\r
}\r
if (url.EndsWith("api_get_member/ship_deck"))\r
{\r
_shipInfo.InspectShip(data);\r
- _akashiTimer.SetTimer();\r
+ _akashiTimer.CheckFleet();\r
_battleInfo.InBattle = false;\r
return Update.Ship | Update.Battle;\r
}\r
if (url.EndsWith("api_get_member/ship3"))\r
{\r
_shipInfo.InspectShip(data);\r
- _akashiTimer.SetTimer();\r
+ _akashiTimer.CheckFleet();\r
_conditionTimer.CheckCond();\r
return Update.Ship;\r
}\r
_miscTextInfo.InspectPracticeEnemyInfo(data);\r
return Update.Item;\r
}\r
+ if (url.EndsWith("api_get_member/preset_deck"))\r
+ {\r
+ _shipInfo.InspectPresetDeck(data);\r
+ return Update.None;\r
+ }\r
return Update.None;\r
}\r
\r
_shipInfo.InspectDestroyShip(request, data);\r
_materialInfo.InspectDestroyShip(data);\r
_conditionTimer.CheckCond();\r
- _akashiTimer.SetTimer();\r
+ _akashiTimer.CheckFleet();\r
return Update.Item | Update.Ship;\r
}\r
if (url.EndsWith("api_req_kousyou/destroyitem2"))\r
{\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
{\r
if (url.EndsWith("/battle"))\r
{\r
- _shipInfo.StartSortie(request); // 演習を出撃中とみなす\r
+ _shipInfo.InspectMapStart(request); // 演習を出撃中とみなす\r
_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
}\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
{\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
{\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
if (url.EndsWith("api_req_hensei/change"))\r
{\r
_shipInfo.InspectChange(request);\r
- _akashiTimer.SetTimer();\r
+ _akashiTimer.InspectChange(request);\r
+ return Update.Ship;\r
+ }\r
+ if (url.EndsWith("api_req_hensei/preset_select"))\r
+ {\r
+ _shipInfo.InspectDeck(new[] {data});\r
+ _akashiTimer.CheckFleet();\r
+ return Update.Ship;\r
+ }\r
+ if (url.EndsWith("api_req_hensei/preset_register"))\r
+ {\r
+ _shipInfo.InspectPresetRegister(data);\r
+ return Update.None;\r
+ }\r
+ if (url.EndsWith("api_req_hensei/preset_delete"))\r
+ {\r
+ _shipInfo.InspectPresetDelete(request);\r
+ return Update.Timer;\r
+ }\r
+ if (url.EndsWith("api_req_hensei/combined"))\r
+ {\r
+ _shipInfo.InspectCombined(request);\r
return Update.Ship;\r
}\r
if (url.EndsWith("api_req_hokyu/charge"))\r
{\r
_shipInfo.InspectPowerup(request, data);\r
_conditionTimer.CheckCond();\r
- _akashiTimer.SetTimer();\r
+ _akashiTimer.CheckFleet();\r
return Update.Item | Update.Ship;\r
}\r
+ if (url.EndsWith("api_req_kaisou/slot_exchange_index"))\r
+ {\r
+ _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
_conditionTimer.CheckCond();\r
- _akashiTimer.SetTimer();\r
+ _akashiTimer.CheckFleet();\r
return Update.Item | Update.Ship;\r
}\r
if (url.EndsWith("api_req_nyukyo/speedchange"))\r
}\r
if (url.EndsWith("api_req_map/start"))\r
{\r
- _shipInfo.StartSortie(request);\r
+ _shipInfo.InspectMapStart(request); // 出撃中判定が必要なので_conditionTimerより前\r
_conditionTimer.InvalidateCond();\r
_exMapInfo.InspectMapStart(data);\r
_logger.InspectMapStart(data);\r
_miscTextInfo.ClearFlag = true;\r
- return Update.Timer;\r
+ return Update.Timer | Update.Ship;\r
}\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
_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
\r
public int[] GetDeck(int fleet) => _shipInfo.GetDeck(fleet);\r
\r
+ public int CombinedFleetType => _shipInfo.CombinedFleetType;\r
+\r
public ChargeStatus[] ChargeStatuses => _shipInfo.ChargeStatuses;\r
\r
- public int GetFighterPower(int fleet, bool withBonus) => _shipInfo.GetFighterPower(fleet, withBonus);\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
\r
public ShipStatus[] ShipList => _shipInfo.ShipList;\r
\r
- public ItemStatus[] ItemList => _itemInfo.GetItemListWithOwner(ShipList);\r
+ public string[] BadlyDamagedShips => _shipInfo.BadlyDamagedShips;\r
\r
- public AkashiTimer.RepairSpan[] GetAkashiTimers(int fleet) => _akashiTimer.GetTimers(fleet);\r
+ public ItemStatus[] ItemList => _itemInfo.GetItemListWithOwner(ShipList);\r
\r
- public AkashiTimer.Notice[] GetAkashiTimerNotice() => _akashiTimer.GetNotice();\r
+ public AkashiTimer AkashiTimer => _akashiTimer;\r
\r
public Achievement Achievement => _achievement;\r
\r
\r
public class RingTimer\r
{\r
- private DateTime _endTime;\r
private readonly TimeSpan _spare;\r
\r
public TimeSpan Rest { get; private set; }\r
\r
- public bool IsFinished => _endTime != DateTime.MinValue && Rest <= _spare;\r
+ public bool IsFinished => EndTime != DateTime.MinValue && Rest <= _spare;\r
+\r
+ public DateTime EndTime { get; private set; }\r
\r
public bool NeedRing { get; set; }\r
\r
\r
public void SetEndTime(DateTime time)\r
{\r
- _endTime = time;\r
+ EndTime = time;\r
}\r
\r
public void Update()\r
{\r
- if (_endTime == DateTime.MinValue)\r
+ if (EndTime == DateTime.MinValue)\r
{\r
Rest = TimeSpan.Zero;\r
return;\r
}\r
var prev = Rest;\r
- Rest = _endTime - DateTime.Now;\r
+ Rest = EndTime - DateTime.Now;\r
if (Rest < TimeSpan.Zero)\r
Rest = TimeSpan.Zero;\r
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