1 // Copyright (C) 2018 Kazuhiro Fujieda <fujieda@users.osdn.me>
\r
3 // Licensed under the Apache License, Version 2.0 (the "License");
\r
4 // you may not use this file except in compliance with the License.
\r
5 // You may obtain a copy of the License at
\r
7 // http://www.apache.org/licenses/LICENSE-2.0
\r
9 // Unless required by applicable law or agreed to in writing, software
\r
10 // distributed under the License is distributed on an "AS IS" BASIS,
\r
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
12 // See the License for the specific language governing permissions and
\r
13 // limitations under the License.
\r
18 namespace KancolleSniffer.Model
\r
20 public class ItemStatus
\r
22 public int Id { get; set; }
\r
23 public bool Empty => Id == -1;
\r
24 public bool Unimplemented => Id == 0;
\r
25 public ItemSpec Spec { get; set; } = new ItemSpec();
\r
26 public int Level { get; set; }
\r
27 public int Alv { get; set; }
\r
28 public ShipStatus Holder { get; set; }
\r
35 public ItemStatus(int id)
\r
40 public int[] CalcFighterPower(int slot)
\r
42 if (!Spec.CanAirCombat || slot == 0)
\r
43 return new[] {0, 0};
\r
44 var unskilled = (Spec.AntiAir + FighterPowerLevelBonus) * Math.Sqrt(slot);
\r
45 return AlvBonus.Select(bonus => (int)(unskilled + bonus)).ToArray();
\r
48 public int[] CalcFighterPowerInBase(int slot, bool airDefense)
\r
50 if (!Spec.IsAircraft || slot == 0)
\r
51 return new[] {0, 0};
\r
52 var airDefenseBonus = airDefense ? Spec.AntiBomber * 2 + Spec.Interception : Spec.Interception * 1.5;
\r
53 var unskilled = (Spec.AntiAir + airDefenseBonus + FighterPowerLevelBonus) * Math.Sqrt(slot);
\r
54 return AlvBonusInBase.Select(bonus => (int)(unskilled + bonus)).ToArray();
\r
57 private readonly double[] _alvBonusMin =
\r
59 Math.Sqrt(0.0), Math.Sqrt(1.0), Math.Sqrt(2.5), Math.Sqrt(4.0), Math.Sqrt(5.5), Math.Sqrt(7.0),
\r
60 Math.Sqrt(8.5), Math.Sqrt(10.0)
\r
63 private readonly double[] _alvBonusMax =
\r
65 Math.Sqrt(0.9), Math.Sqrt(2.4), Math.Sqrt(3.9), Math.Sqrt(5.4), Math.Sqrt(6.9), Math.Sqrt(8.4),
\r
66 Math.Sqrt(9.9), Math.Sqrt(12.0)
\r
69 private int[] AlvTypeBonusTable
\r
79 return new[] {0, 0, 2, 5, 9, 14, 14, 22};
\r
85 return new[] {0, 0, 0, 0, 0, 0, 0, 0};
\r
87 return new[] {0, 0, 1, 1, 1, 3, 3, 6};
\r
94 private double[] AlvBonus
\r
98 var table = AlvTypeBonusTable;
\r
100 return new[] {0.0, 0.0};
\r
101 return new[] {table[Alv] + _alvBonusMin[Alv], table[Alv] + _alvBonusMax[Alv]};
\r
105 private double[] AlvBonusInBase
\r
114 return new[] {_alvBonusMin[Alv], _alvBonusMax[Alv]};
\r
121 private double FighterPowerLevelBonus
\r
130 return 0.2 * Level;
\r
131 case 7: // 改修可能なのは爆戦のみ
\r
132 return 0.25 * Level;
\r
138 public double LoSLevelBonus
\r
145 return 1.2 * Math.Sqrt(Level);
\r
147 return 1.15 * Math.Sqrt(Level);
\r
149 return 1.25 * Math.Sqrt(Level);
\r
151 return 1.4 * Math.Sqrt(Level);
\r
152 case 94: // 艦上偵察機(II)
\r
153 return 1.2 * Math.Sqrt(Level);
\r
160 public double FirepowerLevelBonus
\r
175 return Math.Sqrt(Level);
\r
177 return 1.5 * Math.Sqrt(Level);
\r
179 return SecondaryGunLevelBonus;
\r
182 return Spec.Id == 226 // 九五式爆雷
\r
184 : 0.75 * Math.Sqrt(Level);
\r
191 public double SecondaryGunLevelBonus
\r
197 case 10: // 12.7cm連装高角砲
\r
199 case 220: // 8cm高角砲改+増設機銃
\r
200 case 275: // 10cm連装高角砲改+増設機銃
\r
201 return 0.2 * Level;
\r
202 case 12: // 15.5cm三連装副砲
\r
203 case 234: // 15.5cm三連装副砲改
\r
204 case 247: // 15.2cm三連装砲
\r
205 return 0.3 * Level;
\r
207 return Math.Sqrt(Level);
\r
212 public double TorpedoLevelBonus
\r
220 return 1.2 * Math.Sqrt(Level);
\r
227 public double AntiSubmarineLevelBonus
\r
235 return Math.Sqrt(Level);
\r
242 public double BomberLevelBonus => Spec.Type == 11 /* 水爆 */ ? 0.2 * Level : 0;
\r
244 public double NightBattleLevelBonus
\r
260 return Math.Sqrt(Level);
\r
262 return SecondaryGunLevelBonus;
\r
269 public double EffectiveAntiAirForShip
\r
273 switch (Spec.IconType)
\r
276 return 6 * Spec.AntiAir + 4 * Math.Sqrt(Level);
\r
278 return 4 * Spec.AntiAir + (Spec.AntiAir >= 8 ? 3 : 2) * Math.Sqrt(Level);
\r
280 return 3 * Spec.AntiAir;
\r
282 return 4 * Spec.AntiAir + 2 * Math.Sqrt(Level);
\r
288 public double EffectiveAntiAirForFleet
\r
292 switch (Spec.IconType)
\r
301 return 0.2 * Spec.AntiAir;
\r
303 return 0.4 * Spec.AntiAir + 1.5 * Math.Sqrt(Level);
\r
305 return 0.6 * Spec.AntiAir;
\r
307 return 0.35 * Spec.AntiAir + (Spec.AntiAir >= 8 ? 3 : 2) * Math.Sqrt(Level);
\r
309 return 0.35 * Spec.AntiAir + 2 * Math.Sqrt(Level);
\r
311 if (Spec.Id == 9) // 46cm三連装砲
\r
312 return 0.25 * Spec.AntiAir;
\r
313 if (Spec.Type == 10) // 水偵
\r
314 return 0.2 * Spec.AntiAir;
\r