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 static System.Math;
\r
19 namespace KancolleSniffer
\r
21 public class MiscTextInfo
\r
23 private readonly ShipInfo _shipInfo;
\r
24 private readonly ItemInfo _itemInfo;
\r
26 private const string GuideText =
\r
27 "[海域ゲージ情報]\r\n 海域選択画面に進むと表示します。\r\n[演習情報]\r\n 演習相手を選ぶと表示します。\r\n[獲得アイテム]\r\n 帰投したときに表示します。";
\r
29 public string Text { get; private set; } = GuideText;
\r
30 public bool SortieStarted { private get; set; }
\r
32 public MiscTextInfo(ShipInfo shipInfo, ItemInfo itemInfo)
\r
34 _shipInfo = shipInfo;
\r
35 _itemInfo = itemInfo;
\r
42 SortieStarted = false;
\r
43 var text = GenerateItemGetText();
\r
44 Text = text == "" ? GuideText : "[獲得アイテム]\r\n" + text;
\r
49 private readonly Dictionary<int, int> _required = new Dictionary<int, int>
\r
67 public void InspectMapInfo(dynamic json)
\r
69 Text = "[海域ゲージ]\r\n";
\r
70 foreach (var entry in json.api_map_info() ? json.api_map_info : json)
\r
72 var map = (int)entry.api_id;
\r
73 if (entry.api_eventmap())
\r
75 var evmap = entry.api_eventmap;
\r
76 Text += $"{map / 10}-{map % 10} : HP {(int)evmap.api_now_maphp}/{(int)evmap.api_max_maphp}\r\n";
\r
79 if (!entry.api_defeat_count())
\r
81 var reqStr = _required.TryGetValue(map, out var req) ? req.ToString() : "?";
\r
82 Text += $"{map / 10}-{map % 10} : 撃破 {(int)entry.api_defeat_count}/{reqStr}\r\n";
\r
86 private readonly int[] _expTable =
\r
88 0, 100, 300, 600, 1000, 1500, 2100, 2800, 3600, 4500,
\r
89 5500, 6600, 7800, 9100, 10500, 12000, 13600, 15300, 17100, 19000,
\r
90 21000, 23100, 25300, 27600, 30000, 32500, 35100, 37800, 40600, 43500,
\r
91 46500, 49600, 52800, 56100, 59500, 63000, 66600, 70300, 74100, 78000,
\r
92 82000, 86100, 90300, 94600, 99000, 103500, 108100, 112800, 117600, 122500,
\r
93 127500, 132700, 138100, 143700, 149500, 155500, 161700, 168100, 174700, 181500,
\r
94 188500, 195800, 203400, 211300, 219500, 228000, 236800, 245900, 255300, 265000,
\r
95 275000, 285400, 296200, 307400, 319000, 331000, 343400, 356200, 369400, 383000,
\r
96 397000, 411500, 426500, 442000, 458000, 474500, 491500, 509000, 527000, 545500,
\r
97 564500, 584500, 606500, 631500, 661500, 701500, 761500, 851500, 1000000, 1000000,
\r
98 1010000, 1011000, 1013000, 1016000, 1020000, 1025000, 1031000, 1038000, 1046000, 1055000,
\r
99 1065000, 1077000, 1091000, 1107000, 1125000, 1145000, 1168000, 1194000, 1223000, 1255000,
\r
100 1290000, 1329000, 1372000, 1419000, 1470000, 1525000, 1584000, 1647000, 1714000, 1785000,
\r
101 1860000, 1940000, 2025000, 2115000, 2210000, 2310000, 2415000, 2525000, 2640000, 2760000,
\r
102 2887000, 3021000, 3162000, 3310000, 3465000, 3628000, 3799000, 3978000, 4165000, 4360000,
\r
103 4564000, 4777000, 4999000, 5230000, 5470000, 5720000, 5780000, 5860000, 5970000, 6120000,
\r
104 6320000, 6580000, 6910000, 7320000, 7820000
\r
107 public void InspectPracticeEnemyInfo(dynamic json)
\r
109 Text = $"[演習情報]\r\n敵艦隊名 : {json.api_deckname}\r\n";
\r
110 var ships = json.api_deck.api_ships;
\r
111 var s1 = (int)ships[0].api_id != -1 ? (int)ships[0].api_level : 1;
\r
112 var s2 = (int)ships[1].api_id != -1 ? (int)ships[1].api_level : 1;
\r
113 var raw = _expTable[Min(s1, _expTable.Length) - 1] / 100.0 +
\r
114 _expTable[Min(s2, _expTable.Length) - 1] / 300.0;
\r
115 var exp = raw >= 500 ? 500 + (int)Sqrt(raw - 500) : (int)raw;
\r
116 Text += $"獲得経験値 : {exp}\r\nS勝利 : {(int)(exp * 1.2)}";
\r
119 public void InspectMapNext(dynamic json)
\r
121 if (json.api_airsearch() && (int)json.api_airsearch.api_result != 0)
\r
123 var item = json.api_itemget;
\r
124 AddItemCount((int)item.api_usemst + 100, (int)item.api_id, (int)item.api_getcount);
\r
127 if (json.api_itemget())
\r
129 foreach (var item in json.api_itemget)
\r
130 AddItemCount((int)item.api_usemst, (int)item.api_id, (int)item.api_getcount);
\r
132 if (json.api_itemget_eo_result())
\r
134 var eo = json.api_itemget_eo_result;
\r
135 AddItemCount((int)eo.api_usemst, (int)eo.api_id, (int)eo.api_getcount);
\r
137 if (json.api_itemget_eo_comment())
\r
139 var eo = json.api_itemget_eo_comment;
\r
140 AddItemCount((int)eo.api_usemst, (int)eo.api_id, (int)eo.api_getcount);
\r
142 if (json.api_eventmap() && json.api_eventmap.api_itemget())
\r
144 foreach (var item in json.api_eventmap.api_itemget)
\r
146 var type = (int)item.api_type;
\r
147 type = type == 1 ? 5 :
\r
148 type == 5 ? 6 : type;
\r
149 AddItemCount(type, (int)item.api_id, (int)item.api_value);
\r
154 public void InspectMapStart(dynamic json)
\r
156 InspectMapNext(json);
\r
159 public void InspectBattleResult(dynamic json)
\r
161 if (json.api_get_eventitem())
\r
163 foreach (var item in json.api_get_eventitem)
\r
165 var type = (int)item.api_type;
\r
166 type = type == 1 ? 5 :
\r
167 type == 5 ? 6 : type;
\r
168 var id = (int)item.api_id;
\r
169 AddItemCount(type, id, (int)item.api_value);
\r
172 if (json.api_mapcell_incentive() && (int)json.api_mapcell_incentive == 1)
\r
174 foreach (var type in _items.Keys.Where(type => type > 100).ToArray())
\r
176 foreach (var id in _items[type])
\r
177 AddItemCount(type - 100, id.Key, id.Value);
\r
182 private readonly Dictionary<int, SortedDictionary<int, int>> _items =
\r
183 new Dictionary<int, SortedDictionary<int, int>>();
\r
185 private void AddItemCount(int type, int id, int count)
\r
187 if (!_items.ContainsKey(type))
\r
188 _items[type] = new SortedDictionary<int, int>();
\r
189 var dict = _items[type];
\r
190 if (!dict.ContainsKey(id))
\r
195 private readonly Dictionary<int, string> _furniture = new Dictionary<int, string>();
\r
197 public void InspectMaster(dynamic json)
\r
199 if (!json.api_mst_furniture())
\r
201 foreach (var entry in json.api_mst_furniture)
\r
202 _furniture[(int)entry.api_id] = (string)entry.api_title;
\r
205 private string GetName(int type, int id)
\r
210 return _shipInfo.GetSpec(id).Name;
\r
212 return _itemInfo.GetSpecByItemId(id).Name;
\r
214 return new[] {"燃料", "弾薬", "鋼材", "ボーキサイト", "高速建造材", "高速修復材", "開発資材", "改修資材"}[id - 1];
\r
216 return _itemInfo.GetUseItemName(id);
\r
218 return _furniture[id];
\r
224 private string GenerateItemGetText()
\r
226 return string.Join("\r\n",
\r
227 new[] {4, 5, 3, 6, 2}.Where(_items.ContainsKey).SelectMany(type =>
\r
228 _items[type].Select(pair => GetName(type, pair.Key) + ": " + pair.Value)));
\r