public void Initialize()\r
{\r
_itemInfo = new ItemInfo();\r
- _shipInfo = new ShipInfo(_itemInfo);\r
+ _shipInfo = new ShipInfo(new ShipMaster(), _itemInfo);\r
_battleInfo = new BattleInfo(_shipInfo, _itemInfo);\r
}\r
\r
[TestClass]\r
public class SnifferTest\r
{\r
- [TestInitialize]\r
- public void Intialize()\r
+ [ClassInitialize]\r
+ public static void Intialize(TestContext context)\r
{\r
ExpressionToCodeConfiguration.GlobalAssertionConfiguration = ExpressionToCodeConfiguration\r
.GlobalAssertionConfiguration.WithPrintedListLengthLimit(200).WithMaximumValueLength(1000);\r
[TestMethod]\r
public void TransportPoint()\r
{\r
- DataLoader.LoadTpSpec();\r
-\r
+ var sniffer = new Sniffer();\r
var msgs = new[] {"", "鬼怒改二+特大発+おにぎり", "駆逐艦+士魂部隊", "補給艦"};\r
var results = new[] {47, 19, 13, 15};\r
for (var i = 0; i < msgs.Length; i++)\r
{\r
- var sniffer = new Sniffer();\r
SniffLogFile(sniffer, "transportpoint_00" + (i + 1));\r
var j = i;\r
PAssert.That(() => (int)sniffer.Fleets[0].TransportPoint == results[j], msgs[j]);\r
\r
namespace KancolleSniffer\r
{\r
- public static class DataLoader\r
+ public class AdditionalData\r
{\r
private static readonly string EnemySlotFile =\r
Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "EnemySlot.csv");\r
\r
- private static Dictionary<int, int[]> _maxEq;\r
+ private Dictionary<int, int[]> _maxEq;\r
\r
- public static void LoadEnemySlot()\r
+ public void LoadEnemySlot()\r
{\r
try\r
{\r
}\r
}\r
\r
- public static int[] EnemySlot(int id) =>\r
+ public int[] EnemySlot(int id) =>\r
_maxEq != null ? _maxEq.TryGetValue(id, out var slot) ? slot : null : null;\r
\r
- private const string FileName = "TP.csv";\r
+ private const string TpFileName = "TP.csv";\r
\r
- private static readonly string TpFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, FileName);\r
+ private static readonly string TpFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, TpFileName);\r
\r
- private static Dictionary<int, double> _tpSpec;\r
+ private Dictionary<int, double> _tpSpec;\r
\r
- public static void LoadTpSpec()\r
+ public void LoadTpSpec()\r
{\r
try\r
{\r
}\r
catch (Exception ex)\r
{\r
- throw new Exception(FileName + "が壊れています。", ex);\r
+ throw new Exception(TpFileName + "が壊れています。", ex);\r
}\r
}\r
\r
- public static double ItemTp(int id) =>\r
+ public double ItemTp(int id) =>\r
_tpSpec != null ? _tpSpec.TryGetValue(id, out var tp) ? tp : -1 : -1;\r
}\r
}
\ No newline at end of file
// 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
}\r
}\r
\r
+ public Func<int, double?> GetItemTp { private get; set; }\r
+\r
public double TransportPoint\r
{\r
get\r
{\r
- var tp = DataLoader.ItemTp(Id);\r
+ var tp = GetItemTp?.Invoke(Id);\r
if (tp >= 0)\r
- return tp;\r
+ return (double)tp;\r
switch (Id)\r
{\r
case 75: // ドラム缶(輸送用)\r
MarginEquips = 10;\r
}\r
\r
+ public AdditionalData AdditionalData { get; set; }\r
+\r
public void InspectBasic(dynamic json)\r
{\r
MaxShips = (int)json.api_max_chara;\r
var dict = new Dictionary<int, string>();\r
foreach (var entry in json.api_mst_slotitem_equiptype)\r
dict[(int)entry.api_id] = entry.api_name;\r
+ AdditionalData?.LoadTpSpec();\r
foreach (var entry in json.api_mst_slotitem)\r
{\r
var type = (int)entry.api_type[2];\r
Bomber = (int)entry.api_baku,\r
Interception = type == 48 ? (int)entry.api_houk : 0, // 局地戦闘機は回避の値が迎撃\r
AntiBomber = type == 48 ? (int)entry.api_houm : 0, // 〃命中の値が対爆\r
- Distance = entry.api_distance() ? (int)entry.api_distance : 0\r
+ Distance = entry.api_distance() ? (int)entry.api_distance : 0,\r
+ GetItemTp = id => AdditionalData?.ItemTp(id)\r
};\r
}\r
_itemSpecs[-1] = _itemSpecs[0] = new ItemSpec();\r
<Compile Include="LogServer.cs" />\r
<Compile Include="MaterialInfo.cs" />\r
<Compile Include="MiscTextInfo.cs" />\r
- <Compile Include="DataLoader.cs" />\r
+ <Compile Include="AdditionalData.cs" />\r
<Compile Include="NotificationConfigDialog.cs">\r
<SubType>Form</SubType>\r
</Compile>\r
{\r
var target = "";\r
_sniffer.LoadState();\r
- DataLoader.LoadTpSpec();\r
_watcher.SynchronizingObject = this;\r
_watcherTimer.Tick += (sender, ev) =>\r
{\r
_sniffer.LoadState();\r
break;\r
case "TP.csv":\r
- DataLoader.LoadTpSpec();\r
+ _sniffer.AdditionalData.LoadTpSpec();\r
break;\r
}\r
};\r
\r
private readonly Fleet[] _fleets;\r
private readonly Dictionary<int, ShipStatus> _shipInfo = new Dictionary<int, ShipStatus>();\r
- private readonly ShipMaster _shipMaster = new ShipMaster();\r
+ private readonly ShipMaster _shipMaster;\r
private readonly ItemInfo _itemInfo;\r
private readonly List<int> _escapedShips = new List<int>();\r
private ShipStatus[] _battleResult = new ShipStatus[0];\r
}\r
}\r
\r
- public ShipInfo(ItemInfo itemInfo)\r
+ public ShipInfo(ShipMaster shipMaster, ItemInfo itemInfo)\r
{\r
+ _shipMaster = shipMaster;\r
_fleets = Enumerable.Range(0, FleetCount).Select((x, i) => new Fleet(this, i)).ToArray();\r
_itemInfo = itemInfo;\r
ClearShipInfo();\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
namespace KancolleSniffer\r
{\r
public const int NumSlots = 5;\r
private readonly Dictionary<int, ShipSpec> _shipSpecs = new Dictionary<int, ShipSpec>();\r
+ public AdditionalData AdditionalData { get; set; }\r
\r
public static bool IsEnemyId(int id) => id > 1500;\r
\r
foreach (var entry in json.api_mst_stype)\r
dict[entry.api_id] = entry.api_name;\r
dict[8] = "巡洋戦艦";\r
- DataLoader.LoadEnemySlot();\r
+ AdditionalData?.LoadEnemySlot();\r
foreach (var entry in json.api_mst_ship)\r
{\r
var shipSpec = _shipSpecs[(int)entry.api_id] = new ShipSpec\r
shipSpec.Remodel.Level = (int)entry.api_afterlv;\r
shipSpec.Remodel.After = int.Parse(entry.api_aftershipid);\r
}\r
- shipSpec.MaxEq = entry.api_maxeq()\r
- ? entry.api_maxeq\r
- : DataLoader.EnemySlot(shipSpec.Id);\r
+ shipSpec.GetMaxEq = entry.api_maxeq()\r
+ ? (Func<int[]>)(() => entry.api_maxeq)\r
+ : () => AdditionalData?.EnemySlot(shipSpec.Id);\r
}\r
_shipSpecs[-1] = new ShipSpec();\r
SetRemodelBaseAndStep();\r
public int FuelMax { get; set; }\r
public int BullMax { get; set; }\r
public int SlotNum { get; set; }\r
- public int[] MaxEq { get; set; }\r
+ public Func<int[]> GetMaxEq { get; set; }\r
+ public int[] MaxEq => GetMaxEq?.Invoke();\r
public int ShipType { get; set; }\r
public int ShipClass { get; set; }\r
public string ShipTypeName { get; set; }\r
{\r
Id = -1;\r
Name = "";\r
- MaxEq = new int[0];\r
}\r
\r
public double RepairWeight\r
private readonly MaterialInfo _materialInfo = new MaterialInfo();\r
private readonly QuestInfo _questInfo;\r
private readonly MissionInfo _missionInfo = new MissionInfo();\r
+ private readonly ShipMaster _shipMaster = new ShipMaster();\r
private readonly ShipInfo _shipInfo;\r
private readonly ConditionTimer _conditionTimer;\r
private readonly DockInfo _dockInfo;\r
private readonly Status _status = new Status();\r
private bool _saveState;\r
private readonly List<IHaveState> _haveState;\r
+ private AdditionalData _additionalData;\r
\r
public interface IRepeatingTimerController\r
{\r
public Sniffer(bool start = false)\r
{\r
_start = start;\r
- _shipInfo = new ShipInfo(_itemInfo);\r
+ _shipInfo = new ShipInfo(_shipMaster, _itemInfo);\r
_conditionTimer = new ConditionTimer(_shipInfo);\r
_dockInfo = new DockInfo(_shipInfo, _materialInfo);\r
_akashiTimer = new AkashiTimer(_shipInfo, _dockInfo, _presetDeck);\r
_baseAirCoprs = new BaseAirCoprs(_itemInfo);\r
_miscTextInfo = new MiscTextInfo(_shipInfo, _itemInfo);\r
_haveState = new List<IHaveState> {_achievement, _materialInfo, _conditionTimer, _exMapInfo, _questInfo};\r
+ AdditionalData = new AdditionalData();\r
+ }\r
+\r
+ public AdditionalData AdditionalData\r
+ {\r
+ get => _additionalData;\r
+ set\r
+ {\r
+ _additionalData = value;\r
+ _shipMaster.AdditionalData = value;\r
+ _itemInfo.AdditionalData = value;\r
+ }\r
}\r
\r
public void SaveState()\r