コミットメタ情報

リビジョンd07f46c2328cf9c003d0e9a7aa351396db5e3131 (tree)
日時2018-08-02 17:30:16
作者Kazuhiro Fujieda <fujieda@user...>
コミッターKazuhiro Fujieda

ログメッセージ

DockInfoからShipInfoへの依存をなくす

変更サマリ

差分

--- a/KancolleSniffer/Model/DockInfo.cs
+++ b/KancolleSniffer/Model/DockInfo.cs
@@ -21,15 +21,15 @@ namespace KancolleSniffer.Model
2121 public class DockInfo
2222 {
2323 public const int DockCount = 4;
24- private readonly ShipInfo _shipInfo;
24+ private readonly ShipInventry _shipInventry;
2525 private readonly MaterialInfo _materialInfo;
2626 private readonly int[] _ndoc = new int[DockCount];
2727 private readonly AlarmTimer[] _ndocTimers = new AlarmTimer[DockCount];
2828 private readonly AlarmTimer[] _kdocTimers = new AlarmTimer[DockCount];
2929
30- public DockInfo(ShipInfo ship, MaterialInfo material)
30+ public DockInfo(ShipInventry shipInventry, MaterialInfo material)
3131 {
32- _shipInfo = ship;
32+ _shipInventry = shipInventry;
3333 _materialInfo = material;
3434 for (var i = 0; i < _ndocTimers.Length; i++)
3535 _ndocTimers[i] = new AlarmTimer();
@@ -46,7 +46,7 @@ namespace KancolleSniffer.Model
4646 var prev = _ndoc[id];
4747 _ndoc[id] = (int)entry.api_ship_id;
4848 if (prev != 0 && _ndoc[id] == 0) // 修復完了
49- _shipInfo.RepairShip(prev);
49+ _shipInventry[prev].RepairShip();
5050 }
5151 }
5252
@@ -54,25 +54,25 @@ namespace KancolleSniffer.Model
5454 {
5555 var values = HttpUtility.ParseQueryString(request);
5656 var id = int.Parse(values["api_ship_id"]);
57- var ship = _shipInfo.GetStatus(id);
57+ var ship = _shipInventry[id];
5858 var m = ship.NdockItem;
5959 _materialInfo.SubMaterial(Material.Fuel, m[0]);
6060 _materialInfo.SubMaterial(Material.Steal, m[1]);
6161 if (int.Parse(values["api_highspeed"]) == 1)
6262 {
63- _shipInfo.RepairShip(id);
63+ ship.RepairShip();
6464 _materialInfo.SubMaterial(Material.Bucket, 1);
6565 return;
6666 }
6767 if (ship.RepairTime.CompareTo(TimeSpan.FromMinutes(1)) <= 0)
68- _shipInfo.RepairShip(id);
68+ ship.RepairShip();
6969 }
7070
7171 public void InspectSpeedChange(string request)
7272 {
7373 var values = HttpUtility.ParseQueryString(request);
7474 var dock = int.Parse(values["api_ndock_id"]) - 1;
75- _shipInfo.RepairShip(_ndoc[dock]);
75+ _shipInventry[_ndoc[dock]].RepairShip();
7676 _ndoc[dock] = 0;
7777 _ndocTimers[dock].SetEndTime(0);
7878 _materialInfo.SubMaterial(Material.Bucket, 1);
@@ -80,7 +80,7 @@ namespace KancolleSniffer.Model
8080
8181 public NameAndTimer[] NDock
8282 => _ndoc.Zip(_ndocTimers,
83- (id, timer) => new NameAndTimer {Name = id == 0 ? "" : _shipInfo.GetStatus(id).Name, Timer = timer}).ToArray();
83+ (id, timer) => new NameAndTimer {Name = id == 0 ? "" : _shipInventry[id].Name, Timer = timer}).ToArray();
8484
8585 public bool InNDock(int id) => _ndoc.Any(n => n == id); // 空のドックのidは0
8686
--- a/KancolleSniffer/Model/ShipInfo.cs
+++ b/KancolleSniffer/Model/ShipInfo.cs
@@ -16,7 +16,6 @@ using System;
1616 using System.Collections.Generic;
1717 using System.Linq;
1818 using KancolleSniffer.Util;
19-using static System.Math;
2019
2120 namespace KancolleSniffer.Model
2221 {
@@ -329,13 +328,6 @@ namespace KancolleSniffer.Model
329328 _fleets[fleet].State = FleetState.Practice;
330329 }
331330
332- public void RepairShip(int id)
333- {
334- var s = _shipInventry[id];
335- s.NowHp = s.MaxHp;
336- s.Cond = Max(40, s.Cond);
337- }
338-
339331 public Fleet[] Fleets => _fleets;
340332
341333 public ShipStatus GetStatus(int id) => FillUp(_shipInventry[id]);
--- a/KancolleSniffer/Model/ShipStatus.cs
+++ b/KancolleSniffer/Model/ShipStatus.cs
@@ -88,6 +88,12 @@ namespace KancolleSniffer.Model
8888 Sunk
8989 }
9090
91+ public void RepairShip()
92+ {
93+ NowHp = MaxHp;
94+ Cond = Max(40, Cond);
95+ }
96+
9197 public static Damage CalcDamage(int now, int max)
9298 {
9399 if (now == 0 && max > 0)
--- a/KancolleSniffer/Sniffer.cs
+++ b/KancolleSniffer/Sniffer.cs
@@ -82,7 +82,7 @@ namespace KancolleSniffer
8282 _itemInfo = new ItemInfo(_itemMaster, _itemInventry);
8383 _shipInfo = new ShipInfo(_shipMaster, _shipInventry, _itemInventry);
8484 _conditionTimer = new ConditionTimer(_shipInfo);
85- _dockInfo = new DockInfo(_shipInfo, _materialInfo);
85+ _dockInfo = new DockInfo(_shipInventry, _materialInfo);
8686 _akashiTimer = new AkashiTimer(_shipInfo, _dockInfo, _presetDeck);
8787 _battleInfo = new BattleInfo(_shipInfo, _itemInfo);
8888 _logger = new Logger(_shipInfo, _itemInfo, _battleInfo);
旧リポジトリブラウザで表示