Ejemplo n.º 1
0
Archivo: Dock.cs Proyecto: lscyane/KCBr
        public bool UpdateBuildKDock(List<KCB.api_get_member.KDock.ApiData> json, MasterData.Ship shipMaster)
        {
            foreach (var data in json)
            {
                int ship_id = (int)data.api_created_ship_id;
                int dock_id = (int)data.api_id;

                lock (_kdock)
                {
                    KDock targetDock = _kdock[dock_id - 1];
                    if (ship_id == 0)
                        targetDock.Vacant = true;
                    else
                    {
                        var ship = shipMaster.LookupShipMaster(ship_id);
                        targetDock.Vacant = false;
                        targetDock.ShipID = ship_id;
                        targetDock.Name = ship.Name;
                        targetDock.Type = ship.ShipTypeName;
                        targetDock.Finish
                            = _epoch.AddMilliseconds(data.api_complete_time).ToLocalTime();
                        targetDock.UpdateMaterialParam(data);
                    }
                }
            }
            return true;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 内部状態の初期化
        /// </summary>
        /// <param name="result">戦闘結果</param>
        /// <param name="_memberShip"></param>
        /// <param name="fleetInfo">艦隊情報</param>
        /// <param name="_masterShip"></param>
        private void initializeShipData(KCB.api_req_sortie.Battle.ApiData result,
            MemberData.Deck.Fleet fleetInfo, MemberData.Ship _memberShip, MasterData.Ship _masterShip)
        {
            Debug.WriteLine("戦闘開始/艦隊番号:" + fleetInfo.Num.ToString());
            _battleResult = new Result(result.api_midnight_flag == 1,_practice);

            //戦闘形態を取得する

            _battleResult.Friend.Formation = (Result.FleetState.FormationType)result.api_formation[0];
            _battleResult.Enemy.Formation = (Result.FleetState.FormationType)result.api_formation[1];
            if (result.api_search != null)
            {
                _battleResult.Friend.SearchResult = (Result.FleetState.SearchResultType)result.api_search[0];
                _battleResult.Enemy.SearchResult = (Result.FleetState.SearchResultType)result.api_search[1];
            }
            else
            {
                _battleResult.Friend.SearchResult = Result.FleetState.SearchResultType.索敵なし;
                _battleResult.Enemy.SearchResult = Result.FleetState.SearchResultType.索敵なし;
            }

            _battleResult.MatchState = (Result.MatchType)result.api_formation[2];

            Debug.WriteLine(string.Format("自陣形:{0} {1}\n敵陣形:{2} {3}\n交戦形態:{4}\n夜戦:{5}",
                 _battleResult.Friend.Formation,_battleResult.Friend.SearchResult,
                 _battleResult.Enemy.Formation,_battleResult.Enemy.SearchResult,
                 _battleResult.MatchState, _battleResult.HasNightBattle));

            ///味方艦隊の情報を取得する
            for (int i = 0; i < fleetInfo.Member.Count; i++)
            {
                var ship_id = fleetInfo.Member[i];
                var ship = _memberShip.GetShip(ship_id);
                var info = _battleResult.Friend.Ships[i];

                info.Initialize(ship_id,ship.ShipNameId,ship.ShipName,ship.ShipTypeId,
                    result.api_maxhps[i + 1],result.api_nowhps[i + 1]);

                Debug.WriteLine(string.Format("No.{0} ID:{1} Name:{2} HP:{3}", i + 1,
                    ship_id, ship.ShipName,ship.HP.ToString()));
            }

            ///敵艦隊の情報を取得する
            for (int i = 0; i < 6; i++)
            {
                int ship_id = result.api_ship_ke[i + 1];
                if (ship_id < 0)
                    continue;

                var ship = _masterShip.LookupShipMaster(ship_id);
                var info = _battleResult.Enemy.Ships[i];
                string shipName;
                if(_practice)
                    shipName = ship.Name;
                else
                    shipName = string.Format("{0}{1}", ship.Name, ship.Yomi);

                info.Initialize(-1,ship_id,shipName,ship.ShipTypeId,
                    result.api_maxhps[i + 7],result.api_nowhps[i + 7]);

                Debug.WriteLine(string.Format("No.{0} Name:{1} HP:{2}/{3}",
                    i + 1, shipName, result.api_maxhps[i + 7], result.api_nowhps[i + 7]));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 戦闘終了 /kcsapi/api_req_sortie/battleresult
        /// </summary>
        /// <param name="JSON"></param>
        public LogData.BattleResultInfo Finish(string JSON, MemberData.Ship shipData,
            MemberData.Deck deckData,MasterData.Ship shipMaster,MemberData.Basic basicData)
        {
//            var json = DynamicJson.Parse(JSON);
            var json = JsonConvert.DeserializeObject<KCB.api_req_sortie.BattleResult>(JSON);
            if ((int)json.api_result != 1)
                return null;

            var data = json.api_data;

            LogData.BattleResultInfo result = new LogData.BattleResultInfo();
            result.MemberID = basicData.MemberID;
            result.Date = DateTime.Now;
            result.AreaName = data.api_quest_name;
            result.Rank = data.api_win_rank;

            //敵情報
            result.Foe.DeckName = data.api_enemy_info.api_deck_name;
            Debug.WriteLine("FoeDeckName:" + result.Foe.DeckName);
//            double[] enemylist = (double[])data.api_ship_id;

//            for (int i = 1; i < enemylist.Count(); i++)
            for (int i = 1; i < data.api_ship_id.Count(); i++)
            {
                int enemyID = data.api_ship_id[i];
                if (enemyID <= 0)
                {
                    result.Foe.ShipList[i - 1] = "";
                    continue;
                }

                //何故かeliteとかflagの文字は読みに入ってる
                var t = shipMaster.LookupShipMaster(enemyID);
                if (t.Yomi.Length == 1)
                    result.Foe.ShipList[i - 1] = t.Name;
                else
                    result.Foe.ShipList[i - 1] = string.Format("{0}({1})", t.Name, t.Yomi);

                Debug.WriteLine(string.Format("ShipList({0})={1}", i - 1, result.Foe.ShipList[i - 1]));
            }

            //自軍情報
            var fleet = deckData.GetFleet(battleFleetID);
            result.Friend.DeckName = fleet.Name;
            Debug.WriteLine("FriendDeckName:" + result.Friend.DeckName);
            for (int i = 0; i < fleet.Member.Count(); i++)
            {
                if (fleet.Member[i] <= 0)
                {
                    result.Friend.ShipList[i] = "";
                    continue;
                }

                string header = "";
                ///ロスト艦艇
                if (data.api_lost_flag != null && (int)data.api_lost_flag[i + 1] != 0)
                    header = "x";

                //MVPは1オリジン
                if ((int)data.api_mvp == i + 1)
                    header = "*";

                var t = shipData.GetShip(fleet.Member[i]);
                result.Friend.ShipList[i] = string.Format("{0}{1}(Lv{2} HP{3})",
                    header, t.ShipName, t.Level, t.HP);
                Debug.WriteLine(string.Format("ShipList({0})={1}", i, result.Friend.ShipList[i]));
            }

            ///ドロップ
//            if (data.IsDefined("api_get_ship"))
            if(data.api_get_ship != null)
                result.ShipDropped = string.Format("{0}({1})", data.api_get_ship.api_ship_name,
                    data.api_get_ship.api_ship_type);
            Debug.WriteLine("GetShip:" + result.ShipDropped);

            return result;
        }