1 // Copyright (C) 2013, 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 namespace KancolleSniffer
\r
19 public class MissionInfo
\r
21 private readonly Dictionary<int, string> _missionNames = new Dictionary<int, string>();
\r
22 private readonly NameAndTimer[] _missions = new NameAndTimer[3];
\r
24 public MissionInfo()
\r
26 for (var i = 0; i < _missions.Length; i++)
\r
27 _missions[i] = new NameAndTimer();
\r
30 public void InspectMaster(dynamic json)
\r
32 foreach (var entry in json)
\r
33 _missionNames[(int)entry.api_id] = (string)entry.api_name;
\r
36 public void InspectDeck(dynamic json)
\r
38 foreach (var entry in json)
\r
40 var id = (int)entry.api_id;
\r
44 var mission = entry.api_mission;
\r
45 if (mission[0] == 0)
\r
47 _missions[id].Name = "";
\r
48 _missions[id].Timer.SetEndTime(0);
\r
51 _missions[id].Name = _missionNames.TryGetValue((int)mission[1], out var name) ? name : "不明";
\r
52 _missions[id].Timer.SetEndTime(mission[2]);
\r
56 public NameAndTimer[] Missions => _missions;
\r
58 public bool InMission(int fleet) => fleet != 0 && _missions[fleet - 1].Name != "";
\r