• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Révision28336d02272415cd3503d0c9e9c8ec3bfe4cb5ec (tree)
l'heure2019-07-22 20:50:09
AuteurKazuhiro Fujieda <fujieda@user...>
CommiterKazuhiro Fujieda

Message de Log

BattleLoggerのマップの処理の抽象度を上げる

Change Summary

Modification

--- a/KancolleSniffer.Test/LoggerTest.cs
+++ b/KancolleSniffer.Test/LoggerTest.cs
@@ -214,6 +214,8 @@ namespace KancolleSniffer.Test
214214 == result);
215215 }
216216
217+ private JsonObject Js(object obj) => JsonObject.CreateJsonObject(obj);
218+
217219 [TestMethod]
218220 public void Achievement()
219221 {
@@ -238,9 +240,9 @@ namespace KancolleSniffer.Test
238240 return (DateTime)dateEnum.Current;
239241 });
240242 for (var i = 0; i < 6; i++)
241- logger.InspectBasic(JsonParser.Parse($"{{\"api_experience\": {i * 1000}}}"));
242- logger.InspectBattleResult(JsonParser.Parse("{\"api_get_exmap_rate\": \"100\"}"));
243- logger.InspectMapNext(JsonParser.Parse("{\"api_get_eo_rate\": 75}"));
243+ logger.InspectBasic(Js(new{api_experience = i * 1000}));
244+ logger.InspectBattleResult(Js(new {api_get_exmap_rate = "100"}));
245+ logger.InspectMapNext(Js(new {api_maparea_id = 0, api_mapinfo_no = 0, api_no = 0, api_event_id = 0, api_get_eo_rate = 75}));
244246 PAssert.That(() =>
245247 "2017-03-31 21:00:00,0,0|2017-03-31 21:00:00,0,0|2017-03-31 22:00:00,1000,0|" +
246248 "2017-04-01 03:00:00,4000,0|2017-04-02 02:00:00,5000,0|" +
--- a/KancolleSniffer/Log/BattleLogger.cs
+++ b/KancolleSniffer/Log/BattleLogger.cs
@@ -26,8 +26,7 @@ namespace KancolleSniffer.Log
2626 private readonly BattleInfo _battleInfo;
2727 private readonly Action<string, string, string> _writer;
2828 private dynamic _battle;
29- private dynamic _map;
30- private bool _start;
29+ private readonly CellData _cell = new CellData();
3130
3231 public BattleLogger(ShipInfo shipInfo, ItemInfo itemInfo, BattleInfo battleInfo, Action<string, string, string> writer)
3332 {
@@ -37,16 +36,35 @@ namespace KancolleSniffer.Log
3736 _writer = writer;
3837 }
3938
39+ private class CellData
40+ {
41+ public bool Start;
42+ public bool Boss;
43+ public int Id;
44+ public int Area;
45+ public int Map;
46+ public int Cell;
47+
48+ public void Set(dynamic json)
49+ {
50+ Area = (int)json.api_maparea_id;
51+ Map = (int)json.api_mapinfo_no;
52+ Cell = json.api_no() ? (int)json.api_no : 0;
53+ Boss = (int)json.api_event_id == 5;
54+ Id = Area * 10 + Map;
55+ }
56+ }
57+
4058 public void InspectMapStart(dynamic json)
4159 {
42- _start = true;
43- _map = json;
60+ _cell.Start = true;
61+ _cell.Set(json);
4462 _battle = null;
4563 }
4664
4765 public void InspectMapNext(dynamic json)
4866 {
49- _map = json;
67+ _cell.Set(json);
5068 }
5169
5270 public void InspectBattle(dynamic json)
@@ -58,19 +76,18 @@ namespace KancolleSniffer.Log
5876
5977 public void InspectBattleResult(dynamic result)
6078 {
61- if (result.disabled() || _map == null || _battle == null)
79+ if (result.disabled() || _battle == null)
6280 {
63- _map = _battle = null;
81+ _battle = null;
6482 return;
6583 }
6684 var fShips = GenerateFriendShipList();
6785 var eShips = GenerateEnemyShipList();
68- var cell = (int)_map.api_no;
6986 var boss = "";
70- if (_start)
87+ if (_cell.Start)
7188 boss = "出撃";
72- if (cell == (int)_map.api_bosscell_no || (int)_map.api_event_id == 5)
73- boss = _start ? "出撃&ボス" : "ボス";
89+ if (_cell.Boss)
90+ boss = _cell.Start ? "出撃&ボス" : "ボス";
7491 var dropType = result.api_get_ship() ? result.api_get_ship.api_ship_type : "";
7592 if (result.api_get_useitem())
7693 {
@@ -92,7 +109,7 @@ namespace KancolleSniffer.Log
92109 var fPower = fp.Diff ? fp.RangeString : fp.Min.ToString();
93110 _writer("海戦・ドロップ報告書", string.Join(",",
94111 result.api_quest_name,
95- cell, boss,
112+ _cell.Cell, boss,
96113 result.api_win_rank,
97114 BattleFormationName((int)_battle.api_formation[2]),
98115 FormationName(_battle.api_formation[0]),
@@ -103,14 +120,14 @@ namespace KancolleSniffer.Log
103120 string.Join(",", eShips),
104121 fPower, _battleInfo.EnemyFighterPower.AirCombat + _battleInfo.EnemyFighterPower.UnknownMark,
105122 AirControlLevelName(_battle),
106- $"{(int)_map.api_maparea_id}-{(int)_map.api_mapinfo_no}"),
123+ $"{_cell.Area}-{_cell.Map}"),
107124 "日付,海域,マス,ボス,ランク,艦隊行動,味方陣形,敵陣形,敵艦隊,ドロップ艦種,ドロップ艦娘," +
108125 "味方艦1,味方艦1HP,味方艦2,味方艦2HP,味方艦3,味方艦3HP,味方艦4,味方艦4HP,味方艦5,味方艦5HP,味方艦6,味方艦6HP," +
109126 "敵艦1,敵艦1HP,敵艦2,敵艦2HP,敵艦3,敵艦3HP,敵艦4,敵艦4HP,敵艦5,敵艦5HP,敵艦6,敵艦6HP," +
110127 "味方制空値,敵制空値,制空状態,マップ"
111128 );
112- _map = _battle = null;
113- _start = false;
129+ _battle = null;
130+ _cell.Start = false;
114131 }
115132
116133 private IEnumerable<string> GenerateFriendShipList()