/// <summary> /// 艦隊の燃料と弾薬の補給状況を調べる /// </summary> /// <param name="fleetMember">艦隊メンバー</param> /// <param name="shipData">艦娘ステート一覧</param> /// <returns>どの燃料が消費されているか</returns> SupplyStatusFlags CheckFleetStatus(IEnumerable<int> fleetMember, MemberData.Ship shipData) { SupplyStatusFlags status = SupplyStatusFlags.None; foreach (var ship_id in fleetMember) { var dat = shipData.GetShip(ship_id); if (!dat.Fuel.Full) { Debug.WriteLine("Fuel not filled"); status |= SupplyStatusFlags.Fuel; } if (!dat.Bullet.Full) { Debug.WriteLine("Bullet not filled"); status |= SupplyStatusFlags.Bullet; } } return status; }
/// <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])); } }
/// <summary> /// /kcsapi/api_req_nyukyo/start /// 入渠に伴う資材消費を反映させる /// </summary> /// <param name="api_highspeed"></param> public void UpdateOnNDockStart(IDictionary<string, string> queryParam, MemberData.Ship _memberShip) { string ship_id = queryParam["api_ship_id"]; string highspeed = queryParam["api_highspeed"]; var ship = _memberShip.GetShip(ship_id); if (highspeed == "1") { Debug.WriteLine("Using FastRepair"); FastRepair--; } //修理に要した資材を引く Fuel -= ship.RepairFuel; Steel -= ship.RepairSteel; }
/// <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; }
public LogData.CreateItemInfo CreateLogData(string responseJson,IDictionary<string,string> queryParam, MasterData.Item itemData, MemberData.Deck deckDat, MemberData.Ship shipDat,MemberData.Basic basicDat) { // var json = DynamicJson.Parse(oSession.ResponseJSON); var json = JsonConvert.DeserializeObject<KCB.api_req_kousyou.CreateItem>(responseJson); if ((int)json.api_result != 1) return null; var info = new LogData.CreateItemInfo(queryParam, json.api_data); info.OfficeLv = basicDat.Level; var secretary = shipDat.GetShip(deckDat.Secretary); info.SecretaryShip = string.Format("{0}(Lv{1})", secretary.ShipName, secretary.Level); info.MemberID = basicDat.MemberID; if (info.Succeess) { var it = itemData.GetItemParam(info.ItemNameID); info.ItemName = it.Name; info.ItemType = it.Type; } return info; }
// /// <summary> /// 建造記録を生成 /// /kcsapi/api_get_member/kdock /// </summary> /// <param name="dockDat"></param> /// <param name="basicDat"></param> /// <param name="deckDat"></param> /// <param name="shipDat"></param> /// <returns></returns> public IEnumerable<LogData.CreateShipInfo> CreateLogData(MemberData.Dock dockDat, MemberData.Basic basicDat,MemberData.Deck deckDat,MemberData.Ship shipDat) { List<LogData.CreateShipInfo> retList = new List<LogData.CreateShipInfo>(); for (int n = 0; n < kdock_build.Count(); n++) { ///既に建造記録を生成しているか、建造していないドックを飛ばす if (!kdock_build[n]) continue; var secretary = shipDat.GetShip(deckDat.Secretary); var info = new LogData.CreateShipInfo(); lock (dockDat.KDockLock) { var kdock = dockDat.GetKDock(n + 1); info.Resource = new LogData.Material(kdock); info.ShipType = kdock.Type; info.ShipName = kdock.Name; info.OfficeLv = basicDat.Level; info.SecretaryShip = string.Format("{0}(Lv{1})", secretary.ShipName, secretary.Level); info.Date = DateTime.Now; info.MemberID = basicDat.MemberID; } retList.Add(info); Debug.WriteLine("KDockLog:" + info.ToString()); kdock_build[n] = false; } if (retList.Count == 0) return null; return retList; }
/// <summary> /// 遠征結果のログ情報を生成 /// </summary> /// <param name="JSON"></param> /// <param name="shipList"></param> /// <returns></returns> public LogData.MissionResultInfo CreateResult(string JSON, MemberData.Ship shipList,MemberData.Basic basicData) { // var json = DynamicJson.Parse(JSON); var json = JsonConvert.DeserializeObject<KCB.api_req_mission.Result>(JSON); if ((int)json.api_result != 1) return null; var result = json.api_data; if (result == null) return null; LogData.MissionResultInfo res = new LogData.MissionResultInfo(); res.MemberID = basicData.MemberID; res.AreaName = result.api_maparea_name; res.QuestName = result.api_quest_name; res.Date = DateTime.Now; res.Succeeded = (int)result.api_clear_result; //失敗したとき、api_get_material = -1で帰ってくる // Type typMaterial = result.api_get_material.GetType(); // if (typMaterial != typeof(Codeplex.Data.DynamicJson)) // if(result.api_get_material is Codeplex.Data.DynamicJson) // res.Material = new LogData.Material((double[])result.api_get_material); if (result.api_get_material is Newtonsoft.Json.Linq.JArray) res.Material = new LogData.Material((Newtonsoft.Json.Linq.JArray)result.api_get_material); else res.Material = new LogData.Material(); if (result.api_useitem_flag[0] != 0) { res.Item.Add( string.Format("{0}x{1}", itemName((int)result.api_useitem_flag[0] , result.api_get_item1.api_useitem_name), (int)result.api_get_item1.api_useitem_count) ); } if (result.api_useitem_flag[1] != 0) { res.Item.Add( string.Format("{0}x{1}", itemName((int)result.api_useitem_flag[1] , result.api_get_item2.api_useitem_name), (int)result.api_get_item2.api_useitem_count) ); } // double[] ships = (double[]) result.api_ship_id; // for (int n = 1; n < ships.Count(); n++) for (int n = 1; n < result.api_ship_id.Count(); n++) { var it = shipList.GetShip(result.api_ship_id[n]); res.Member.Add(string.Format("{0}({1}Lv{2})", it.ShipName, it.ShipType, it.Level)); Debug.WriteLine("Member:" + res.Member.Last()); } Debug.WriteLine("result:" + res.ToString()); return res; }