public override void OnResponseReceived( dynamic data ) { KCDatabase db = KCDatabase.Instance; //api_ship_data foreach ( var elem in data.api_ship_data ) { int id = (int)elem.api_id; ShipData ship = db.Ships[id]; ship.LoadFromResponse( APIName, elem ); for ( int i = 0; i < ship.Slot.Count; i++ ) { if ( ship.Slot[i] == -1 ) continue; if ( !db.Equipments.ContainsKey( ship.Slot[i] ) ) { //改装時に新装備を入手するが、追加される前にIDを与えられてしまうため EquipmentData eq = new EquipmentData(); eq.LoadFromResponse( APIName, ship.Slot[i] ); db.Equipments.Add( eq ); } } } //api_deck_data db.Fleet.LoadFromResponse( APIName, data.api_deck_data ); base.OnResponseReceived( (object)data ); }
public override void OnResponseReceived( dynamic data ) { KCDatabase db = KCDatabase.Instance; //装備の追加 データが不十分のため、自力で構築しなければならない if ( (int)data.api_create_flag != 0 ) { var eq = new EquipmentData(); eq.LoadFromResponse( APIName, data.api_slot_item ); db.Equipments.Add( eq ); } db.Material.LoadFromResponse( APIName, data.api_material ); //logging if ( Utility.Configuration.Config.Log.ShowSpoiler ) { if ( (int)data.api_create_flag != 0 ) { int eqid = (int)data.api_slot_item.api_slotitem_id; Utility.Logger.Add( 2, string.Format( "{0}「{1}」の開発に成功しました。({2}/{3}/{4}/{5} 秘書艦: {6})", db.MasterEquipments[eqid].CategoryTypeInstance.Name, db.MasterEquipments[eqid].Name, materials[0], materials[1], materials[2], materials[3], db.Fleet[1].MembersInstance[0].NameWithLevel ) ); } else { Utility.Logger.Add( 2, string.Format( "開発に失敗しました。({0}/{1}/{2}/{3} 秘書艦: {4})", materials[0], materials[1], materials[2], materials[3], db.Fleet[1].MembersInstance[0].NameWithLevel ) ); } } base.OnResponseReceived( (object) data ); }
public override void LoadFromResponse(string apiname, dynamic data) { base.LoadFromResponse(apiname, (object)data); IsSucceeded = (int)data.api_create_flag != 0; Materials = Array.AsReadOnly((int[])data.api_material); void AddToDatabase(dynamic equipmentData) { var eq = new EquipmentData(); eq.LoadFromResponse(apiname, Codeplex.Data.DynamicJson.Parse(equipmentData.ToString())); KCDatabase.Instance.Equipments.Add(eq); } bool isOldAPI = data.api_shizai_flag(); if (isOldAPI) { // 旧 API フォーマット (-2019/09/30 12:00) Results = Array.AsReadOnly(new[] { IsSucceeded ? new DevelopmentResult(data.api_slot_item) : new DevelopmentResult() }); if (IsSucceeded) { AddToDatabase(data.api_slot_item); } } else { // 新 API フォーマット (2019/09/30 21:00-) dynamic[] elems = data.api_get_items; var results = new DevelopmentResult[elems.Length]; for (int i = 0; i < elems.Length; i++) { results[i] = new DevelopmentResult(elems[i]); if (results[i].IsSucceeded) { AddToDatabase(elems[i]); } } Results = Array.AsReadOnly(results); } KCDatabase.Instance.Material.LoadFromResponse(apiname, data.api_material); }
public override void OnResponseReceived( dynamic data ) { KCDatabase db = KCDatabase.Instance; // Admiral - 各所でバグるので封印 //db.Admiral.LoadFromResponse( APIName, data.api_basic ); // Equipments db.Equipments.Clear(); foreach ( var elem in data.api_slot_item ) { var eq = new EquipmentData(); eq.LoadFromResponse( APIName, elem ); db.Equipments.Add( eq ); } // Arsenal foreach ( var ars in data.api_kdock ) { int id = (int)ars.api_id; if ( !db.Arsenals.ContainsKey( id ) ) { var a = new ArsenalData(); a.LoadFromResponse( APIName, ars ); db.Arsenals.Add( a ); } else { db.Arsenals[id].LoadFromResponse( APIName, ars ); } } // UseItem db.UseItems.Clear(); foreach ( var elem in data.api_useitem ) { var item = new UseItem(); item.LoadFromResponse( APIName, elem ); db.UseItems.Add( item ); } base.OnResponseReceived( (object)data ); }
public override void OnResponseReceived( dynamic data ) { KCDatabase db = KCDatabase.Instance; db.Equipments.Clear(); foreach ( var elem in data ) { var eq = new EquipmentData(); eq.LoadFromResponse( APIName, elem ); db.Equipments.Add( eq ); } db.Battle.LoadFromResponse( APIName, data ); base.OnResponseReceived( (object)data ); }
public override void OnResponseReceived( dynamic data ) { KCDatabase db = KCDatabase.Instance; //api_kdock foreach ( var ars in data.api_kdock ) { int id = (int)ars.api_id; if ( !db.Arsenals.ContainsKey( id ) ) { var a = new ArsenalData(); a.LoadFromResponse( APIName, ars ); db.Arsenals.Add( a ); } else { db.Arsenals[id].LoadFromResponse( APIName, ars ); } } //api_slotitem if ( data.api_slotitem != null ) { //装備なしの艦はnullになる foreach ( var elem in data.api_slotitem ) { var eq = new EquipmentData(); eq.LoadFromResponse( APIName, elem ); db.Equipments.Add( eq ); } } //api_ship { ShipData ship = new ShipData(); ship.LoadFromResponse( APIName, data.api_ship ); db.Ships.Add( ship ); Utility.Logger.Add( 2, string.Format( "{0}「{1}」の建造が完了しました。", ship.MasterShip.ShipTypeName, ship.MasterShip.NameWithClass ) ); } base.OnResponseReceived( (object)data ); }
/// <summary> /// スロット情報を設定します。 /// このメソッド以外の場所で Slot 系列のプロパティは書き換えないでください。 /// </summary> /// <param name="slot">メインスロット。</param> /// <param name="expansion">拡張スロット。</param> private void SetSlot(int[] slot, int expansion) { var slotRaw = new int[slot.Length]; var slotMaster = new int[slot.Length]; var slotInstance = new EquipmentData[slot.Length]; var slotInstanceMaster = new EquipmentDataMaster[slot.Length]; var allSlotRaw = new int[slot.Length + 1]; var allSlotMaster = new int[slot.Length + 1]; var allSlotInstance = new EquipmentData[slot.Length + 1]; var allSlotInstanceMaster = new EquipmentDataMaster[slot.Length + 1]; for (int i = 0; i < slot.Length; i++) { slotRaw[i] = allSlotRaw[i] = slot[i]; slotInstance[i] = allSlotInstance[i] = KCDatabase.Instance.Equipments[slot[i]]; slotMaster[i] = allSlotMaster[i] = slotInstance[i]?.EquipmentID ?? -1; slotInstanceMaster[i] = allSlotInstanceMaster[i] = slotInstance[i]?.MasterEquipment; } ExpansionSlot = allSlotRaw[slot.Length] = expansion; ExpansionSlotInstance = allSlotInstance[slot.Length] = KCDatabase.Instance.Equipments[expansion]; ExpansionSlotMaster = allSlotMaster[slot.Length] = ExpansionSlotInstance?.EquipmentID ?? -1; ExpansionSlotInstanceMaster = allSlotInstanceMaster[slot.Length] = ExpansionSlotInstance?.MasterEquipment; Slot = Array.AsReadOnly(slotRaw); SlotMaster = Array.AsReadOnly(slotMaster); SlotInstance = Array.AsReadOnly(slotInstance); SlotInstanceMaster = Array.AsReadOnly(slotInstanceMaster); AllSlot = Array.AsReadOnly(allSlotRaw); AllSlotMaster = Array.AsReadOnly(allSlotMaster); AllSlotInstance = Array.AsReadOnly(allSlotInstance); AllSlotInstanceMaster = Array.AsReadOnly(allSlotInstanceMaster); }
public static int CalculateID( EquipmentData eq ) { return CalculateID( eq.Level, eq.AircraftLevel ); }
/// <summary> /// 初期装備を更新します。 /// </summary> /// <param name="ship">対象の艦船。入手直後・改装直後のものに限ります。</param> public void UpdateDefaultSlot( ShipData ship ) { int[] slot = new int[ship.Slot.Count]; for (int i = 0; i < slot.Length; i++) { if (ship.Slot[i] == -1) { slot[i] = -1; }// TODO:出撃から帰還時にNullReferenceExceptionが発生するため、装備のLoadFromResponseには"api_port/port"は無いが、応急措置として装備キーが存在するか調べ追加する。 else if (!KCDatabase.Instance.Equipments.ContainsKey(ship.Slot[i])) { EquipmentData eq = new EquipmentData(); eq.LoadFromResponse("api_get_member/ship3", ship.Slot[i]); KCDatabase.Instance.Equipments.Add(eq); } else { slot[i] = KCDatabase.Instance.Equipments[ship.Slot[i]].EquipmentID; } } UpdateDefaultSlot( ship.ShipID, slot ); }