1 // Copyright (C) 2013, 2014, 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.Globalization;
\r
20 namespace KancolleSniffer
\r
22 public class Sniffer
\r
24 private bool _start;
\r
25 private readonly ItemInfo _itemInfo = new ItemInfo();
\r
26 private readonly MaterialInfo _materialInfo = new MaterialInfo();
\r
27 private readonly QuestInfo _questInfo = new QuestInfo();
\r
28 private readonly MissionInfo _missionInfo = new MissionInfo();
\r
29 private readonly ShipInfo _shipInfo;
\r
30 private readonly ConditionTimer _conditionTimer;
\r
31 private readonly DockInfo _dockInfo;
\r
32 private readonly AkashiTimer _akashiTimer;
\r
33 private readonly Achievement _achievement = new Achievement();
\r
34 private readonly BattleInfo _battleInfo;
\r
35 private readonly Logger _logger;
\r
36 private readonly ExMapInfo _exMapInfo = new ExMapInfo();
\r
37 private readonly MiscTextInfo _miscTextInfo = new MiscTextInfo();
\r
38 private readonly BaseAirCoprs _baseAirCoprs;
\r
39 private readonly PresetDeck _presetDeck = new PresetDeck();
\r
40 private readonly Status _status = new Status();
\r
41 private bool _saveState;
\r
42 private readonly List<IHaveState> _haveState;
\r
44 public interface IRepeatingTimerController
\r
46 void Stop(string key);
\r
47 void Stop(string key, int fleet);
\r
52 public IRepeatingTimerController RepeatingTimerController { get; set; }
\r
70 public Sniffer(bool start = false)
\r
73 _shipInfo = new ShipInfo(_itemInfo);
\r
74 _conditionTimer = new ConditionTimer(_shipInfo);
\r
75 _dockInfo = new DockInfo(_shipInfo, _materialInfo);
\r
76 _akashiTimer = new AkashiTimer(_shipInfo, _dockInfo, _presetDeck);
\r
77 _battleInfo = new BattleInfo(_shipInfo, _itemInfo);
\r
78 _logger = new Logger(_shipInfo, _itemInfo, _battleInfo);
\r
79 _baseAirCoprs = new BaseAirCoprs(_itemInfo);
\r
80 _haveState = new List<IHaveState> {_achievement, _materialInfo, _conditionTimer, _exMapInfo};
\r
83 private void SaveState()
\r
87 if (!_haveState.Any(x => x.NeedSave))
\r
89 foreach (var x in _haveState)
\r
90 x.SaveState(_status);
\r
94 public void LoadState()
\r
97 foreach (var x in _haveState)
\r
98 x.LoadState(_status);
\r
102 public Update Sniff(string url, string request, dynamic json)
\r
104 if (!json.api_result())
\r
105 return Update.Error;
\r
106 if ((int)json.api_result != 1)
\r
107 return Update.None;
\r
108 var data = json.api_data() ? json.api_data : new object();
\r
110 if (url.EndsWith("api_start2"))
\r
112 return ApiStart(data);
\r
115 return Update.None;
\r
117 if (url.EndsWith("api_port/port"))
\r
118 return ApiPort(data);
\r
119 if (url.Contains("member"))
\r
120 return ApiMember(url, json);
\r
121 if (url.Contains("kousyou"))
\r
122 return ApiKousyou(url, request, data);
\r
123 if (url.Contains("battle") || url.Contains("sortie"))
\r
124 return ApiBattle(url, request, data);
\r
125 return ApiOthers(url, request, data);
\r
128 private Update ApiStart(dynamic data)
\r
130 _shipInfo.InspectMaster(data);
\r
131 _missionInfo.InspectMaster(data.api_mst_mission);
\r
132 _itemInfo.InspectMaster(data);
\r
133 _exMapInfo.ResetIfNeeded();
\r
135 return Update.Start;
\r
138 private Update ApiPort(dynamic data)
\r
140 _itemInfo.InspectBasic(data.api_basic);
\r
141 _materialInfo.InspectMaterialPort(data.api_material);
\r
142 _logger.InspectBasic(data.api_basic);
\r
143 _logger.InspectMaterial(data.api_material);
\r
144 _shipInfo.InspectShip(data);
\r
145 _shipInfo.ClearBadlyDamagedShips();
\r
146 _conditionTimer.CalcRegenTime();
\r
147 _missionInfo.InspectDeck(data.api_deck_port);
\r
148 _dockInfo.InspectNDock(data.api_ndock);
\r
149 _akashiTimer.Port();
\r
150 _achievement.InspectBasic(data.api_basic);
\r
151 if (data.api_parallel_quest_count()) // 昔のログにはないので
\r
152 _questInfo.QuestCount = (int)data.api_parallel_quest_count;
\r
153 if (data.api_event_object())
\r
154 _baseAirCoprs.InspectEventObject(data.api_event_object);
\r
155 if (data.api_plane_info())
\r
156 _baseAirCoprs.InspectPlaneInfo(data.api_plane_info);
\r
157 _battleInfo.CleanupResult();
\r
158 _battleInfo.BattleState = BattleState.None;
\r
159 _shipInfo.ClearEscapedShips();
\r
160 _miscTextInfo.ClearIfNeeded();
\r
162 RepeatingTimerController?.Resume();
\r
163 foreach (var s in new[] {"遠征終了", "入渠終了", "疲労回復", "泊地修理"})
\r
164 RepeatingTimerController?.Stop(s);
\r
168 private Update ApiMember(string url, dynamic json)
\r
170 var data = json.api_data() ? json.api_data : new object();
\r
172 if (url.EndsWith("api_get_member/require_info"))
\r
174 _itemInfo.InspectSlotItem(data.api_slot_item, true);
\r
175 _dockInfo.InspectKDock(data.api_kdock);
\r
176 return Update.Timer;
\r
178 if (url.EndsWith("api_get_member/basic"))
\r
180 _itemInfo.InspectBasic(data);
\r
181 _logger.InspectBasic(data);
\r
182 return Update.None;
\r
184 if (url.EndsWith("api_get_member/slot_item"))
\r
186 _itemInfo.InspectSlotItem(data, true);
\r
187 return Update.Item;
\r
189 if (url.EndsWith("api_get_member/kdock"))
\r
191 _dockInfo.InspectKDock(data);
\r
192 _logger.InspectKDock(data);
\r
193 return Update.Timer;
\r
195 if (url.EndsWith("api_get_member/ndock"))
\r
197 _dockInfo.InspectNDock(data);
\r
198 _conditionTimer.CheckCond();
\r
199 _akashiTimer.CheckFleet();
\r
200 RepeatingTimerController?.Stop("入渠終了");
\r
201 return Update.NDock | Update.Timer | Update.Ship;
\r
203 if (url.EndsWith("api_get_member/questlist"))
\r
205 _questInfo.InspectQuestList(data);
\r
206 return Update.QuestList;
\r
208 if (url.EndsWith("api_get_member/deck"))
\r
210 _shipInfo.InspectDeck(data);
\r
211 _missionInfo.InspectDeck(data);
\r
212 _akashiTimer.CheckFleet();
\r
213 return Update.Mission | Update.Timer;
\r
215 if (url.EndsWith("api_get_member/ship2"))
\r
218 _shipInfo.InspectShip(json);
\r
219 _akashiTimer.CheckFleet();
\r
220 _battleInfo.BattleState = BattleState.None;
\r
221 return Update.Item | Update.Ship | Update.Battle;
\r
223 if (url.EndsWith("api_get_member/ship_deck"))
\r
225 _shipInfo.InspectShip(data);
\r
226 _akashiTimer.CheckFleet();
\r
227 _battleInfo.BattleState = BattleState.None;
\r
228 return Update.Ship | Update.Battle;
\r
230 if (url.EndsWith("api_get_member/ship3"))
\r
232 _shipInfo.InspectShip(data);
\r
233 _akashiTimer.CheckFleet();
\r
234 _conditionTimer.CheckCond();
\r
235 return Update.Ship;
\r
237 if (url.EndsWith("api_get_member/material"))
\r
239 _materialInfo.InspectMaterial(data);
\r
240 return Update.Item;
\r
242 if (url.EndsWith("api_get_member/mapinfo"))
\r
244 _exMapInfo.InspectMapInfo(data);
\r
245 _miscTextInfo.InspectMapInfo(data);
\r
246 if (data.api_air_base())
\r
247 _baseAirCoprs.Inspect(data.api_air_base);
\r
248 return Update.Item;
\r
250 if (url.EndsWith("api_req_member/get_practice_enemyinfo"))
\r
252 _miscTextInfo.InspectPracticeEnemyInfo(data);
\r
253 return Update.Item;
\r
255 if (url.EndsWith("api_get_member/preset_deck"))
\r
257 _presetDeck.Inspect(data);
\r
258 return Update.None;
\r
260 if (url.EndsWith("api_get_member/base_air_corps"))
\r
262 _baseAirCoprs.Inspect(data);
\r
263 return Update.Ship;
\r
265 return Update.None;
\r
268 private Update ApiKousyou(string url, string request, dynamic data)
\r
270 if (url.EndsWith("api_req_kousyou/createitem"))
\r
272 _itemInfo.InspectCreateItem(data);
\r
273 _materialInfo.InspectCreateIem(data);
\r
274 _logger.InspectCreateItem(request, data);
\r
275 return Update.Item;
\r
277 if (url.EndsWith("api_req_kousyou/getship"))
\r
279 _itemInfo.InspectGetShip(data);
\r
280 _shipInfo.InspectShip(data);
\r
281 _dockInfo.InspectKDock(data.api_kdock);
\r
282 _conditionTimer.CheckCond();
\r
283 RepeatingTimerController?.Stop("建造完了");
\r
284 return Update.Item | Update.Timer;
\r
286 if (url.EndsWith("api_req_kousyou/destroyship"))
\r
288 _shipInfo.InspectDestroyShip(request, data);
\r
289 _materialInfo.InspectDestroyShip(data);
\r
290 _conditionTimer.CheckCond();
\r
291 _akashiTimer.CheckFleet();
\r
292 return Update.Item | Update.Ship;
\r
294 if (url.EndsWith("api_req_kousyou/destroyitem2"))
\r
296 _itemInfo.InspectDestroyItem(request, data);
\r
297 _materialInfo.InspectDestroyItem(data);
\r
298 return Update.Item;
\r
300 if (url.EndsWith("api_req_kousyou/remodel_slot"))
\r
302 _logger.SetCurrentMaterial(_materialInfo.Current);
\r
303 _logger.InspectRemodelSlot(request, data); // 資材の差が必要なので_materialInfoより前
\r
304 _itemInfo.InspectRemodelSlot(data);
\r
305 _materialInfo.InspectRemodelSlot(data);
\r
306 return Update.Item;
\r
308 if (url.EndsWith("api_req_kousyou/createship"))
\r
310 _logger.InspectCreateShip(request);
\r
311 return Update.None;
\r
313 if (url.EndsWith("api_req_kousyou/createship_speedchange"))
\r
315 _dockInfo.InspectCreateShipSpeedChange(request);
\r
316 return Update.Timer;
\r
318 return Update.None;
\r
321 private Update ApiBattle(string url, string request, dynamic data)
\r
323 if (IsNormalBattleAPI(url) || IsCombinedBattleAPI(url))
\r
325 _battleInfo.InspectBattle(url, request, data);
\r
326 _logger.InspectBattle(data);
\r
327 return Update.Ship | Update.Battle;
\r
329 if (url.EndsWith("api_req_practice/battle") || url.EndsWith("api_req_practice/midnight_battle"))
\r
331 if (url.EndsWith("/battle"))
\r
333 _shipInfo.InspectMapStart(request); // 演習を出撃中とみなす
\r
334 _conditionTimer.InvalidateCond();
\r
335 _miscTextInfo.ClearFlag = true;
\r
336 RepeatingTimerController?.Suspend();
\r
338 _battleInfo.InspectBattle(url, request, data);
\r
339 return Update.Ship | Update.Battle | Update.Timer;
\r
341 if (url.EndsWith("api_req_sortie/battleresult") || url.EndsWith("api_req_combined_battle/battleresult"))
\r
343 _battleInfo.InspectBattleResult(data);
\r
344 _exMapInfo.InspectBattleResult(data);
\r
345 _logger.InspectBattleResult(data);
\r
346 return Update.Ship;
\r
348 if (url.EndsWith("api_req_practice/battle_result"))
\r
350 _battleInfo.InspectPracticeResult(data);
\r
351 return Update.Ship;
\r
353 if (url.EndsWith("/goback_port"))
\r
355 _battleInfo.CauseEscape();
\r
356 return Update.Ship;
\r
358 _battleInfo.BattleState = BattleState.Unknown;
\r
359 return Update.None;
\r
362 private bool IsNormalBattleAPI(string url)
\r
364 return url.EndsWith("api_req_sortie/battle") ||
\r
365 url.EndsWith("api_req_sortie/airbattle") ||
\r
366 url.EndsWith("api_req_sortie/ld_airbattle") ||
\r
367 url.EndsWith("api_req_battle_midnight/battle") ||
\r
368 url.EndsWith("api_req_battle_midnight/sp_midnight");
\r
371 private bool IsCombinedBattleAPI(string url)
\r
373 return url.EndsWith("api_req_combined_battle/battle") ||
\r
374 url.EndsWith("api_req_combined_battle/airbattle") ||
\r
375 url.EndsWith("api_req_combined_battle/ld_airbattle") ||
\r
376 url.EndsWith("api_req_combined_battle/battle_water") ||
\r
377 url.EndsWith("api_req_combined_battle/midnight_battle") ||
\r
378 url.EndsWith("api_req_combined_battle/sp_midnight") ||
\r
379 url.EndsWith("api_req_combined_battle/ec_battle") ||
\r
380 url.EndsWith("api_req_combined_battle/ec_midnight_battle") ||
\r
381 url.EndsWith("api_req_combined_battle/ec_night_to_day") ||
\r
382 url.EndsWith("api_req_combined_battle/each_battle") ||
\r
383 url.EndsWith("api_req_combined_battle/each_battle_water");
\r
386 private Update ApiOthers(string url, string request, dynamic data)
\r
388 if (url.EndsWith("api_req_hensei/change"))
\r
390 _shipInfo.InspectChange(request);
\r
391 _akashiTimer.InspectChange(request);
\r
392 return Update.Ship;
\r
394 if (url.EndsWith("api_req_hensei/preset_select"))
\r
396 _shipInfo.InspectDeck(new[] {data});
\r
397 _akashiTimer.CheckFleet();
\r
398 return Update.Ship;
\r
400 if (url.EndsWith("api_req_hensei/preset_register"))
\r
402 _presetDeck.InspectRegister(data);
\r
403 return Update.None;
\r
405 if (url.EndsWith("api_req_hensei/preset_delete"))
\r
407 _presetDeck.InspectDelete(request);
\r
408 return Update.Timer;
\r
410 if (url.EndsWith("api_req_hensei/combined"))
\r
412 _shipInfo.InspectCombined(request);
\r
413 return Update.Ship;
\r
415 if (url.EndsWith("api_req_hokyu/charge"))
\r
417 _shipInfo.InspectCharge(data);
\r
418 _materialInfo.InspectCharge(data);
\r
419 return Update.Item | Update.Ship;
\r
421 if (url.EndsWith("api_req_kaisou/powerup"))
\r
423 _shipInfo.InspectPowerup(request, data);
\r
424 _conditionTimer.CheckCond();
\r
425 _akashiTimer.CheckFleet();
\r
426 return Update.Item | Update.Ship;
\r
428 if (url.EndsWith("api_req_kaisou/slot_exchange_index"))
\r
430 _shipInfo.InspectSlotExchange(request, data);
\r
431 return Update.Ship;
\r
433 if (url.EndsWith("api_req_kaisou/slot_deprive"))
\r
435 _shipInfo.InspectSlotDeprive(data);
\r
436 return Update.Ship;
\r
438 if (url.EndsWith("api_req_nyukyo/start"))
\r
440 _dockInfo.InspectNyukyo(request);
\r
441 _conditionTimer.CheckCond();
\r
442 _akashiTimer.CheckFleet();
\r
443 var ndock = HttpUtility.ParseQueryString(request)["api_ndock_id"];
\r
444 if (ndock != null && int.TryParse(ndock, out int id))
\r
445 RepeatingTimerController?.Stop("入渠終了", id - 1);
\r
446 return Update.Item | Update.Ship;
\r
448 if (url.EndsWith("api_req_nyukyo/speedchange"))
\r
450 _dockInfo.InspectSpeedChange(request);
\r
451 _conditionTimer.CheckCond();
\r
452 return Update.NDock | Update.Timer | Update.Item | Update.Ship;
\r
454 if (url.EndsWith("api_req_map/start"))
\r
456 _shipInfo.InspectMapStart(request); // 出撃中判定が必要なので_conditionTimerより前
\r
457 _conditionTimer.InvalidateCond();
\r
458 _exMapInfo.InspectMapStart(data);
\r
459 _battleInfo.InspectMapStart(data);
\r
460 _logger.InspectMapStart(data);
\r
461 _miscTextInfo.ClearFlag = true;
\r
462 RepeatingTimerController?.Suspend();
\r
463 return Update.Timer | Update.Ship;
\r
465 if (url.EndsWith("api_req_map/next"))
\r
467 _exMapInfo.InspectMapNext(data);
\r
468 _battleInfo.InspectMapNext(data);
\r
469 _logger.InspectMapNext(data);
\r
470 return Update.None;
\r
472 if (url.EndsWith("api_req_mission/start"))
\r
474 var deck = HttpUtility.ParseQueryString(request)["api_deck_id"];
\r
475 if (deck != null && int.TryParse(deck, out int id))
\r
476 RepeatingTimerController?.Stop("遠征終了", id - 1);
\r
477 return Update.None;
\r
479 if (url.EndsWith("api_req_mission/result"))
\r
481 _materialInfo.InspectMissionResult(data);
\r
482 _logger.InspectMissionResult(data);
\r
483 return Update.Item;
\r
485 if (url.EndsWith("api_req_quest/stop"))
\r
487 _questInfo.InspectStop(request);
\r
488 return Update.QuestList;
\r
490 if (url.EndsWith("api_req_quest/clearitemget"))
\r
492 _questInfo.InspectClearItemGet(request);
\r
493 _logger.InspectClearItemGet(data);
\r
494 return Update.QuestList;
\r
496 if (url.EndsWith("api_req_air_corps/supply"))
\r
498 _materialInfo.InspectAirCorpsSupply(data);
\r
499 _baseAirCoprs.InspectSupply(request, data);
\r
500 return Update.Item;
\r
502 if (url.EndsWith("api_req_air_corps/set_plane"))
\r
504 _materialInfo.InspectAirCorpsSetPlane(data);
\r
505 _baseAirCoprs.InspectSetPlane(request, data);
\r
506 return Update.Item | Update.Ship;
\r
508 if (url.EndsWith("api_req_air_corps/set_action"))
\r
510 _baseAirCoprs.InspectSetAction(request);
\r
511 return Update.Ship;
\r
513 if (url.EndsWith("api_req_air_corps/expand_base"))
\r
515 _baseAirCoprs.InspectExpandBase(request, data);
\r
516 return Update.Ship;
\r
518 return Update.None;
\r
521 public NameAndTimer[] NDock => _dockInfo.NDock;
\r
523 public RingTimer[] KDock => _dockInfo.KDock;
\r
525 public ItemInfo Item => _itemInfo;
\r
527 public MaterialInfo Material => _materialInfo;
\r
529 public QuestStatus[] Quests => _questInfo.Quests;
\r
531 public NameAndTimer[] Missions => _missionInfo.Missions;
\r
533 public DateTime GetConditionTimer(int fleet) => _conditionTimer.GetTimer(fleet);
\r
535 public int[] GetConditionNotice(DateTime prev, DateTime now) => _conditionTimer.GetNotice(prev, now);
\r
537 public ShipStatus[] GetShipStatuses(int fleet) => _shipInfo.GetShipStatuses(fleet);
\r
539 public int[] GetDeck(int fleet) => _shipInfo.GetDeck(fleet);
\r
541 public ShipInfo.ShipStatusPair[] BattleResultStatusDiff => _shipInfo.BattleResultDiff;
\r
543 public bool IsBattleResultStatusError => _shipInfo.IsBattleResultError;
\r
545 public ShipStatus[] BattleStartStatus => _shipInfo.BattleStartStatus;
\r
547 public int CombinedFleetType => _shipInfo.CombinedFleetType;
\r
549 public ChargeStatus[] ChargeStatuses => _shipInfo.ChargeStatuses;
\r
551 public int[] GetFighterPower(int fleet) => _shipInfo.GetFighterPower(fleet);
\r
553 public double GetContactTriggerRate(int fleet) => _shipInfo.GetContactTriggerRate(fleet);
\r
555 public double GetFleetLineOfSights(int fleet, int factor) => _shipInfo.GetLineOfSights(fleet, factor);
\r
557 public ShipStatus[] RepairList => _shipInfo.GetRepairList(_dockInfo);
\r
559 public ShipStatus[] ShipList => _shipInfo.ShipList;
\r
561 public string[] BadlyDamagedShips => _shipInfo.BadlyDamagedShips;
\r
563 public double GetDaihatsuBonus(int fleet) => _shipInfo.GetDaihatsuBonus(fleet);
\r
565 public double GetTransportPoint(int fleet) => _shipInfo.GetTransportPoint(fleet);
\r
567 public ItemStatus[] ItemList
\r
571 _itemInfo.ClearHolder();
\r
572 _shipInfo.SetItemHolder();
\r
573 _baseAirCoprs.SetItemHolder();
\r
574 return _itemInfo.ItemList;
\r
578 public AkashiTimer AkashiTimer => _akashiTimer;
\r
580 public Achievement Achievement => _achievement;
\r
582 public BattleInfo Battle => _battleInfo;
\r
584 public ExMapInfo ExMap => _exMapInfo;
\r
586 public string MiscText => _miscTextInfo.Text;
\r
588 public BaseAirCoprs.BaseInfo[] BaseAirCorps => _baseAirCoprs.AllAirCorps;
\r
590 public bool UseOldEnemyId
\r
592 set => _shipInfo.UseOldEnemyId = value;
\r
595 public void SetLogWriter(Action<string, string, string> writer, Func<DateTime> nowFunc)
\r
597 _logger.SetWriter(writer, nowFunc);
\r
600 public void SkipMaster()
\r
605 public void EnableLog(LogType type)
\r
607 _logger.EnableLog(type);
\r
610 public int MaterialLogInterval
\r
612 set => _logger.MaterialLogInterval = value;
\r
615 public string LogOutputDir
\r
617 set => _logger.OutputDir = value;
\r
620 public void FlashLog()
\r
622 _logger.FlashLog();
\r
626 public class NameAndTimer
\r
628 public string Name { get; set; }
\r
629 public RingTimer Timer { get; set; }
\r
631 public NameAndTimer()
\r
633 Timer = new RingTimer();
\r
637 public class RingTimer
\r
639 private readonly TimeSpan _spare;
\r
640 private bool _finished;
\r
642 public bool IsFinished(DateTime now) => EndTime != DateTime.MinValue && EndTime - now < _spare || _finished;
\r
644 public DateTime EndTime { get; private set; }
\r
646 public RingTimer(int spare = 60)
\r
648 _spare = TimeSpan.FromSeconds(spare);
\r
651 public void SetEndTime(double time)
\r
653 SetEndTime((int)time == 0
\r
654 ? DateTime.MinValue
\r
655 : new DateTime(1970, 1, 1).ToLocalTime().AddSeconds(time / 1000));
\r
658 public void SetEndTime(DateTime time)
\r
664 public void Finish()
\r
669 public bool CheckRing(DateTime prev, DateTime now)
\r
671 return EndTime != DateTime.MinValue && prev != DateTime.MinValue &&
\r
672 prev < EndTime -_spare && EndTime - _spare <= now;
\r
675 public string ToString(DateTime now, bool endTime = false)
\r
677 if (EndTime == DateTime.MinValue && !_finished)
\r
680 return EndTime.ToString(@"dd\ HH\:mm", CultureInfo.InvariantCulture);
\r
681 var rest = _finished || EndTime - now < TimeSpan.Zero ? TimeSpan.Zero : EndTime - now;
\r
682 return $"{(int)rest.TotalHours:d2}:" + rest.ToString(@"mm\:ss", CultureInfo.InvariantCulture);
\r