OSDN Git Service

海戦・ドロップ報告書にアイテムのドロップを記録する
authorKazuhiro Fujieda <fujieda@users.osdn.me>
Sun, 4 Oct 2015 08:35:07 +0000 (17:35 +0900)
committerKazuhiro Fujieda <fujieda@users.osdn.me>
Sun, 4 Oct 2015 08:35:07 +0000 (17:35 +0900)
KancolleSniffer.Test/LoggerTest.cs
KancolleSniffer/ItemInfo.cs
KancolleSniffer/Logger.cs

index 435a80d..b852950 100644 (file)
@@ -184,6 +184,24 @@ namespace KancolleSniffer.Test
         }\r
 \r
         [TestMethod]\r
+        public void InspectBattleResultDropItem()\r
+        {\r
+            var sniffer = new Sniffer();\r
+            var result = "";\r
+            sniffer.SetLogWriter((path, s, h) => { result += s + "|"; }, () => new DateTime(2015, 1, 1));\r
+            sniffer.EnableLog(LogType.Battle);\r
+            SnifferTest.SniffLogFile(sniffer, "dropitem_001");\r
+            PAssert.That(() =>\r
+                "2015-01-01 00:00:00,南西諸島防衛線,2,出撃,S,T字戦(有利),単縦陣,単縦陣,敵偵察艦隊,駆逐艦,白雪," +\r
+                "呂500(Lv56),13/13,伊168改(Lv97),15/15,伊58改(Lv97),18/18,伊8改(Lv97),19/19,伊19改(Lv97),18/18,伊401改(Lv99),24/24," +\r
+                "重巡リ級,0/58,軽巡ヘ級,0/36,駆逐イ級,0/20,駆逐イ級,0/20,駆逐イ級,0/20,,|" +\r
+                "2015-01-01 00:00:00,南西諸島防衛線,10,ボス,S,反航戦,単縦陣,輪形陣,敵機動部隊,アイテム,菱餅," +\r
+                "呂500(Lv56),13/13,伊168改(Lv97),15/15,伊58改(Lv97),18/18,伊8改(Lv97),19/19,伊19改(Lv97),18/18,伊401改(Lv99),24/24," +\r
+                "空母ヲ級,0/85,空母ヲ級,0/85,重巡リ級,0/58,軽巡ヘ級,0/36,駆逐ハ級,0/24,駆逐ハ級,0/24|"\r
+                == result);\r
+        }\r
+\r
+        [TestMethod]\r
         public void InspectMaterial()\r
         {\r
             var sniffer = new Sniffer();\r
index 2b2ab51..e5e85ee 100644 (file)
@@ -204,6 +204,7 @@ namespace KancolleSniffer
         private int _nowShips, _nowEquips;\r
         private readonly Dictionary<int, ItemSpec> _itemSpecs = new Dictionary<int, ItemSpec>();\r
         private readonly Dictionary<int, ItemStatus> _itemInfo = new Dictionary<int, ItemStatus>();\r
+        private readonly Dictionary<int, string> _useItemName = new Dictionary<int, string>();\r
         private bool _inPort;\r
         private DateTime _lastMission;\r
 \r
@@ -345,6 +346,8 @@ namespace KancolleSniffer
                 };\r
             }\r
             _itemSpecs[-1] = new ItemSpec();\r
+            foreach (var entry in json.api_mst_useitem)\r
+                _useItemName[(int)entry.api_id] = entry.api_name;\r
         }\r
 \r
         public void InspectSlotItem(dynamic json, bool full = false)\r
@@ -451,6 +454,8 @@ namespace KancolleSniffer
             }\r
         }\r
 \r
+        public string GetUseItemName(int id) => _useItemName[id];\r
+\r
         public void SaveState(Status status)\r
         {\r
             NeedSave = false;\r
index a3ee34a..5c70126 100644 (file)
@@ -165,6 +165,12 @@ namespace KancolleSniffer
                 boss = "出撃";\r
             if (cell == (int)_map.api_bosscell_no || (int)_map.api_event_id == 5)\r
                 boss = _start ? "出撃&ボス" : "ボス";\r
+            var dropType = result.api_get_ship()\r
+                ? result.api_get_ship.api_ship_type\r
+                : result.api_get_useitem() ? "アイテム" : "";\r
+            var dropName = result.api_get_ship()\r
+                ? result.api_get_ship.api_ship_name\r
+                : result.api_get_useitem() ? _itemInfo.GetUseItemName((int)result.api_get_useitem.api_useitem_id) : "";\r
             _writer("海戦・ドロップ報告書", string.Join(",", _nowFunc().ToString(DateTimeFormat),\r
                 result.api_quest_name,\r
                 cell, boss,\r
@@ -173,8 +179,7 @@ namespace KancolleSniffer
                 FormationName(_battle.api_formation[0]),\r
                 FormationName(_battle.api_formation[1]),\r
                 result.api_enemy_info.api_deck_name,\r
-                result.api_get_ship() ? result.api_get_ship.api_ship_type : "",\r
-                result.api_get_ship() ? result.api_get_ship.api_ship_name : "",\r
+                dropType, dropName,\r
                 string.Join(",", fships),\r
                 string.Join(",", eships)),\r
                 "日付,海域,マス,ボス,ランク,艦隊行動,味方陣形,敵陣形,敵艦隊,ドロップ艦種,ドロップ艦娘," +\r
@@ -333,9 +338,10 @@ namespace KancolleSniffer
             _writer("改修報告書",\r
                 now.ToString(DateTimeFormat) + "," +\r
                 string.Join(",", name, level, success, certain, useName, useNum,\r
-                diff[(int)Material.Fuel], diff[(int)Material.Bullet], diff[(int)Material.Steal], diff[(int)Material.Bouxite],\r
-                diff[(int)Material.Development], diff[(int)Material.Screw],\r
-                ship1, ship2),\r
+                    diff[(int)Material.Fuel], diff[(int)Material.Bullet], diff[(int)Material.Steal],\r
+                    diff[(int)Material.Bouxite],\r
+                    diff[(int)Material.Development], diff[(int)Material.Screw],\r
+                    ship1, ship2),\r
                 "日付,改修装備,レベル,成功,確実化,消費装備,消費数,燃料,弾薬,鋼材,ボーキ,開発資材,改修資材,秘書艦,二番艦");\r
         }\r
     }\r