コミットメタ情報

リビジョン87743ea162d2c728ba529e9ec08a1aa1df9ee561 (tree)
日時2018-03-24 20:29:54
作者Kazuhiro Fujieda <fujieda@user...>
コミッターKazuhiro Fujieda

ログメッセージ

ダメコンの発動が戦闘結果の計算に反映されないことがあるのを直す

変更サマリ

差分

--- a/KancolleSniffer.Test/BattleTest.cs
+++ b/KancolleSniffer.Test/BattleTest.cs
@@ -113,5 +113,20 @@ namespace KancolleSniffer.Test
113113 _battleInfo.InspectBattleResult(Data(logs[6]));
114114 PAssert.That(() => !_battleInfo.DisplayedResultRank.IsError);
115115 }
116+
117+ /// <summary>
118+ /// 機動対敵連合の雷撃戦でダメコンが発動する
119+ /// </summary>
120+ [TestMethod]
121+ public void TreiggerDameconInCombinedBattle()
122+ {
123+ var logs = ReadAllLines("damecon_002");
124+ var battle = Data(logs[3]);
125+ _shipInfo.InjectShips(battle, JsonParser.Parse(logs[0]));
126+ _battleInfo.InspectBattle(logs[1], logs[2], battle);
127+ _battleInfo.InspectBattle(logs[4], logs[5], Data(logs[6]));
128+ _battleInfo.InspectBattleResult(Data(logs[9]));
129+ PAssert.That(() => !_battleInfo.DisplayedResultRank.IsError);
130+ }
116131 }
117132 }
\ No newline at end of file
--- a/KancolleSniffer.Test/logs
+++ b/KancolleSniffer.Test/logs
@@ -1 +1 @@
1-Subproject commit f928f55f2d3299e981e25b57426f46b8f4c2b7a0
1+Subproject commit 94f121ea3ba75db7d87910efa59d9146fb8255e0
--- a/KancolleSniffer/BattleInfo.cs
+++ b/KancolleSniffer/BattleInfo.cs
@@ -255,83 +255,71 @@ namespace KancolleSniffer
255255 return result;
256256 }
257257
258- private enum CombatType
259- {
260- AtOnce,
261- ByTurn,
262- Support,
263- Aircraft,
264- AirBase,
265- Friend
266- }
267-
268- private class Phase
269- {
270- public string Api { get; }
271- public CombatType Type { get; }
272- public string Name { get; }
273-
274- public Phase(string api, CombatType type, string name = "")
275- {
276- Api = api;
277- Type = type;
278- Name = name;
279- }
280- }
281-
282258 private void CalcDamage(dynamic json)
283259 {
284260 AirBattleResults.Clear();
285- var phases = new[]
261+ foreach (KeyValuePair<string, dynamic> kv in json)
286262 {
287- new Phase("air_base_injection", CombatType.Aircraft, "AB噴式"),
288- new Phase("injection_kouku", CombatType.Aircraft, "噴式"),
289- new Phase("air_base_attack", CombatType.AirBase),
290- new Phase("n_support_info", CombatType.Support),
291- new Phase("n_hougeki1", CombatType.ByTurn),
292- new Phase("n_hougeki2", CombatType.ByTurn),
293- new Phase("kouku", CombatType.Aircraft, "航空戦"),
294- new Phase("kouku2", CombatType.Aircraft, "航空戦2"),
295- new Phase("support_info", CombatType.Support),
296- new Phase("opening_taisen", CombatType.ByTurn),
297- new Phase("opening_atack", CombatType.AtOnce),
298- new Phase("friendly_battle", CombatType.Friend),
299- new Phase("hougeki", CombatType.ByTurn),
300- new Phase("hougeki1", CombatType.ByTurn),
301- new Phase("hougeki2", CombatType.ByTurn),
302- new Phase("hougeki3", CombatType.ByTurn),
303- new Phase("raigeki", CombatType.AtOnce)
304- };
305- foreach (var phase in phases)
306- CalcDamageByType(json, phase);
307- }
308-
309- private void CalcDamageByType(dynamic json, Phase phase)
310- {
311- var api = "api_" + phase.Api;
312- if (!json.IsDefined(api) || json[api] == null)
313- return;
314- switch (phase.Type)
315- {
316- case CombatType.AtOnce:
317- CalcDamageAtOnce(json[api]);
318- break;
319- case CombatType.ByTurn:
320- CalcDamageByTurn(json[api]);
321- break;
322- case CombatType.Support:
323- CalcSupportDamage(json[api]);
324- break;
325- case CombatType.Aircraft:
326- AddAirBattleResult(json[api], phase.Name);
327- CalcKoukuDamage(json[api]);
328- break;
329- case CombatType.AirBase:
330- CalcAirBaseAttackDamage(json[api]);
331- break;
332- case CombatType.Friend:
333- CalcFriendAttackDamage(json[api]);
334- break;
263+ if (kv.Value == null)
264+ continue;
265+ switch (kv.Key)
266+ {
267+ case "api_air_base_injection":
268+ AddAirBattleResult(kv.Value, "AB噴式");
269+ CalcKoukuDamage(kv.Value);
270+ break;
271+ case "api_injection_kouku":
272+ AddAirBattleResult(kv.Value, "噴式");
273+ CalcKoukuDamage(kv.Value);
274+ break;
275+ case "api_air_base_attack":
276+ CalcAirBaseAttackDamage(kv.Value);
277+ break;
278+ case "api_n_support_info":
279+ CalcSupportDamage(kv.Value);
280+ break;
281+ case "api_n_hougeki1":
282+ CalcDamageByTurn(kv.Value);
283+ break;
284+ case "api_n_hougeki2":
285+ CalcDamageByTurn(kv.Value);
286+ break;
287+ case "api_kouku":
288+ AddAirBattleResult(kv.Value, "航空戦");
289+ CalcKoukuDamage(kv.Value);
290+ break;
291+ case "api_kouku2":
292+ AddAirBattleResult(kv.Value, "航空戦2");
293+ CalcKoukuDamage(kv.Value);
294+ break;
295+ case "api_support_info":
296+ CalcSupportDamage(kv.Value);
297+ break;
298+ case "api_opening_taisen":
299+ CalcDamageByTurn(kv.Value);
300+ break;
301+ case "api_opening_atack":
302+ CalcDamageAtOnce(kv.Value);
303+ break;
304+ case "api_friendly_battle":
305+ CalcFriendAttackDamage(kv.Value);
306+ break;
307+ case "api_hougeki":
308+ CalcDamageByTurn(kv.Value);
309+ break;
310+ case "api_hougeki1":
311+ CalcDamageByTurn(kv.Value);
312+ break;
313+ case "api_hougeki2":
314+ CalcDamageByTurn(kv.Value);
315+ break;
316+ case "api_hougeki3":
317+ CalcDamageByTurn(kv.Value);
318+ break;
319+ case "api_raigeki":
320+ CalcDamageAtOnce(kv.Value);
321+ break;
322+ }
335323 }
336324 }
337325
@@ -692,11 +680,12 @@ namespace KancolleSniffer
692680 /// <summary>
693681 /// テスト専用
694682 /// </summary>
695- public void InjectResultStatus(ShipStatus[] main, ShipStatus[] guard, ShipStatus[] enemy, ShipStatus[] enemyGuard)
683+ public void InjectResultStatus(ShipStatus[] main, ShipStatus[] guard, ShipStatus[] enemy,
684+ ShipStatus[] enemyGuard)
696685 {
697686 Result = new BattleResult
698687 {
699- Friend = new BattleResult.Combined { Main = main, Guard = guard},
688+ Friend = new BattleResult.Combined {Main = main, Guard = guard},
700689 Enemy = new BattleResult.Combined {Main = enemy, Guard = enemyGuard}
701690 };
702691 }
旧リポジトリブラウザで表示