/// <summary> /// /kcsapi/api_req_sortie/battle /// 戦闘開始 /// </summary> /// <param name="JSON"></param> /// <param name="practice">演習の時true</param> /// <param name="_memberShip"></param> /// <param name="_memberDeck"></param> /// <param name="_masterShip"></param> public int ProcessBattle(string JSON,bool practice, MemberData.Ship _memberShip, MemberData.Deck _memberDeck, MasterData.Ship _masterShip,MasterData.Item _masterItem) { var json = JsonConvert.DeserializeObject<KCB.api_req_sortie.Battle>(JSON); if (json == null) return 0; if (json.api_result != 1) return 0; _practice = practice; var result = json.api_data; var deck_info = _memberDeck.GetFleet(result.api_dock_id); int estimatedBattleTime = InitialPhase; initializeShipData(result, deck_info, _memberShip, _masterShip); //索敵フェイズ if (_battleResult.Friend.SearchResult != Result.FleetState.SearchResultType.索敵なし) estimatedBattleTime += SearchPhase; //支援艦隊が来た if (result.api_support_flag > 0 && result.api_support_info != null) { //航空支援(flag=1) if (result.api_support_info.api_support_airatack != null) { Debug.WriteLine("航空支援(味方から敵へ)"); getRaiDamage(result.api_support_info.api_support_airatack.api_stage3.api_edam, _battleResult.Enemy.Ships); estimatedBattleTime += SupportTime; } //砲雷撃支援(flag=2/雷撃,3/砲撃) if (result.api_support_info.api_support_hourai != null) { Debug.WriteLine("砲雷支援(味方から敵へ)"); getRaiDamage(result.api_support_info.api_support_hourai.api_damage, _battleResult.Enemy.Ships); estimatedBattleTime += SupportTime; } } // 開幕雷撃 if (result.api_opening_flag == 1 && result.api_opening_atack != null) { Debug.WriteLine("開幕雷撃(敵から味方へ)"); estimatedBattleTime += getRaiDamage(result.api_opening_atack.api_fdam, _battleResult.Friend.Ships); Debug.WriteLine("開幕雷撃(味方から敵へ)"); getRaiDamage(result.api_opening_atack.api_edam, _battleResult.Enemy.Ships); } estimatedBattleTime += Torpedo; // 航空戦 if (result.api_stage_flag[2] == 1 && result.api_kouku.api_stage3 != null) { Debug.WriteLine("航空戦(敵から味方へ)"); estimatedBattleTime += getRaiDamage(result.api_kouku.api_stage3.api_fdam, _battleResult.Friend.Ships); Debug.WriteLine("航空戦(味方から敵へ)"); getRaiDamage(result.api_kouku.api_stage3.api_edam, _battleResult.Enemy.Ships); } estimatedBattleTime += AirBattle; // 砲撃1順目 if (result.api_hourai_flag[0] == 1 && result.api_hougeki1 != null) { Debug.WriteLine("砲撃1順目"); estimatedBattleTime += getHougekiDamage(result.api_hougeki1, _battleResult, _masterItem); } // 砲撃2順目 if (result.api_hourai_flag[1] == 1 && result.api_hougeki2 != null) { Debug.WriteLine("砲撃2順目"); estimatedBattleTime += getHougekiDamage(result.api_hougeki2, _battleResult, _masterItem); } // 砲撃3順目 if (result.api_hourai_flag[2] == 1 && result.api_hougeki3 != null) { Debug.WriteLine("砲撃3順目"); estimatedBattleTime += getHougekiDamage(result.api_hougeki3, _battleResult, _masterItem); } // 雷撃 if (result.api_hourai_flag[3] == 1 && result.api_raigeki != null) { Debug.WriteLine("雷撃(敵から味方へ)"); estimatedBattleTime += getRaiDamage(result.api_raigeki.api_fdam, _battleResult.Friend.Ships); Debug.WriteLine("雷撃(味方から敵へ)"); getRaiDamage(result.api_raigeki.api_edam, _battleResult.Enemy.Ships); } estimatedBattleTime += Torpedo; //夜戦の場合は待つ必要がないから0を返す。 return result.api_midnight_flag != 0 ? estimatedBattleTime : 0; }
/// <summary> /// /kcsapi/api_req_battle_midnight/sp_midnight /// 開幕夜戦 /// </summary> /// <param name="JSON"></param> /// <param name="_memberShip"></param> /// <param name="_memberDeck"></param> /// <param name="_masterShip"></param> public void ProcessNightBattle(string JSON, MemberData.Ship _memberShip, MemberData.Deck _memberDeck, MasterData.Ship _masterShip, MasterData.Item _masterItem) { var json = JsonConvert.DeserializeObject<KCB.api_req_sortie.Battle>(JSON); if (json == null) return; if (json.api_result != 1) return; var deck_info = _memberDeck.GetFleet(json.api_data.api_deck_id); initializeShipData(json.api_data, deck_info, _memberShip, _masterShip); getHougekiDamage(json.api_data.api_hougeki, _battleResult,_masterItem); }
/// <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; }