コミットメタ情報

リビジョン2bc419d6c2040ede457555537b6ebcc1cbe563d4 (tree)
日時2018-11-16 23:45:28
作者Kazuhiro Fujieda <fujieda@user...>
コミッターKazuhiro Fujieda

ログメッセージ

基地航空隊の仕様変更が原因で海域選択でエラーになるのを直す

変更サマリ

差分

--- a/KancolleSniffer/Model/BaseAirCoprs.cs
+++ b/KancolleSniffer/Model/BaseAirCoprs.cs
@@ -46,9 +46,17 @@ namespace KancolleSniffer.Model
4646 public bool IsInterceptor => AirCombat[0] != Interception[0];
4747 }
4848
49+ public class Distance
50+ {
51+ public int Base { get; set; }
52+ public int Bonus { get; set; }
53+
54+ public override string ToString() => Bonus > 0 ? $"{Base}+{Bonus}" : Base.ToString();
55+ }
56+
4957 public class AirCorpsInfo
5058 {
51- public int Distance { get; set; }
59+ public Distance Distance { get; set; }
5260 public int Action { get; set; }
5361 public PlaneInfo[] Planes { get; set; }
5462
@@ -147,7 +155,7 @@ namespace KancolleSniffer.Model
147155 group
148156 new AirCorpsInfo
149157 {
150- Distance = (int)entry.api_distance,
158+ Distance = CreateDistance(entry.api_distance),
151159 Action = (int)entry.api_action_kind,
152160 Planes = (from plane in (dynamic[])entry.api_plane_info
153161 select new PlaneInfo
@@ -169,7 +177,7 @@ namespace KancolleSniffer.Model
169177 var values = HttpUtility.ParseQueryString(request);
170178 var airCorps = GetBaseInfo(values).AirCorps[int.Parse(values["api_base_id"]) - 1];
171179 if (json.api_distance()) // 2016春イベにはない
172- airCorps.Distance = (int)json.api_distance;
180+ airCorps.Distance = CreateDistance(json.api_distance);
173181 foreach (var planeInfo in json.api_plane_info)
174182 {
175183 var planeId = (int)planeInfo.api_squadron_id - 1;
@@ -186,6 +194,11 @@ namespace KancolleSniffer.Model
186194 }
187195 }
188196
197+ private Distance CreateDistance(dynamic distance) => distance is double
198+ // ReSharper disable once PossibleInvalidCastException
199+ ? new Distance {Base = (int)distance}
200+ : new Distance {Base = (int)distance.api_base, Bonus = (int)distance.api_bonus};
201+
189202 public void InspectSupply(string request, dynamic json)
190203 {
191204 InspectSetPlane(request, json);
--- a/KancolleSniffer/View/FleetPanel.cs
+++ b/KancolleSniffer/View/FleetPanel.cs
@@ -211,7 +211,7 @@ namespace KancolleSniffer.View
211211 {
212212 Ship = name[i++] + " " + airCorps.ActionName,
213213 Ship2 = $"出撃コスト:燃{cost[0]}弾{cost[1]}",
214- Spec = spec + " 距離:" + airCorps.Distance,
214+ Spec = spec + $" 距離:{airCorps.Distance}",
215215 Spec2 = spec2
216216 });
217217 list.AddRange(airCorps.Planes.Select(plane =>
旧リポジトリブラウザで表示