コミットメタ情報

リビジョン8213caa4cdad0e13964aa7cec44a6b817a8933d3 (tree)
日時2018-07-30 20:50:31
作者Kazuhiro Fujieda <fujieda@user...>
コミッターKazuhiro Fujieda

ログメッセージ

IDを-1や0と直接比較するのをやめる

変更サマリ

差分

--- a/KancolleSniffer/Logger.cs
+++ b/KancolleSniffer/Logger.cs
@@ -303,24 +303,24 @@ namespace KancolleSniffer
303303 var result = _battleInfo.Result.Enemy.Main.Concat(Enumerable.Repeat(new ShipStatus(), 6)).Take(6);
304304 if (_battleInfo.Result.Enemy.Guard.Length == 0)
305305 {
306- return result.Select(s => s.Id == -1 ? "," : $"{s.Name},{s.NowHp}/{s.MaxHp}").ToList();
306+ return result.Select(s => s.Empty ? "," : $"{s.Name},{s.NowHp}/{s.MaxHp}").ToList();
307307 }
308308 var main = result;
309309 var guard = _battleInfo.Result.Enemy.Guard.Concat(Enumerable.Repeat(new ShipStatus(), 6)).Take(6);
310310 return main.Zip(guard, (m, g) =>
311311 {
312- if (m.Id == -1 && g.Id == -1)
312+ if (m.Empty && g.Empty)
313313 return ",";
314314 var name = "";
315315 var hp = "";
316- if (m.Id != -1)
316+ if (!m.Empty)
317317 {
318318 name = $"{m.Name}";
319319 hp = $"{m.NowHp}/{m.MaxHp}";
320320 }
321321 name += "・";
322322 hp += "・";
323- if (g.Id != -1)
323+ if (!g.Empty)
324324 {
325325 name += $"{g.Name}";
326326 hp += $"{g.NowHp}/{g.MaxHp}";
--- a/KancolleSniffer/Model/BaseAirCoprs.cs
+++ b/KancolleSniffer/Model/BaseAirCoprs.cs
@@ -174,7 +174,7 @@ namespace KancolleSniffer.Model
174174 {
175175 var planeId = (int)planeInfo.api_squadron_id - 1;
176176 var prev = airCorps.Planes[planeId];
177- if (prev.Slot.Id != -1)
177+ if (!prev.Slot.Empty)
178178 _relocationgPlanes.Add(prev.Slot.Id);
179179 airCorps.Planes[planeId] = new PlaneInfo
180180 {
--- a/KancolleSniffer/Model/ItemInfo.cs
+++ b/KancolleSniffer/Model/ItemInfo.cs
@@ -180,7 +180,7 @@ namespace KancolleSniffer.Model
180180 return itemIds.Select(itemId =>
181181 {
182182 var spec = _itemMaster[itemId];
183- if (spec.Id == -1)
183+ if (spec.Empty)
184184 {
185185 spec = new ItemSpec {Id = itemId};
186186 _itemMaster[itemId] = spec;
--- a/KancolleSniffer/Model/ItemSpec.cs
+++ b/KancolleSniffer/Model/ItemSpec.cs
@@ -21,6 +21,7 @@ namespace KancolleSniffer.Model
2121 {
2222 public static bool IncreaceLandPowerTp = false;
2323 public int Id;
24+ public bool Empty => Id == -1;
2425 public string Name;
2526 public int Type;
2627 public string TypeName;
--- a/KancolleSniffer/Model/ItemStatus.cs
+++ b/KancolleSniffer/Model/ItemStatus.cs
@@ -20,6 +20,8 @@ namespace KancolleSniffer.Model
2020 public class ItemStatus
2121 {
2222 public int Id { get; set; }
23+ public bool Empty => Id == -1;
24+ public bool Unimplemented => Id == 0;
2325 public ItemSpec Spec { get; set; } = new ItemSpec();
2426 public int Level { get; set; }
2527 public int Alv { get; set; }
--- a/KancolleSniffer/Model/ShipInfo.cs
+++ b/KancolleSniffer/Model/ShipInfo.cs
@@ -47,7 +47,7 @@ namespace KancolleSniffer.Model
4747 var spec = ship.Spec;
4848 if (spec.NumEquips != -1 || ship.Id <= MaxId)
4949 return;
50- spec.NumEquips = ship.Slot.Count(item => item.Id != -1);
50+ spec.NumEquips = ship.Slot.Count(item => !item.Empty);
5151 }
5252 }
5353
--- a/KancolleSniffer/Model/ShipStatus.cs
+++ b/KancolleSniffer/Model/ShipStatus.cs
@@ -22,6 +22,7 @@ namespace KancolleSniffer.Model
2222 public class ShipStatus : ICloneable
2323 {
2424 public int Id { get; set; }
25+ public bool Empty => Id == -1;
2526 public Fleet Fleet { get; set; }
2627 public int DeckIndex { get; set; }
2728 public ShipSpec Spec { get; set; }
@@ -286,7 +287,7 @@ namespace KancolleSniffer.Model
286287 {
287288 get
288289 {
289- if (AllSlot.All(item => item.Id == -1 || item.Id == 0))
290+ if (AllSlot.All(item => item.Empty || item.Unimplemented))
290291 return AntiAir;
291292 var vanilla = AntiAir - AllSlot.Sum(item => item.Spec.AntiAir);
292293 var x = vanilla + AllSlot.Sum(item => item.EffectiveAntiAirForShip);
--- a/KancolleSniffer/TextGenerator.cs
+++ b/KancolleSniffer/TextGenerator.cs
@@ -49,7 +49,7 @@ namespace KancolleSniffer
4949 => "区分,装備名,熟練度,改修,個数\r\n" +
5050 string.Join("\r\n",
5151 (from item in itemList
52- where item.Spec.Id != -1
52+ where !item.Spec.Empty
5353 orderby item.Spec.Type, item.Spec.Id, item.Alv, item.Level
5454 group item by
5555 $"{item.Spec.TypeName},{item.Spec.Name},{item.Alv},{item.Level}"
@@ -81,7 +81,7 @@ namespace KancolleSniffer
8181 select ($"{s.Name} Lv{s.Level} " +
8282 string.Join(",",
8383 from item in s.AllSlot
84- where item.Id != -1
84+ where !item.Empty
8585 select dict[item.Spec.Name] + ItemStatusString(item))).TrimEnd(' ') + "\r\n"));
8686 var fp = target.FighterPower;
8787 sb.Append($"制空: {(fp[0] == fp[1] ? fp[0].ToString() : fp[0] + "~" + fp[1])} " +
@@ -158,15 +158,15 @@ namespace KancolleSniffer
158158 for (var i = 0; i < items.Length; i++)
159159 {
160160 var item = items[i];
161- if (item.Id == -1)
161+ if (item.Empty)
162162 continue;
163163 if (i != 0)
164164 sb.Append(",");
165165 sb.Append($"\"i{i + 1}\":{{\"id\":{item.Spec.Id},\"rf\":{item.Level},\"mas\":{item.Alv}}}");
166166 }
167- if (ship.SlotEx.Id != 0 && ship.SlotEx.Id != -1)
167+ if (!ship.SlotEx.Unimplemented && !ship.SlotEx.Empty)
168168 {
169- if (ship.Slot.Any(item => item.Id != -1))
169+ if (ship.Slot.Any(item => !item.Empty))
170170 sb.Append(",");
171171 var name = ship.Spec.SlotNum == 5 ? "ix" : $"i{ship.Spec.SlotNum + 1}";
172172 sb.Append($"\"{name}\":{{\"id\":{ship.SlotEx.Spec.Id},\"rf\":{ship.SlotEx.Level}}}");
--- a/KancolleSniffer/View/BattleResultPanel.cs
+++ b/KancolleSniffer/View/BattleResultPanel.cs
@@ -264,7 +264,7 @@ namespace KancolleSniffer.View
264264 var result =
265265 (from i in Enumerable.Range(0, ship.Slot.Length)
266266 let item = ship.Slot[i]
267- where item.Id != -1
267+ where !item.Empty
268268 select item.Spec.Name + (item.Spec.IsAircraft && ship.OnSlot.Length > 0 && ship.Spec.MaxEq.Length > 0
269269 ? $"{ship.OnSlot[i]}/{ship.Spec.MaxEq[i]}"
270270 : ""));
--- a/KancolleSniffer/View/FleetPanel.cs
+++ b/KancolleSniffer/View/FleetPanel.cs
@@ -103,7 +103,7 @@ namespace KancolleSniffer.View
103103 var item = s.Slot[i];
104104 var onslot = s.OnSlot[i];
105105 var max = s.Spec.MaxEq[i];
106- if (item.Id == -1)
106+ if (item.Empty)
107107 continue;
108108 var airspec = "";
109109 if (item.Spec.IsDiveBomber) // 爆撃
--- a/KancolleSniffer/View/ItemTreeView.cs
+++ b/KancolleSniffer/View/ItemTreeView.cs
@@ -37,7 +37,7 @@ namespace KancolleSniffer.View
3737 private TreeNode CreateItemNodes(IEnumerable<ItemStatus> itemList)
3838 {
3939 var grouped = from item in itemList
40- where item.Spec.Id != -1
40+ where !item.Spec.Empty
4141 orderby item.Spec.Type, item.Spec.Id, item.Alv, item.Level
4242 group item by item.Spec.Type
4343 into byTypeGroup
@@ -85,7 +85,7 @@ namespace KancolleSniffer.View
8585 foreach (var byShip in byParam)
8686 {
8787 var ship = byShip.First().Holder;
88- var name = byShip.Key == -1
88+ var name = ship.Empty
8989 ? "未装備x" + byShip.Count()
9090 : (ship.Fleet == null ? "" : ship.Fleet.Number + 1 + " ") +
9191 ship.Name + (ship.Level > 0 ? "Lv" + ship.Level : "") + "x" + byShip.Count();
--- a/KancolleSniffer/View/ShipLabel.cs
+++ b/KancolleSniffer/View/ShipLabel.cs
@@ -65,11 +65,11 @@ namespace KancolleSniffer.View
6565 return;
6666 }
6767 var empty = SlotStatus.Equipped;
68- if (status.Id != -1)
68+ if (!status.Empty)
6969 {
70- if (status.Slot.All(item => item.Id == -1))
70+ if (status.Slot.All(item => item.Empty))
7171 empty |= SlotStatus.NormalEmpty;
72- if (status.SlotEx.Id == -1)
72+ if (status.SlotEx.Empty)
7373 empty |= SlotStatus.ExtraEmpty;
7474 }
7575 var dc = status.PreparedDamageControl;
旧リポジトリブラウザで表示