1 // Copyright (C) 2015 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
15 using System.Collections.Generic;
\r
17 using KancolleSniffer.Model;
\r
18 using static System.Math;
\r
20 namespace KancolleSniffer.View
\r
22 public class MiscTextInfo
\r
24 private readonly ShipInfo _shipInfo;
\r
25 private readonly ItemInfo _itemInfo;
\r
26 private bool _inSortie;
\r
28 private const string GuideText =
\r
29 "[海域ゲージ情報]\r\n 海域選択画面に進むと表示します。\r\n[演習情報]\r\n 演習相手を選ぶと表示します。\r\n[獲得アイテム]\r\n 帰投したときに表示します。";
\r
31 public string Text { get; private set; } = GuideText;
\r
33 public MiscTextInfo(ShipInfo shipInfo, ItemInfo itemInfo)
\r
35 _shipInfo = shipInfo;
\r
36 _itemInfo = itemInfo;
\r
44 var text = GenerateItemGetText();
\r
45 Text = text == "" ? GuideText : "[獲得アイテム]\r\n" + text;
\r
50 private readonly Dictionary<int, int> _required = new Dictionary<int, int>
\r
68 public void InspectMapInfo(dynamic json)
\r
70 Text = "[海域ゲージ]\r\n";
\r
71 foreach (var entry in json.api_map_info() ? json.api_map_info : json)
\r
73 var map = (int)entry.api_id;
\r
74 if (entry.api_eventmap())
\r
76 var evmap = entry.api_eventmap;
\r
77 Text += $"{map / 10}-{map % 10} : HP {(int)evmap.api_now_maphp}/{(int)evmap.api_max_maphp}\r\n";
\r
80 if (!entry.api_defeat_count())
\r
82 var reqStr = _required.TryGetValue(map, out var req) ? req.ToString() : "?";
\r
83 Text += $"{map / 10}-{map % 10} : 撃破 {(int)entry.api_defeat_count}/{reqStr}\r\n";
\r
87 private readonly int[] _expTable =
\r
89 0, 100, 300, 600, 1000, 1500, 2100, 2800, 3600, 4500,
\r
90 5500, 6600, 7800, 9100, 10500, 12000, 13600, 15300, 17100, 19000,
\r
91 21000, 23100, 25300, 27600, 30000, 32500, 35100, 37800, 40600, 43500,
\r
92 46500, 49600, 52800, 56100, 59500, 63000, 66600, 70300, 74100, 78000,
\r
93 82000, 86100, 90300, 94600, 99000, 103500, 108100, 112800, 117600, 122500,
\r
94 127500, 132700, 138100, 143700, 149500, 155500, 161700, 168100, 174700, 181500,
\r
95 188500, 195800, 203400, 211300, 219500, 228000, 236800, 245900, 255300, 265000,
\r
96 275000, 285400, 296200, 307400, 319000, 331000, 343400, 356200, 369400, 383000,
\r
97 397000, 411500, 426500, 442000, 458000, 474500, 491500, 509000, 527000, 545500,
\r
98 564500, 584500, 606500, 631500, 661500, 701500, 761500, 851500, 1000000, 1000000,
\r
99 1010000, 1011000, 1013000, 1016000, 1020000, 1025000, 1031000, 1038000, 1046000, 1055000,
\r
100 1065000, 1077000, 1091000, 1107000, 1125000, 1145000, 1168000, 1194000, 1223000, 1255000,
\r
101 1290000, 1329000, 1372000, 1419000, 1470000, 1525000, 1584000, 1647000, 1714000, 1785000,
\r
102 1860000, 1940000, 2025000, 2115000, 2210000, 2310000, 2415000, 2525000, 2640000, 2760000,
\r
103 2887000, 3021000, 3162000, 3310000, 3465000, 3628000, 3799000, 3978000, 4165000, 4360000,
\r
104 4564000, 4777000, 4999000, 5230000, 5470000, 5720000, 5780000, 5860000, 5970000, 6120000,
\r
105 6320000, 6580000, 6910000, 7320000, 7820000
\r
108 public void InspectPracticeEnemyInfo(dynamic json)
\r
110 Text = $"[演習情報]\r\n敵艦隊名 : {json.api_deckname}\r\n";
\r
111 var ships = json.api_deck.api_ships;
\r
112 var s1 = (int)ships[0].api_id != -1 ? (int)ships[0].api_level : 1;
\r
113 var s2 = (int)ships[1].api_id != -1 ? (int)ships[1].api_level : 1;
\r
114 var raw = _expTable[Min(s1, _expTable.Length) - 1] / 100.0 +
\r
115 _expTable[Min(s2, _expTable.Length) - 1] / 300.0;
\r
116 var exp = raw >= 500 ? 500 + (int)Sqrt(raw - 500) : (int)raw;
\r
117 var bonus = 1 + TrainingCruiserBonus(_shipInfo.Fleets[0].Ships);
\r
118 Text += $"獲得経験値 : {(int)(exp * bonus)}\r\nS勝利 : {(int)((int)(exp * 1.2) * bonus)}";
\r
121 private double TrainingCruiserBonus(ShipStatus[] fleet)
\r
123 if (fleet[0].Spec.IsTrainingCruiser)
\r
125 var fsLevel = fleet[0].Level;
\r
126 if (fleet.Skip(1).Any(s => s.Spec.IsTrainingCruiser))
\r
148 var tc = fleet.Count(s => s.Spec.IsTrainingCruiser);
\r
151 var level = fleet.Where(s => s.Spec.IsTrainingCruiser).Max(s => s.Level);
\r
175 public void InspectMapNext(dynamic json)
\r
177 if (json.api_airsearch() && (int)json.api_airsearch.api_result != 0)
\r
179 var item = json.api_itemget;
\r
180 AddItemCount((int)item.api_usemst + 100, (int)item.api_id, (int)item.api_getcount);
\r
183 if (json.api_itemget())
\r
185 foreach (var item in json.api_itemget)
\r
186 AddItemCount((int)item.api_usemst, (int)item.api_id, (int)item.api_getcount);
\r
188 if (json.api_itemget_eo_result())
\r
190 var eo = json.api_itemget_eo_result;
\r
191 AddItemCount((int)eo.api_usemst, (int)eo.api_id, (int)eo.api_getcount);
\r
193 if (json.api_itemget_eo_comment())
\r
195 var eo = json.api_itemget_eo_comment;
\r
196 AddItemCount((int)eo.api_usemst, (int)eo.api_id, (int)eo.api_getcount);
\r
198 if (json.api_eventmap() && json.api_eventmap.api_itemget())
\r
200 foreach (var item in json.api_eventmap.api_itemget)
\r
202 var type = (int)item.api_type;
\r
203 type = type == 1 ? 5 :
\r
204 type == 5 ? 6 : type;
\r
205 AddItemCount(type, (int)item.api_id, (int)item.api_value);
\r
210 public void InspectMapStart(dynamic json)
\r
213 InspectMapNext(json);
\r
216 public void InspectBattleResult(dynamic json)
\r
218 if (json.api_get_eventitem())
\r
220 foreach (var item in json.api_get_eventitem)
\r
222 var type = (int)item.api_type;
\r
223 type = type == 1 ? 5 :
\r
224 type == 5 ? 6 : type;
\r
225 var id = (int)item.api_id;
\r
226 AddItemCount(type, id, (int)item.api_value);
\r
229 if (json.api_mapcell_incentive() && (int)json.api_mapcell_incentive == 1)
\r
231 foreach (var type in _items.Keys.Where(type => type > 100).ToArray())
\r
233 foreach (var id in _items[type])
\r
234 AddItemCount(type - 100, id.Key, id.Value);
\r
239 private readonly Dictionary<int, SortedDictionary<int, int>> _items =
\r
240 new Dictionary<int, SortedDictionary<int, int>>();
\r
242 private void AddItemCount(int type, int id, int count)
\r
244 if (!_items.ContainsKey(type))
\r
245 _items[type] = new SortedDictionary<int, int>();
\r
246 var dict = _items[type];
\r
247 if (!dict.ContainsKey(id))
\r
252 private readonly Dictionary<int, string> _furniture = new Dictionary<int, string>();
\r
254 public void InspectMaster(dynamic json)
\r
256 if (!json.api_mst_furniture())
\r
258 foreach (var entry in json.api_mst_furniture)
\r
259 _furniture[(int)entry.api_id] = (string)entry.api_title;
\r
262 private string GetName(int type, int id)
\r
267 return _shipInfo.GetSpec(id).Name;
\r
269 return _itemInfo.GetSpecByItemId(id).Name;
\r
271 return new[] {"燃料", "弾薬", "鋼材", "ボーキサイト", "高速建造材", "高速修復材", "開発資材", "改修資材"}[id - 1];
\r
273 return _itemInfo.GetUseItemName(id);
\r
275 return _furniture[id];
\r
281 private string GenerateItemGetText()
\r
283 return string.Join("\r\n",
\r
284 new[] {4, 5, 3, 6, 2}.Where(_items.ContainsKey).SelectMany(type =>
\r
285 _items[type].Select(pair => GetName(type, pair.Key) + ": " + pair.Value)));
\r