OSDN Git Service

装備のTPをTP.csvから読み込む
authorKazuhiro Fujieda <fujieda@users.osdn.me>
Sun, 25 Feb 2018 05:56:48 +0000 (14:56 +0900)
committerKazuhiro Fujieda <fujieda@users.osdn.me>
Mon, 26 Feb 2018 12:59:54 +0000 (21:59 +0900)
Data/TP.csv [new file with mode: 0644]
KancolleSniffer.Test/KancolleSniffer.Test.csproj
KancolleSniffer.Test/SnifferTest.cs
KancolleSniffer/ItemInfo.cs
KancolleSniffer/KancolleSniffer.csproj
KancolleSniffer/MainForm.cs

diff --git a/Data/TP.csv b/Data/TP.csv
new file mode 100644 (file)
index 0000000..36b9d10
--- /dev/null
@@ -0,0 +1,9 @@
+75,ドラム缶(輸送用),5.0\r
+68,大発動艇,8.0\r
+193,特大発動艇,8.0\r
+166,大発動艇(八九式中戦車&陸戦隊),8.0\r
+230,特大発動艇+戦車第11連隊,8.0\r
+167,特二式内火艇,2.0\r
+145,戦闘糧食,1.0\r
+150,秋刀魚の缶詰,1.0\r
+241,戦闘糧食(特別なおにぎり),1.0\r
index 7c83474..8cc1d24 100644 (file)
   <Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />\r
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
   <PropertyGroup>\r
-    <PostBuildEvent>COPY $(SolutionDir)\Data\EnemySlot.csv $(TargetDir)</PostBuildEvent>\r
+    <PostBuildEvent>COPY $(SolutionDir)\Data\*.* $(TargetDir)</PostBuildEvent>\r
   </PropertyGroup>\r
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r
        Other similar extension points exist, see Microsoft.Common.targets.\r
index 30e6901..6dd945d 100644 (file)
@@ -330,12 +330,11 @@ namespace KancolleSniffer.Test
         [TestMethod]\r
         public void TransportPoint()\r
         {\r
+            ItemSpec.LoadTpSpec();\r
+\r
             var sniffer1 = new Sniffer();\r
             SniffLogFile(sniffer1, "transportpoint_001");\r
-            ItemSpec.IncreaceLandPowerTp = false;\r
             PAssert.That(() => (int)sniffer1.GetShipStatuses(0).Sum(s => s.TransportPoint) == 27);\r
-            ItemSpec.IncreaceLandPowerTp = true;\r
-            PAssert.That(() => (int)sniffer1.GetShipStatuses(0).Sum(s => s.TransportPoint) == 37, "陸上戦力揚陸時");\r
 \r
             var sniffer2 = new Sniffer();\r
             SniffLogFile(sniffer2, "transportpoint_002");\r
index 26d036a..2f66139 100644 (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.IO;\r
 using System.Linq;\r
 using static System.Math;\r
 \r
@@ -157,10 +159,27 @@ namespace KancolleSniffer
             }\r
         }\r
 \r
+        private static Dictionary<int, double> _tpSpec;\r
+\r
+        public static void LoadTpSpec()\r
+        {\r
+            try\r
+            {\r
+                _tpSpec = File.ReadAllLines(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TP.csv"))\r
+                    .Select(line => line.Split(','))\r
+                    .ToDictionary(f => int.Parse(f[0]), f => double.Parse(f[2]));\r
+            }\r
+            catch (IOException)\r
+            {\r
+            }\r
+        }\r
+\r
         public double TransportPoint\r
         {\r
             get\r
             {\r
+                if (_tpSpec != null && _tpSpec.TryGetValue(Id, out var tp))\r
+                    return tp;\r
                 switch (Id)\r
                 {\r
                     case 75: // ドラム缶(輸送用)\r
@@ -170,15 +189,17 @@ namespace KancolleSniffer
                     case 193: // 特大発動艇\r
                         return 8.0;\r
                     case 166: // 大発動艇(八九式中戦車&陸戦隊)\r
-                        return IncreaceLandPowerTp ? 13.0 : 8.0;\r
+                        return 8.0;\r
                     case 167: // 特二式内火艇\r
-                        return IncreaceLandPowerTp ? 7.0 : 2.0;\r
+                        return 2.0;\r
                     case 230: // 特大発動艇+戦車第11連隊\r
                         return 8.0;\r
                     case 145: // 戦闘糧食\r
                         return 1.0;\r
                     case 150: // 秋刀魚の缶詰\r
                         return 1.0;\r
+                    case 241: // 戦闘糧食(特別なおにぎり)\r
+                        return 1.0;\r
                     default:\r
                         return 0;\r
                 }\r
@@ -195,7 +216,8 @@ namespace KancolleSniffer
                         return LoS <= 7 ? 1.2 : 1.3;\r
                     case 10:\r
                     case 41:\r
-                        return LoS <= 7 ? 1.1 : LoS <= 8 ? 1.13 : 1.16;\r
+                        return LoS <= 7 ? 1.1 :\r
+                            LoS <= 8 ? 1.13 : 1.16;\r
                 }\r
                 return 1;\r
             }\r
index 8b04604..85fcddd 100644 (file)
   </ItemGroup>\r
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
   <PropertyGroup>\r
-    <PostBuildEvent>COPY $(SolutionDir)\Data\EnemySlot.csv $(TargetDir)</PostBuildEvent>\r
+    <PostBuildEvent>COPY $(SolutionDir)\Data\*.* $(TargetDir)</PostBuildEvent>\r
   </PropertyGroup>\r
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r
        Other similar extension points exist, see Microsoft.Common.targets.\r
index 2d2dcdc..72d55fe 100644 (file)
@@ -90,7 +90,7 @@ namespace KancolleSniffer
             _proxyManager.UpdatePacFile();\r
             PerformZoom();\r
             _shipLabels.AdjustAkashiTimers();\r
-            LoadState();\r
+            LoadData();\r
             _sniffer.RepeatingTimerController = new RepeatingTimerController(_notificationManager, _config);\r
         }\r
 \r
@@ -110,23 +110,33 @@ namespace KancolleSniffer
         private readonly FileSystemWatcher _watcher = new FileSystemWatcher\r
         {\r
             Path = AppDomain.CurrentDomain.BaseDirectory,\r
-            Filter = "status.xml",\r
             NotifyFilter = NotifyFilters.LastWrite\r
         };\r
 \r
         private readonly Timer _watcherTimer = new Timer {Interval = 1000};\r
 \r
-        private void LoadState()\r
+        private void LoadData()\r
         {\r
+            var target = "";\r
             _sniffer.LoadState();\r
+            ItemSpec.LoadTpSpec();\r
             _watcher.SynchronizingObject = this;\r
             _watcherTimer.Tick += (sender, ev) =>\r
             {\r
                 _watcherTimer.Stop();\r
-                _sniffer.LoadState();\r
+                switch (target)\r
+                {\r
+                    case "status.xml":\r
+                        _sniffer.LoadState();\r
+                        break;\r
+                    case "TP.csv":\r
+                        ItemSpec.LoadTpSpec();\r
+                        break;\r
+                }\r
             };\r
             _watcher.Changed += (sender, ev) =>\r
             {\r
+                target = ev.Name;\r
                 _watcherTimer.Stop();\r
                 _watcherTimer.Start();\r
             };\r