/// <summary>
        /// 制空戦力を求めます。
        /// </summary>
        /// <param name="slot">装備スロット。</param>
        /// <param name="aircraft">艦載機搭載量の配列。</param>
        public static int GetAirSuperiority(int[] slot, int[] aircraft)
        {
            int air    = 0;
            int length = Math.Min(slot.Length, aircraft.Length);

            for (int s = 0; s < length; s++)
            {
                EquipmentDataMaster eq = KCDatabase.Instance.MasterEquipments[slot[s]];

                if (eq == null)
                {
                    continue;
                }

                switch (eq.EquipmentType[2])
                {
                case 6:
                case 7:
                case 8:
                case 11:
                    air += (int)(eq.AA * Math.Sqrt(aircraft[s]));
                    break;
                }
            }

            return(air);
        }
Beispiel #2
0
 public ComboBoxEquipment(int equipmentID, int level, int aircraftLevel)
 {
     EquipmentID       = equipmentID;
     Level             = level;
     AircraftLevel     = aircraftLevel;
     EquipmentInstance = KCDatabase.Instance.MasterEquipments[equipmentID];
     UniqueID          = -1;
 }
            private string GetShipString(int shipID, int[] slot, int level, int hp, int firepower, int torpedo, int aa, int armor, int asw, int evasion, int los, int luck)
            {
                ShipDataMaster ship = KCDatabase.Instance.MasterShips[shipID];

                if (ship == null)
                {
                    return(null);
                }

                int firepower_c = firepower;
                int torpedo_c   = torpedo;
                int aa_c        = aa;
                int armor_c     = armor;
                int asw_c       = Math.Max(asw, 0);
                int evasion_c   = Math.Max(evasion, 0);
                int los_c       = Math.Max(los, 0);
                int luck_c      = luck;

                if (slot != null)
                {
                    int count = slot.Length;
                    for (int i = 0; i < count; i++)
                    {
                        EquipmentDataMaster eq = KCDatabase.Instance.MasterEquipments[slot[i]];
                        if (eq == null)
                        {
                            continue;
                        }

                        firepower += eq.Firepower;
                        torpedo   += eq.Torpedo;
                        aa        += eq.AA;
                        armor     += eq.Armor;
                        asw       += eq.ASW;
                        evasion   += eq.Evasion;
                        los       += eq.LOS;
                        luck      += eq.Luck;
                    }
                }

                return(string.Format(
                           "{0} {1}{2}\n耐久: {3}\n火力: {4}/{5}\n雷装: {6}/{7}\n対空: {8}/{9}\n装甲: {10}/{11}\n対潜: {12}/{13}\n回避: {14}/{15}\n索敵: {16}/{17}\n運: {18}/{19}\n(右クリックで図鑑)\n",
                           ship.ShipTypeName, ship.NameWithClass, level < 1 ? "" : string.Format(" Lv. {0}", level),
                           hp,
                           firepower_c, firepower,
                           torpedo_c, torpedo,
                           aa_c, aa,
                           armor_c, armor,
                           asw_c == -1 ? "???" : asw_c.ToString(), asw,
                           evasion_c == -1 ? "???" : evasion_c.ToString(), evasion,
                           los_c == -1 ? "???" : los_c.ToString(), los,
                           luck_c, luck
                           ));
            }
Beispiel #4
0
 public ComboBoxEquipment(EquipmentData equipment)
 {
     if (equipment == null)
     {
         EquipmentID       = -1;
         Level             = 0;
         AircraftLevel     = 0;
         EquipmentInstance = null;
         UniqueID          = -1;
     }
     else
     {
         EquipmentID       = equipment.EquipmentID;
         Level             = equipment.Level;
         AircraftLevel     = equipment.AircraftLevel;
         EquipmentInstance = KCDatabase.Instance.MasterEquipments[equipment.EquipmentID];
         UniqueID          = equipment.MasterID;
     }
 }
Beispiel #5
0
            private static string GetAircraftParameters(EquipmentDataMaster eq)
            {
                if (eq == null)
                {
                    return("");
                }

                var sb = new StringBuilder();

                void Add(string name, int value)
                {
                    if (value != 0)
                    {
                        sb.Append(name).Append(": ").AppendLine(value.ToString("+0;-0;0"));
                    }
                }

                void AddNoSign(string name, int value)
                {
                    if (value != 0)
                    {
                        sb.Append(name).Append(": ").AppendLine(value.ToString());
                    }
                }

                bool isLand = eq.CategoryType == EquipmentTypes.Interceptor;

                Add("FP", eq.Firepower);
                Add("Torp", eq.Torpedo);
                Add("Bomb", eq.Bomber);
                Add("AA", eq.AA);
                Add("Armor", eq.Armor);
                Add("ASW", eq.ASW);
                Add(isLand ? "Interception" : "Evasion", eq.Evasion);
                Add("LOS", eq.LOS);
                Add(isLand ? "Anti-bomber" : "Acc", eq.Accuracy);
                AddNoSign("Cost", eq.AircraftCost);
                AddNoSign("Range", eq.AircraftDistance);

                return(sb.ToString());
            }
Beispiel #6
0
            private static string GetAircraftParameters(EquipmentDataMaster eq)
            {
                if (eq == null)
                {
                    return("");
                }

                var sb = new StringBuilder();

                void Add(string name, int value)
                {
                    if (value != 0)
                    {
                        sb.Append(name).Append(": ").AppendLine(value.ToString("+0;-0;0"));
                    }
                }

                void AddNoSign(string name, int value)
                {
                    if (value != 0)
                    {
                        sb.Append(name).Append(": ").AppendLine(value.ToString());
                    }
                }

                bool isLand = eq.CategoryType == EquipmentTypes.Interceptor;

                Add("火力", eq.Firepower);
                Add("雷装", eq.Torpedo);
                Add("爆装", eq.Bomber);
                Add("対空", eq.AA);
                Add("装甲", eq.Armor);
                Add("対潜", eq.ASW);
                Add(isLand ? "迎撃" : "回避", eq.Evasion);
                Add("索敵", eq.LOS);
                Add(isLand ? "対爆" : "命中", eq.Accuracy);
                AddNoSign("コスト", eq.AircraftCost);
                AddNoSign("半径", eq.AircraftDistance);

                return(sb.ToString());
            }
        private string GetCreateItemInfo(dynamic data)
        {
            if ((int)data.api_create_flag == 0)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("[開発失敗]");
                sb.AppendLine(data.api_fdata);

                EquipmentDataMaster eqm = KCDatabase.Instance.MasterEquipments[int.Parse(((string)data.api_fdata).Split(",".ToCharArray())[1])];
                if (eqm != null)
                {
                    sb.AppendLine(eqm.Name);
                }


                return(sb.ToString());
            }
            else
            {
                return("");
            }
        }
Beispiel #8
0
		private void UpdateAlbumPage( int shipID ) {

			KCDatabase db = KCDatabase.Instance;
			ShipDataMaster ship = db.MasterShips[shipID];

			if ( ship == null ) return;


			BasePanelShipGirl.SuspendLayout();

			//header
			TableShipName.SuspendLayout();
			_shipID = shipID;
			ShipID.Text = ship.ShipID.ToString();
			AlbumNo.Text = ship.AlbumNo.ToString();
			ResourceName.Text = string.Format( "{0} ver. {1}", ship.ResourceName, ship.ResourceVersion );

			ShipType.Text = ship.IsLandBase ? "陸上基地" : db.ShipTypes[ship.ShipType].Name;
			ShipName.Text = ship.NameWithClass;
			ToolTipInfo.SetToolTip( ShipName, !ship.IsAbyssalShip ? ship.NameReading : null );
			TableShipName.ResumeLayout();


			//main parameter
			TableParameterMain.SuspendLayout();

			if ( !ship.IsAbyssalShip ) {

				TitleParameterMin.Text = "初期値";
				TitleParameterMax.Text = "最大値";

				HPMin.Text = ship.HPMin.ToString();
				HPMax.Text = ship.HPMaxMarried.ToString();

				FirepowerMin.Text = ship.FirepowerMin.ToString();
				FirepowerMax.Text = ship.FirepowerMax.ToString();

				TorpedoMin.Text = ship.TorpedoMin.ToString();
				TorpedoMax.Text = ship.TorpedoMax.ToString();

				AAMin.Text = ship.AAMin.ToString();
				AAMax.Text = ship.AAMax.ToString();

				ArmorMin.Text = ship.ArmorMin.ToString();
				ArmorMax.Text = ship.ArmorMax.ToString();

				ASWMin.Text = GetParameterMinBound( ship.ASW );
				ASWMax.Text = GetParameterMax( ship.ASW );

				EvasionMin.Text = GetParameterMinBound( ship.Evasion );
				EvasionMax.Text = GetParameterMax( ship.Evasion );

				LOSMin.Text = GetParameterMinBound( ship.LOS );
				LOSMax.Text = GetParameterMax( ship.LOS );

				LuckMin.Text = ship.LuckMin.ToString();
				LuckMax.Text = ship.LuckMax.ToString();

			} else {

				int hp = ship.HPMin;
				int firepower = ship.FirepowerMax;
				int torpedo = ship.TorpedoMax;
				int aa = ship.AAMax;
				int armor = ship.ArmorMax;
				int asw = ship.ASW != null && ship.ASW.Maximum != ShipParameterRecord.Parameter.MaximumDefault ? ship.ASW.Maximum : 0;
				int evasion = ship.Evasion != null && ship.Evasion.Maximum != ShipParameterRecord.Parameter.MaximumDefault ? ship.Evasion.Maximum : 0;
				int los = ship.LOS != null && ship.LOS.Maximum != ShipParameterRecord.Parameter.MaximumDefault ? ship.LOS.Maximum : 0;
				int luck = ship.LuckMax;

				if ( ship.DefaultSlot != null ) {
					int count = ship.DefaultSlot.Count;
					for ( int i = 0; i < count; i++ ) {
						EquipmentDataMaster eq = KCDatabase.Instance.MasterEquipments[ship.DefaultSlot[i]];
						if ( eq == null ) continue;

						firepower += eq.Firepower;
						torpedo += eq.Torpedo;
						aa += eq.AA;
						armor += eq.Armor;
						asw += eq.ASW;
						evasion += eq.Evasion;
						los += eq.LOS;
						luck += eq.Luck;
					}
				}

				TitleParameterMin.Text = "基本値";
				TitleParameterMax.Text = "装備込";

				HPMin.Text = ship.HPMin.ToString();
				HPMax.Text = hp.ToString();

				FirepowerMin.Text = ship.FirepowerMax.ToString();
				FirepowerMax.Text = firepower.ToString();

				TorpedoMin.Text = ship.TorpedoMax.ToString();
				TorpedoMax.Text = torpedo.ToString();

				AAMin.Text = ship.AAMax.ToString();
				AAMax.Text = aa.ToString();

				ArmorMin.Text = ship.ArmorMax.ToString();
				ArmorMax.Text = armor.ToString();

				ASWMin.Text = ship.ASW != null && ship.ASW.Maximum != ShipParameterRecord.Parameter.MaximumDefault ? ship.ASW.Maximum.ToString() : "???";
				ASWMax.Text = asw.ToString();

				EvasionMin.Text = ship.Evasion != null && ship.Evasion.Maximum != ShipParameterRecord.Parameter.MaximumDefault ? ship.Evasion.Maximum.ToString() : "???";
				EvasionMax.Text = evasion.ToString();

				LOSMin.Text = ship.LOS != null && ship.LOS.Maximum != ShipParameterRecord.Parameter.MaximumDefault ? ship.LOS.Maximum.ToString() : "???";
				LOSMax.Text = los.ToString();

				LuckMin.Text = ship.LuckMax.ToString();
				LuckMax.Text = luck.ToString();

			}
			UpdateLevelParameter( ship.ShipID );

			TableParameterMain.ResumeLayout();


			//sub parameter
			TableParameterSub.SuspendLayout();

			Speed.Text = Constants.GetSpeed( ship.Speed );
			Range.Text = Constants.GetRange( ship.Range );
			Rarity.Text = Constants.GetShipRarity( ship.Rarity );
			Rarity.ImageIndex = (int)ResourceManager.IconContent.RarityRed + ship.Rarity;		//checkme

			TableParameterSub.ResumeLayout();

			TableConsumption.SuspendLayout();

			Fuel.Text = ship.Fuel.ToString();
			Ammo.Text = ship.Ammo.ToString();

			string tooltiptext = string.Format(
				"入渠時の消費:\r\nHP1あたり: 鋼 {0:F2} / 燃 {1:F2}\r\n最大: 鋼 {2} / 燃 {3}\r\n",
				( ship.Fuel * 0.06 ),
				( ship.Fuel * 0.032 ),
				(int)( ship.Fuel * 0.06 * ( ship.HPMaxMarried - 1 ) ),
				(int)( ship.Fuel * 0.032 * ( ship.HPMaxMarried - 1 ) )
				);

			ToolTipInfo.SetToolTip( TableConsumption, tooltiptext );
			ToolTipInfo.SetToolTip( TitleConsumption, tooltiptext );
			ToolTipInfo.SetToolTip( Fuel, tooltiptext );
			ToolTipInfo.SetToolTip( Ammo, tooltiptext );

			TableConsumption.ResumeLayout();

			Description.Text = ship.MessageAlbum != "" ? ship.MessageAlbum : ship.MessageGet;
			Description.Tag = ship.MessageAlbum != "" ? 1 : 0;


			//equipment
			TableEquipment.SuspendLayout();

			for ( int i = 0; i < Equipments.Length; i++ ) {

				if ( ship.Aircraft[i] > 0 || i < ship.SlotSize )
					Aircrafts[i].Text = ship.Aircraft[i].ToString();
				else
					Aircrafts[i].Text = "";


				ToolTipInfo.SetToolTip( Equipments[i], null );

				if ( ship.DefaultSlot == null ) {
					if ( i < ship.SlotSize ) {
						Equipments[i].Text = "???";
						Equipments[i].ImageIndex = (int)ResourceManager.EquipmentContent.Unknown;
					} else {
						Equipments[i].Text = "";
						Equipments[i].ImageIndex = (int)ResourceManager.EquipmentContent.Locked;
					}

				} else if ( ship.DefaultSlot[i] != -1 ) {
					EquipmentDataMaster eq = db.MasterEquipments[ship.DefaultSlot[i]];
					Equipments[i].Text = eq.Name;

					int eqicon = eq.EquipmentType[3];
					if ( eqicon >= (int)ResourceManager.EquipmentContent.Locked )
						eqicon = (int)ResourceManager.EquipmentContent.Unknown;

					Equipments[i].ImageIndex = eqicon;

					{
						StringBuilder sb = new StringBuilder();

						sb.AppendFormat( "{0} {1}\r\n", eq.CategoryTypeInstance.Name, eq.Name );
						if ( eq.Firepower != 0 ) sb.AppendFormat( "火力 {0}{1}\r\n", eq.Firepower > 0 ? "+" : "", eq.Firepower );
						if ( eq.Torpedo != 0 ) sb.AppendFormat( "雷装 {0}{1}\r\n", eq.Torpedo > 0 ? "+" : "", eq.Torpedo );
						if ( eq.AA != 0 ) sb.AppendFormat( "対空 {0}{1}\r\n", eq.AA > 0 ? "+" : "", eq.AA );
						if ( eq.Armor != 0 ) sb.AppendFormat( "装甲 {0}{1}\r\n", eq.Armor > 0 ? "+" : "", eq.Armor );
						if ( eq.ASW != 0 ) sb.AppendFormat( "対潜 {0}{1}\r\n", eq.ASW > 0 ? "+" : "", eq.ASW );
						if ( eq.Evasion != 0 ) sb.AppendFormat( "回避 {0}{1}\r\n", eq.Evasion > 0 ? "+" : "", eq.Evasion );
						if ( eq.LOS != 0 ) sb.AppendFormat( "索敵 {0}{1}\r\n", eq.LOS > 0 ? "+" : "", eq.LOS );
						if ( eq.Accuracy != 0 ) sb.AppendFormat( "命中 {0}{1}\r\n", eq.Accuracy > 0 ? "+" : "", eq.Accuracy );
						if ( eq.Bomber != 0 ) sb.AppendFormat( "爆装 {0}{1}\r\n", eq.Bomber > 0 ? "+" : "", eq.Bomber );
						sb.AppendLine( "(右クリックで図鑑)" );

						ToolTipInfo.SetToolTip( Equipments[i], sb.ToString() );
					}

				} else if ( i < ship.SlotSize ) {
					Equipments[i].Text = "(なし)";
					Equipments[i].ImageIndex = (int)ResourceManager.EquipmentContent.Nothing;

				} else {
					Equipments[i].Text = "";
					Equipments[i].ImageIndex = (int)ResourceManager.EquipmentContent.Locked;
				}
			}

			TableEquipment.ResumeLayout();


			//arsenal
			TableArsenal.SuspendLayout();
			BuildingTime.Text = DateTimeHelper.ToTimeRemainString( new TimeSpan( 0, ship.BuildingTime, 0 ) );

			MaterialFuel.Text = ship.Material[0].ToString();
			MaterialAmmo.Text = ship.Material[1].ToString();
			MaterialSteel.Text = ship.Material[2].ToString();
			MaterialBauxite.Text = ship.Material[3].ToString();

			PowerUpFirepower.Text = ship.PowerUp[0].ToString();
			PowerUpTorpedo.Text = ship.PowerUp[1].ToString();
			PowerUpAA.Text = ship.PowerUp[2].ToString();
			PowerUpArmor.Text = ship.PowerUp[3].ToString();

			TableArsenal.ResumeLayout();


			//remodel
			if ( !ship.IsAbyssalShip ) {

				TableRemodel.SuspendLayout();

				if ( ship.RemodelBeforeShipID == 0 ) {
					RemodelBeforeShipName.Text = "(なし)";
					RemodelBeforeLevel.Text = "";
					RemodelBeforeLevel.ImageIndex = -1;
					ToolTipInfo.SetToolTip( RemodelBeforeLevel, null );
					RemodelBeforeAmmo.Text = "-";
					RemodelBeforeSteel.Text = "-";
				} else {
					ShipDataMaster sbefore = ship.RemodelBeforeShip;
					RemodelBeforeShipName.Text = sbefore.Name;
					RemodelBeforeLevel.Text = string.Format( "Lv. {0}", sbefore.RemodelAfterLevel );
					RemodelBeforeLevel.ImageIndex = sbefore.NeedCatapult > 0 ? (int)ResourceManager.IconContent.ItemCatapult : sbefore.NeedBlueprint > 0 ? (int)ResourceManager.IconContent.ItemBlueprint : -1;
					ToolTipInfo.SetToolTip( RemodelBeforeLevel, GetRemodelItem( sbefore ) );
					RemodelBeforeAmmo.Text = sbefore.RemodelAmmo.ToString();
					RemodelBeforeSteel.Text = sbefore.RemodelSteel.ToString();
				}

				if ( ship.RemodelAfterShipID == 0 ) {
					RemodelAfterShipName.Text = "(なし)";
					RemodelAfterLevel.Text = "";
					RemodelAfterLevel.ImageIndex = -1;
					ToolTipInfo.SetToolTip( RemodelAfterLevel, null );
					RemodelAfterAmmo.Text = "-";
					RemodelAfterSteel.Text = "-";
				} else {
					RemodelAfterShipName.Text = ship.RemodelAfterShip.Name;
					RemodelAfterLevel.Text = string.Format( "Lv. {0}", ship.RemodelAfterLevel );
					RemodelAfterLevel.ImageIndex = ship.NeedCatapult > 0 ? (int)ResourceManager.IconContent.ItemCatapult : ship.NeedBlueprint > 0 ? (int)ResourceManager.IconContent.ItemBlueprint : -1;
					ToolTipInfo.SetToolTip( RemodelAfterLevel, GetRemodelItem( ship ) );
					RemodelAfterAmmo.Text = ship.RemodelAmmo.ToString();
					RemodelAfterSteel.Text = ship.RemodelSteel.ToString();
				}
				TableRemodel.ResumeLayout();


				TableRemodel.Visible = true;
				TableBattle.Visible = false;


			} else {

				TableBattle.SuspendLayout();

				AirSuperiority.Text = Calculator.GetAirSuperiority( ship ).ToString();
				DayAttack.Text = Constants.GetDayAttackKind( Calculator.GetDayAttackKind( ship.DefaultSlot == null ? null : ship.DefaultSlot.ToArray(), ship.ShipID, -1 ) );
				NightAttack.Text = Constants.GetNightAttackKind( Calculator.GetNightAttackKind( ship.DefaultSlot == null ? null : ship.DefaultSlot.ToArray(), ship.ShipID, -1 ) );

				TableBattle.ResumeLayout();

				TableRemodel.Visible = false;
				TableBattle.Visible = true;

			}




			BasePanelShipGirl.ResumeLayout();
			BasePanelShipGirl.Visible = true;


			this.Text = "艦船図鑑 - " + ship.NameWithClass;

		}
        /// <summary>
        /// 戦闘終了時に各種データの収集を行います。
        /// </summary>
        private void BattleFinished()
        {
            //敵編成記録
            EnemyFleetRecord.EnemyFleetElement enemyFleetData = EnemyFleetRecord.EnemyFleetElement.CreateFromCurrentState();

            if (enemyFleetData != null)
            {
                RecordManager.Instance.EnemyFleet.Update(enemyFleetData);
            }


            // ロギング
            if (IsPractice)
            {
                Utility.Logger.Add(2,
                                   string.Format("演習 で「{0}」{1}の「{2}」と交戦しました。( ランク: {3}, 提督Exp+{4}, 艦娘Exp+{5} )",
                                                 EnemyAdmiralName, EnemyAdmiralRank, Result.EnemyFleetName, Result.Rank, Result.AdmiralExp, Result.BaseExp));
            }
            else if (IsBaseAirRaid)
            {
                var initialHPs = BattleDay.Initial.FriendInitialHPs.TakeWhile(hp => hp >= 0);
                var damage     = initialHPs.Zip(BattleDay.ResultHPs.Take(initialHPs.Count()), (initial, result) => initial - result).Sum();
                var airraid    = ((BattleBaseAirRaid)BattleDay).BaseAirRaid;

                Utility.Logger.Add(2,
                                   string.Format("{0}-{1}-{2} で基地に空襲を受けました。( {3}, 被ダメージ合計: {4}, {5} )",
                                                 Compass.MapAreaID, Compass.MapInfoID, Compass.Destination,
                                                 Constants.GetAirSuperiority(airraid.IsAvailable ? airraid.AirSuperiority : -1), damage, Constants.GetAirRaidDamage(Compass.AirRaidDamageKind)));
            }
            else
            {
                Utility.Logger.Add(2,
                                   string.Format("{0}-{1}-{2} で「{3}」と交戦しました。( ランク: {4}, 提督Exp+{5}, 艦娘Exp+{6} )",
                                                 Compass.MapAreaID, Compass.MapInfoID, Compass.Destination, Result.EnemyFleetName, Result.Rank, Result.AdmiralExp, Result.BaseExp));
            }


            // Level up
            if (!IsBaseAirRaid)
            {
                var exps = Result.ExpList;
                var lvup = Result.LevelUpList;
                for (int i = 0; i < lvup.Length; i++)
                {
                    if (lvup[i].Length >= 2 && i < exps.Length && lvup[i][0] + exps[i] >= lvup[i][1])
                    {
                        var ship      = FirstBattle.Initial.FriendFleet.MembersInstance[i];
                        int increment = Math.Max(lvup[i].Length - 2, 1);

                        Utility.Logger.Add(2, string.Format("{0} が Lv. {1} になりました。", ship.Name, ship.Level + increment));
                    }
                }

                if (IsCombinedBattle)
                {
                    exps = Result.ExpListCombined;
                    lvup = Result.LevelUpListCombined;
                    for (int i = 0; i < lvup.Length; i++)
                    {
                        if (lvup[i].Length >= 2 && i < exps.Length && lvup[i][0] + exps[i] >= lvup[i][1])
                        {
                            var ship      = FirstBattle.Initial.FriendFleetEscort.MembersInstance[i];
                            int increment = Math.Max(lvup[i].Length - 2, 1);

                            Utility.Logger.Add(2, string.Format("{0} が Lv. {1} になりました。", ship.Name, ship.Level + increment));
                        }
                    }
                }
            }



            //ドロップ艦記録
            if (!IsPractice && !IsBaseAirRaid)
            {
                //checkme: とてもアレな感じ

                int  shipID  = Result.DroppedShipID;
                int  itemID  = Result.DroppedItemID;
                int  eqID    = Result.DroppedEquipmentID;
                bool showLog = Utility.Configuration.Config.Log.ShowSpoiler;

                if (shipID != -1)
                {
                    ShipDataMaster ship = KCDatabase.Instance.MasterShips[shipID];
                    DroppedShipCount++;

                    var defaultSlot = ship.DefaultSlot;
                    if (defaultSlot != null)
                    {
                        DroppedEquipmentCount += defaultSlot.Count(id => id != -1);
                    }

                    if (showLog)
                    {
                        Utility.Logger.Add(2, string.Format("{0}「{1}」が戦列に加わりました。", ship.ShipTypeName, ship.NameWithClass));
                    }
                }

                if (itemID != -1)
                {
                    if (!DroppedItemCount.ContainsKey(itemID))
                    {
                        DroppedItemCount.Add(itemID, 0);
                    }
                    DroppedItemCount[itemID]++;

                    if (showLog)
                    {
                        var item       = KCDatabase.Instance.UseItems[itemID];
                        var itemmaster = KCDatabase.Instance.MasterUseItems[itemID];
                        Utility.Logger.Add(2, string.Format("アイテム「{0}」を入手しました。( 合計: {1}個 )", itemmaster?.Name ?? ("不明なアイテム - ID:" + itemID), (item?.Count ?? 0) + DroppedItemCount[itemID]));
                    }
                }

                if (eqID != -1)
                {
                    EquipmentDataMaster eq = KCDatabase.Instance.MasterEquipments[eqID];
                    DroppedEquipmentCount++;

                    if (showLog)
                    {
                        Utility.Logger.Add(2, string.Format("{0}「{1}」を入手しました。", eq.CategoryTypeInstance.Name, eq.Name));
                    }
                }


                // 満員判定
                if (shipID == -1 && (
                        KCDatabase.Instance.Admiral.MaxShipCount - (KCDatabase.Instance.Ships.Count + DroppedShipCount) <= 0 ||
                        KCDatabase.Instance.Admiral.MaxEquipmentCount - (KCDatabase.Instance.Equipments.Count + DroppedEquipmentCount) <= 0))
                {
                    shipID = -2;
                }

                RecordManager.Instance.ShipDrop.Add(shipID, itemID, eqID, Compass.MapAreaID, Compass.MapInfoID, Compass.Destination, Compass.MapInfo.EventDifficulty, Compass.EventID == 5, enemyFleetData.FleetID, Result.Rank, KCDatabase.Instance.Admiral.Level);
            }


            void IncrementSpecialAttack(BattleData bd)
            {
                if (bd == null)
                {
                    return;
                }

                foreach (var phase in bd.GetPhases())
                {
                    foreach (var detail in phase.BattleDetails)
                    {
                        int kind = detail.AttackType;

                        if (detail.AttackerIndex.IsFriend && TracedSpecialAttack.Contains(kind))
                        {
                            if (SpecialAttackCount.ContainsKey(kind))
                            {
                                SpecialAttackCount[kind]++;
                            }
                            else
                            {
                                SpecialAttackCount.Add(kind, 1);
                            }
                        }
                    }
                }
            }

            IncrementSpecialAttack(FirstBattle);
            IncrementSpecialAttack(SecondBattle);



            WriteBattleLog();



            /*//DEBUG
             *          if (!IsBaseAirRaid && Utility.Configuration.Config.Log.LogLevel <= 1)
             *          {
             *                  var battle = SecondBattle ?? FirstBattle;
             *
             *                  for (int i = 0; i < battle.Initial.EnemyMaxHPs.Length; i++)
             *                  {
             *                          if (battle.Initial.EnemyMaxHPs[i] > 0 && battle.ResultHPs[BattleIndex.Get(BattleSides.EnemyMain, i)] == 0)
             *                                  Utility.Logger.Add(1, "justkill #" + (i + 1));
             *                  }
             *
             *          int rank = PredictWinRank(out var friend, out var enemy);
             *
             *                  // SS -> S
             *                  if (Constants.GetWinRank(rank).Substring(0, 1) != Result.Rank)
             *                  {
             *                          Utility.Logger.Add(1, $"勝利ランク予測が誤っています。予想 {Constants.GetWinRank(rank)} -> 実際 {Result.Rank}");
             *                  }
             *          }
             *          //*/
        }
        private static string GetShipString(int shipID, int[] slot, int level, int hp, int firepower, int torpedo, int aa, int armor, int asw, int evasion, int los, int luck)
        {
            ShipDataMaster ship = KCDatabase.Instance.MasterShips[shipID];

            if (ship == null)
            {
                return(null);
            }

            int firepower_c = firepower;
            int torpedo_c   = torpedo;
            int aa_c        = aa;
            int armor_c     = armor;
            int asw_c       = asw;
            int evasion_c   = evasion;
            int los_c       = los;
            int luck_c      = luck;
            int range       = ship.Range;

            asw     = Math.Max(asw, 0);
            evasion = Math.Max(evasion, 0);
            los     = Math.Max(los, 0);

            if (slot != null)
            {
                int count = slot.Length;
                for (int i = 0; i < count; i++)
                {
                    EquipmentDataMaster eq = KCDatabase.Instance.MasterEquipments[slot[i]];
                    if (eq == null)
                    {
                        continue;
                    }

                    firepower += eq.Firepower;
                    torpedo   += eq.Torpedo;
                    aa        += eq.AA;
                    armor     += eq.Armor;
                    asw       += eq.ASW;
                    evasion   += eq.Evasion;
                    los       += eq.LOS;
                    luck      += eq.Luck;
                    range      = Math.Max(range, eq.Range);
                }
            }


            var sb = new StringBuilder();

            sb.Append(ship.ShipTypeName).Append(" ").AppendLine(ship.NameWithClass);
            if (level > 0)
            {
                sb.Append("Lv. ").Append(level.ToString());
            }
            sb.Append(" (ID: ").Append(shipID).AppendLine(")");

            sb.Append("耐久: ").Append(hp).AppendLine();

            sb.Append("火力: ").Append(firepower_c);
            if (firepower_c != firepower)
            {
                sb.Append("/").Append(firepower);
            }
            sb.AppendLine();

            sb.Append("雷装: ").Append(torpedo_c);
            if (torpedo_c != torpedo)
            {
                sb.Append("/").Append(torpedo);
            }
            sb.AppendLine();

            sb.Append("対空: ").Append(aa_c);
            if (aa_c != aa)
            {
                sb.Append("/").Append(aa);
            }
            sb.AppendLine();

            sb.Append("装甲: ").Append(armor_c);
            if (armor_c != armor)
            {
                sb.Append("/").Append(armor);
            }
            sb.AppendLine();

            sb.Append("対潜: ");
            if (asw_c < 0)
            {
                sb.Append("???");
            }
            else
            {
                sb.Append(asw_c);
            }
            if (asw_c != asw)
            {
                sb.Append("/").Append(asw);
            }
            sb.AppendLine();

            sb.Append("回避: ");
            if (evasion_c < 0)
            {
                sb.Append("???");
            }
            else
            {
                sb.Append(evasion_c);
            }
            if (evasion_c != evasion)
            {
                sb.Append("/").Append(evasion);
            }
            sb.AppendLine();

            sb.Append("索敵: ");
            if (los_c < 0)
            {
                sb.Append("???");
            }
            else
            {
                sb.Append(los_c);
            }
            if (los_c != los)
            {
                sb.Append("/").Append(los);
            }
            sb.AppendLine();

            sb.Append("運: ").Append(luck_c);
            if (luck_c != luck)
            {
                sb.Append("/").Append(luck);
            }
            sb.AppendLine();

            sb.AppendFormat("射程: {0} / 速力: {1}\r\n(右クリックで図鑑)\r\n",
                            Constants.GetRange(range),
                            Constants.GetSpeed(ship.Speed));

            return(sb.ToString());
        }
        /// <summary>
        /// 昼戦における攻撃種別を取得します。
        /// </summary>
        /// <param name="slot">攻撃艦のスロット(マスターID)。</param>
        /// <param name="attackerShipID">攻撃艦の艦船ID。</param>
        /// <param name="defenerShipID">防御艦の艦船ID。なければ-1</param>
        /// <param name="includeSpecialAttack">弾着観測砲撃を含むか。falseなら除外して計算</param>
        public static int GetDayAttackKind(int[] slot, int attackerShipID, int defenerShipID, bool includeSpecialAttack = true)
        {
            int reconcnt   = 0;
            int mainguncnt = 0;
            int subguncnt  = 0;
            int apshellcnt = 0;
            int radarcnt   = 0;
            int rocketcnt  = 0;
            int landingcnt = 0;
            int uchibicnt  = 0;

            if (slot == null)
            {
                return(-1);
            }

            for (int i = 0; i < slot.Length; i++)
            {
                EquipmentDataMaster eq = KCDatabase.Instance.MasterEquipments[slot[i]];
                if (eq == null)
                {
                    continue;
                }

                int eqtype = eq.CategoryType;

                switch (eqtype)
                {
                case 1:                                 // 小口径主砲
                case 2:                                 // 中口径主砲
                case 3:                                 // 大口径主砲
                    mainguncnt++;
                    break;

                case 4:                                 // 副砲
                    subguncnt++;
                    break;

                case 10:                                // 水上偵察機
                case 11:                                // 水上爆撃機
                    reconcnt++;
                    break;

                case 12:                                // 小型電探
                case 13:                                // 大型電探
                    radarcnt++;
                    break;

                case 19:                                // 対艦強化弾
                    apshellcnt++;
                    break;

                case 24:                                // 上陸用舟艇
                    if (eq.EquipmentID == 166)          // 陸戦隊
                    {
                        landingcnt++;
                    }
                    break;

                case 37:                                // 対地装備
                    rocketcnt++;
                    break;

                case 46:                                // 特型内火艇
                    uchibicnt++;
                    break;
                }
            }

            if (reconcnt > 0 && includeSpecialAttack)
            {
                if (mainguncnt == 2 && apshellcnt == 1)
                {
                    return(6);                                  //カットイン(主砲/主砲)
                }
                else if (mainguncnt == 1 && subguncnt == 1 && apshellcnt == 1)
                {
                    return(5);                                  //カットイン(主砲/徹甲弾)
                }
                else if (mainguncnt == 1 && subguncnt == 1 && radarcnt == 1)
                {
                    return(4);                                  //カットイン(主砲/電探)
                }
                else if (mainguncnt >= 1 && subguncnt >= 1)
                {
                    return(3);                                  //カットイン(主砲/副砲)
                }
                else if (mainguncnt >= 2)
                {
                    return(2);                                  //連撃
                }
            }


            ShipDataMaster atkship = KCDatabase.Instance.MasterShips[attackerShipID];
            ShipDataMaster defship = KCDatabase.Instance.MasterShips[defenerShipID];

            if (atkship != null)
            {
                if (defship != null)
                {
                    if (uchibicnt > 0 && (((atkship.ShipType == 13 || atkship.ShipType == 14) && defship.IsLandBase) || HardInstallationNames.Contains(defship.Name)))
                    {
                        return(12);                                     // 揚陸攻撃(内火艇)
                    }
                    if (landingcnt > 0 && HardInstallationNames.Contains(defship.Name))
                    {
                        return(11);                                     // 揚陸攻撃(大発動艇)
                    }
                    if (rocketcnt > 0 && defship.IsLandBase)
                    {
                        return(10);                                     //ロケット砲撃
                    }
                }


                if (attackerShipID == 352)                      //速吸改

                {
                    if (defship != null && (defship.ShipType == 13 || defship.ShipType == 14))
                    {
                        if (slot.Select(id => KCDatabase.Instance.MasterEquipments[id])
                            .Count(eq => eq != null && ((eq.CategoryType == 8 && eq.ASW > 0) || eq.CategoryType == 11 || eq.CategoryType == 25)) > 0)
                        {
                            return(7);                                          //空撃
                        }
                        else
                        {
                            return(8);                                  //爆雷攻撃
                        }
                    }
                    else if (slot.Select(id => KCDatabase.Instance.MasterEquipments[id]).Count(eq => eq != null && eq.CategoryType == 8) > 0)
                    {
                        return(7);                                      //空撃
                    }
                    else
                    {
                        return(0);                                      //砲撃
                    }
                }
                else if (atkship.ShipType == 7 || atkship.ShipType == 11 || atkship.ShipType == 18) //軽空母/正規空母/装甲空母
                {
                    return(7);                                                                      //空撃
                }
                else if (defship != null && (defship.ShipType == 13 || defship.ShipType == 14))     //潜水艦/潜水空母
                {
                    if (atkship.ShipType == 6 || atkship.ShipType == 10 ||
                        atkship.ShipType == 16 || atkship.ShipType == 17) //航空巡洋艦/航空戦艦/水上機母艦/揚陸艦
                    {
                        return(7);                                        //空撃
                    }
                    else
                    {
                        return(8);                                      //爆雷攻撃
                    }
                }
                //本来の雷撃は発生しない
                else if (atkship.ShipType == 13 || atkship.ShipType == 14) //潜水艦/潜水空母
                {
                    return(9);                                             //雷撃(特例措置, 本来のコード中には存在しない)
                }
            }

            return(0);                          //砲撃
        }
        private static string GetShipString(int shipID, int[] slot, int level, int hp, int firepower, int torpedo, int aa, int armor, int asw, int evasion, int los, int luck)
        {
            ShipDataMaster ship = KCDatabase.Instance.MasterShips[shipID];

            if (ship == null)
            {
                return(null);
            }

            int firepower_c = firepower;
            int torpedo_c   = torpedo;
            int aa_c        = aa;
            int armor_c     = armor;
            int asw_c       = asw;
            int evasion_c   = evasion;
            int los_c       = los;
            int luck_c      = luck;
            int range       = ship.Range;

            asw     = Math.Max(asw, 0);
            evasion = Math.Max(evasion, 0);
            los     = Math.Max(los, 0);

            if (slot != null)
            {
                int count = slot.Length;
                for (int i = 0; i < count; i++)
                {
                    EquipmentDataMaster eq = KCDatabase.Instance.MasterEquipments[slot[i]];
                    if (eq == null)
                    {
                        continue;
                    }

                    firepower += eq.Firepower;
                    torpedo   += eq.Torpedo;
                    aa        += eq.AA;
                    armor     += eq.Armor;
                    asw       += eq.ASW;
                    evasion   += eq.Evasion;
                    los       += eq.LOS;
                    luck      += eq.Luck;
                    range      = Math.Max(range, eq.Range);
                }
            }

            /*
             * return string.Format(
             *                      "{0} {1}{2}\n耐久: {3}\n火力: {4}/{5}\n雷装: {6}/{7}\n対空: {8}/{9}\n装甲: {10}/{11}\n対潜: {12}/{13}\n回避: {14}/{15}\n索敵: {16}/{17}\n運: {18}/{19}\n射程: {20} / 速力: {21}\n(右クリックで図鑑)\n",
             *                      ship.ShipTypeName, ship.NameWithClass, level < 1 ? "" : string.Format( " Lv. {0}", level ),
             *                      hp,
             *                      firepower_c, firepower,
             *                      torpedo_c, torpedo,
             *                      aa_c, aa,
             *                      armor_c, armor,
             *                      asw_c == -1 ? "???" : asw_c.ToString(), asw,
             *                      evasion_c == -1 ? "???" : evasion_c.ToString(), evasion,
             *                      los_c == -1 ? "???" : los_c.ToString(), los,
             *                      luck_c, luck,
             *                      Constants.GetRange( range ),
             *                      Constants.GetSpeed( ship.Speed )
             *                      );
             */

            var sb = new StringBuilder();

            sb.Append(ship.ShipTypeName).Append(" ").Append(ship.NameWithClass);
            if (level > 0)
            {
                sb.Append(" Lv. ").Append(level);
            }
            sb.AppendLine();

            sb.Append("耐久: ").Append(hp).AppendLine();

            sb.Append("火力: ").Append(firepower_c);
            if (firepower_c != firepower)
            {
                sb.Append("/").Append(firepower);
            }
            sb.AppendLine();

            sb.Append("雷装: ").Append(torpedo_c);
            if (torpedo_c != torpedo)
            {
                sb.Append("/").Append(torpedo);
            }
            sb.AppendLine();

            sb.Append("対空: ").Append(aa_c);
            if (aa_c != aa)
            {
                sb.Append("/").Append(aa);
            }
            sb.AppendLine();

            sb.Append("装甲: ").Append(armor_c);
            if (armor_c != armor)
            {
                sb.Append("/").Append(armor);
            }
            sb.AppendLine();

            sb.Append("対潜: ");
            if (asw_c < 0)
            {
                sb.Append("???");
            }
            else
            {
                sb.Append(asw_c);
            }
            if (asw_c != asw)
            {
                sb.Append("/").Append(asw);
            }
            sb.AppendLine();

            sb.Append("回避: ");
            if (evasion_c < 0)
            {
                sb.Append("???");
            }
            else
            {
                sb.Append(evasion_c);
            }
            if (evasion_c != evasion)
            {
                sb.Append("/").Append(evasion);
            }
            sb.AppendLine();

            sb.Append("索敵: ");
            if (los_c < 0)
            {
                sb.Append("???");
            }
            else
            {
                sb.Append(los_c);
            }
            if (los_c != los)
            {
                sb.Append("/").Append(los);
            }
            sb.AppendLine();

            sb.Append("運: ").Append(luck_c);
            if (luck_c != luck)
            {
                sb.Append("/").Append(luck);
            }
            sb.AppendLine();

            sb.AppendFormat("射程: {0} / 速力: {1}\r\n(右クリックで図鑑)\r\n",
                            Constants.GetRange(range),
                            Constants.GetSpeed(ship.Speed));

            return(sb.ToString());
        }
Beispiel #13
0
        public override void OnResponseReceived(dynamic data)
        {
            KCDatabase db = KCDatabase.Instance;


            //特別置換処理
            data.api_mst_stype[7].api_name = "巡洋戦艦";


            //api_mst_ship
            foreach (var elem in data.api_mst_ship)
            {
                int id = (int)elem.api_id;
                if (db.MasterShips[id] == null)
                {
                    var ship = new ShipDataMaster();
                    ship.LoadFromResponse(APIName, elem);
                    db.MasterShips.Add(ship);
                }
                else
                {
                    db.MasterShips[id].LoadFromResponse(APIName, elem);
                }
            }

            //改装関連のデータ設定
            foreach (var ship in db.MasterShips)
            {
                int remodelID = ship.Value.RemodelAfterShipID;
                if (remodelID != 0)
                {
                    db.MasterShips[remodelID].RemodelBeforeShipID = ship.Key;
                }
            }


            //api_mst_slotitem_equiptype
            foreach (var elem in data.api_mst_slotitem_equiptype)
            {
                int id = (int)elem.api_id;
                if (db.EquipmentTypes[id] == null)
                {
                    var eqt = new EquipmentType();
                    eqt.LoadFromResponse(APIName, elem);
                    db.EquipmentTypes.Add(eqt);
                }
                else
                {
                    db.EquipmentTypes[id].LoadFromResponse(APIName, elem);
                }
            }


            //api_mst_stype
            foreach (var elem in data.api_mst_stype)
            {
                int id = (int)elem.api_id;
                if (db.ShipTypes[id] == null)
                {
                    var spt = new ShipType();
                    spt.LoadFromResponse(APIName, elem);
                    db.ShipTypes.Add(spt);
                }
                else
                {
                    db.ShipTypes[id].LoadFromResponse(APIName, elem);
                }
            }


            //api_mst_slotitem
            foreach (var elem in data.api_mst_slotitem)
            {
                int id = (int)elem.api_id;
                if (db.MasterEquipments[id] == null)
                {
                    var eq = new EquipmentDataMaster();
                    eq.LoadFromResponse(APIName, elem);
                    db.MasterEquipments.Add(eq);
                }
                else
                {
                    db.MasterEquipments[id].LoadFromResponse(APIName, elem);
                }
            }


            //api_mst_useitem
            foreach (var elem in data.api_mst_useitem)
            {
                int id = (int)elem.api_id;
                if (db.MasterUseItems[id] == null)
                {
                    var item = new UseItemMaster();
                    item.LoadFromResponse(APIName, elem);
                    db.MasterUseItems.Add(item);
                }
                else
                {
                    db.MasterUseItems[id].LoadFromResponse(APIName, elem);
                }
            }

            //api_mst_maparea
            foreach (var elem in data.api_mst_maparea)
            {
                int id = (int)elem.api_id;
                if (db.MapArea[id] == null)
                {
                    var item = new MapAreaData();
                    item.LoadFromResponse(APIName, elem);
                    db.MapArea.Add(item);
                }
                else
                {
                    db.MapArea[id].LoadFromResponse(APIName, elem);
                }
            }

            //api_mst_mapinfo
            foreach (var elem in data.api_mst_mapinfo)
            {
                int id = (int)elem.api_id;
                if (db.MapInfo[id] == null)
                {
                    var item = new MapInfoData();
                    item.LoadFromResponse(APIName, elem);
                    db.MapInfo.Add(item);
                }
                else
                {
                    db.MapInfo[id].LoadFromResponse(APIName, elem);
                }
            }


            //api_mst_mission
            foreach (var elem in data.api_mst_mission)
            {
                int id = (int)elem.api_id;
                if (db.Mission[id] == null)
                {
                    var item = new MissionData();
                    item.LoadFromResponse(APIName, elem);
                    db.Mission.Add(item);
                }
                else
                {
                    db.Mission[id].LoadFromResponse(APIName, elem);
                }
            }


            //api_mst_shipupgrade
            Dictionary <int, int> upgradeLevels = new Dictionary <int, int>();

            foreach (var elem in data.api_mst_shipupgrade)
            {
                int idbefore   = (int)elem.api_current_ship_id;
                int idafter    = (int)elem.api_id;
                var shipbefore = db.MasterShips[idbefore];
                var shipafter  = db.MasterShips[idafter];
                int level      = (int)elem.api_upgrade_level;

                if (upgradeLevels.ContainsKey(idafter))
                {
                    if (level < upgradeLevels[idafter])
                    {
                        shipafter.RemodelBeforeShipID = idbefore;
                        upgradeLevels[idafter]        = level;
                    }
                }
                else
                {
                    shipafter.RemodelBeforeShipID = idbefore;
                    upgradeLevels.Add(idafter, level);
                }

                if (shipbefore != null)
                {
                    shipbefore.NeedBlueprint        = (int)elem.api_drawing_count;
                    shipbefore.NeedCatapult         = (int)elem.api_catapult_count;
                    shipbefore.NeedActionReport     = (int)elem.api_report_count;
                    shipbefore.NeedAviationMaterial = (int)elem.api_aviation_mat_count;
                    shipbefore.NeedArmamentMaterial = elem.api_arms_mat_count() ? (int)elem.api_arms_mat_count : 0;
                }
            }


            foreach (var elem in data.api_mst_equip_ship)
            {
                int id = (int)elem.api_ship_id;
                db.MasterShips[id].specialEquippableCategory = (int[])elem.api_equip_type;
            }

            foreach (var elem in data.api_mst_equip_exslot_ship)
            {
                int id = (int)elem.api_slotitem_id;
                db.MasterEquipments[id].equippableShipsAtExpansion = (int[])elem.api_ship_ids;
            }


            //api_mst_shipgraph
            foreach (var elem in data.api_mst_shipgraph)
            {
                int id = (int)elem.api_id;
                if (db.ShipGraphics[id] == null)
                {
                    var sgd = new ShipGraphicData();
                    sgd.LoadFromResponse(APIName, elem);
                    db.ShipGraphics.Add(sgd);
                }
                else
                {
                    db.ShipGraphics[id].LoadFromResponse(APIName, elem);
                }
            }



            Utility.Logger.Add(2, "提督が鎮守府に着任しました。これより艦隊の指揮を執ります。");

            base.OnResponseReceived((object)data);
        }
        /// <summary>
        /// 対空カットイン種別を取得します。
        /// </summary>
        public static int GetAACutinKind(int shipID, int[] slot)
        {
            int highangle          = 0;
            int highangle_director = 0;
            int director           = 0;
            int radar              = 0;
            int aaradar            = 0;
            int maingunl           = 0;
            int aashell            = 0;
            int aagun              = 0;
            int aagun_concentrated = 0;


            foreach (int eid in slot)
            {
                EquipmentDataMaster eq = KCDatabase.Instance.MasterEquipments[eid];
                if (eq == null)
                {
                    continue;
                }

                if (eq.IconType == 16)                          //高角砲
                // 10cm連装高角砲+高射装置 or 12.7cm高角砲+高射装置 or 90mm単装高角砲
                {
                    if (eq.EquipmentID == 122 || eq.EquipmentID == 130 || eq.EquipmentID == 135)
                    {
                        highangle_director++;
                    }
                    highangle++;
                }
                else if (eq.CategoryType == 36)                         //高射装置
                {
                    director++;
                }
                else if (eq.CardType == 8)                              //電探
                {
                    if (eq.AA > 0)
                    {
                        aaradar++;
                    }
                    radar++;
                }
                else if (eq.CategoryType == 3)                          //大口径主砲
                {
                    maingunl++;
                }
                else if (eq.CategoryType == 18)                         //対空強化弾
                {
                    aashell++;
                }
                else if (eq.CategoryType == 21)                         //対空機銃
                {
                    if (eq.EquipmentID == 131)                          //25mm三連装機銃 集中配備
                    {
                        aagun_concentrated++;
                    }
                    aagun++;
                }
            }


            //秋月/秋月改/照月/照月改限定
            if (shipID == 421 || shipID == 330 || shipID == 422 || shipID == 346)
            {
                if (highangle >= 2 && radar >= 1)
                {
                    return(1);
                }
                if (highangle >= 1 && radar >= 1)
                {
                    return(2);
                }
                if (highangle >= 2)
                {
                    return(3);
                }
            }

            if (shipID == 428)                          //摩耶改二限定
            {
                if (highangle >= 1 && aagun_concentrated >= 1)
                {
                    if (aaradar >= 1)
                    {
                        return(10);
                    }

                    return(11);
                }
            }

            if (shipID == 141)                          //五十鈴改二限定
            {
                if (highangle >= 1 && aagun >= 1 && aaradar >= 1)
                {
                    return(14);
                }
            }

            if (maingunl >= 1 && aashell >= 1 && director >= 1 && aaradar >= 1)
            {
                return(4);
            }
            if (highangle_director >= 2 && aaradar >= 1)
            {
                return(5);
            }
            if (maingunl >= 1 && aashell >= 1 && director >= 1)
            {
                return(6);
            }
            if (highangle >= 1 && director >= 1 && aaradar >= 1)
            {
                return(7);
            }
            if (highangle_director >= 1 && aaradar >= 1)
            {
                return(8);
            }
            if (highangle >= 1 && director >= 1)
            {
                return(9);
            }

            if (aagun_concentrated >= 1 && aagun >= 2 && aaradar >= 1)                  //注: 機銃2なのは集中機銃がダブるため
            {
                return(12);
            }

            return(0);
        }
        public override void OnResponseReceived(dynamic data)
        {
            KCDatabase db = KCDatabase.Instance;


            //特別置換処理
            data.api_mst_stype[7].api_name = "巡洋戦艦";


            //api_mst_ship
            foreach (var elem in data.api_mst_ship)
            {
                int id = (int)elem.api_id;
                if (db.MasterShips[id] == null)
                {
                    var ship = new ShipDataMaster();
                    ship.LoadFromResponse(APIName, elem);
                    db.MasterShips.Add(ship);
                }
                else
                {
                    db.MasterShips[id].LoadFromResponse(APIName, elem);
                }
            }

            //改装関連のデータ設定
            foreach (var ship in db.MasterShips)
            {
                int remodelID = ship.Value.RemodelAfterShipID;
                if (remodelID != 0)
                {
                    db.MasterShips[remodelID].RemodelBeforeShipID = ship.Key;
                }
            }

            //api_mst_shipgraph
            foreach (var elem in data.api_mst_shipgraph)
            {
                int            id   = (int)elem.api_id;
                ShipDataMaster ship = db.MasterShips[id];
                if (ship != null)
                {
                    ship.ResourceName    = elem.api_filename;
                    ship.ResourceVersion = elem.api_version;
                }
            }


            //api_mst_slotitem_equiptype
            foreach (var elem in data.api_mst_slotitem_equiptype)
            {
                int id = (int)elem.api_id;
                if (db.EquipmentTypes[id] == null)
                {
                    var eqt = new EquipmentType();
                    eqt.LoadFromResponse(APIName, elem);
                    db.EquipmentTypes.Add(eqt);
                }
                else
                {
                    db.EquipmentTypes[id].LoadFromResponse(APIName, elem);
                }
            }


            //api_mst_stype
            foreach (var elem in data.api_mst_stype)
            {
                int id = (int)elem.api_id;
                if (db.ShipTypes[id] == null)
                {
                    var spt = new ShipType();
                    spt.LoadFromResponse(APIName, elem);
                    db.ShipTypes.Add(spt);
                }
                else
                {
                    db.ShipTypes[id].LoadFromResponse(APIName, elem);
                }
            }


            //api_mst_slotitem
            foreach (var elem in data.api_mst_slotitem)
            {
                int id = (int)elem.api_id;
                if (db.MasterEquipments[id] == null)
                {
                    var eq = new EquipmentDataMaster();
                    eq.LoadFromResponse(APIName, elem);
                    db.MasterEquipments.Add(eq);
                }
                else
                {
                    db.MasterEquipments[id].LoadFromResponse(APIName, elem);
                }
            }

            //api_mst_slotitemgraph

            /*
             * foreach ( var elem in data.api_mst_slotitemgraph ) {
             *
             *      int id = (int)elem.api_id;
             *      EquipmentDataMaster eq = db.MasterEquipments[id];
             *      if ( eq != null ) {
             *              eq.ResourceVersion = elem.api_version;
             *      }
             * }
             */

            //api_mst_useitem
            foreach (var elem in data.api_mst_useitem)
            {
                int id = (int)elem.api_id;
                if (db.MasterUseItems[id] == null)
                {
                    var item = new UseItemMaster();
                    item.LoadFromResponse(APIName, elem);
                    db.MasterUseItems.Add(item);
                }
                else
                {
                    db.MasterUseItems[id].LoadFromResponse(APIName, elem);
                }
            }


            //api_mst_mapinfo
            foreach (var elem in data.api_mst_mapinfo)
            {
                int id = (int)elem.api_id;
                if (db.MapInfo[id] == null)
                {
                    var item = new MapInfoData();
                    item.LoadFromResponse(APIName, elem);
                    db.MapInfo.Add(item);
                }
                else
                {
                    db.MapInfo[id].LoadFromResponse(APIName, elem);
                }
            }


            //api_mst_mission
            foreach (var elem in data.api_mst_mission)
            {
                int id = (int)elem.api_id;
                if (db.Mission[id] == null)
                {
                    var item = new MissionData();
                    item.LoadFromResponse(APIName, elem);
                    db.Mission.Add(item);
                }
                else
                {
                    db.Mission[id].LoadFromResponse(APIName, elem);
                }
            }


            //api_mst_shipupgrade
            Dictionary <int, int> upgradeLevels = new Dictionary <int, int>();

            foreach (var elem in data.api_mst_shipupgrade)
            {
                int idbefore   = (int)elem.api_current_ship_id;
                int idafter    = (int)elem.api_id;
                var shipbefore = db.MasterShips[idbefore];
                var shipafter  = db.MasterShips[idafter];
                int level      = (int)elem.api_upgrade_level;

                if (upgradeLevels.ContainsKey(idafter))
                {
                    if (level < upgradeLevels[idafter])
                    {
                        shipafter.RemodelBeforeShipID = idbefore;
                        upgradeLevels[idafter]        = level;
                    }
                }
                else
                {
                    shipafter.RemodelBeforeShipID = idbefore;
                    upgradeLevels.Add(idafter, level);
                }

                if (shipbefore != null)
                {
                    shipbefore.NeedBlueprint = (int)elem.api_drawing_count;
                    shipbefore.NeedCatapult  = (int)elem.api_catapult_count;
                }
            }


            Utility.Logger.Add(2, "提督が鎮守府に着任しました。これより艦隊の指揮を執ります。");

            base.OnResponseReceived((object)data);
        }
Beispiel #16
0
        /// <summary>
        /// 戦闘終了時に各種データの収集を行います。
        /// </summary>
        private void BattleFinished()
        {
            //敵編成記録
            EnemyFleetRecord.EnemyFleetElement enemyFleetData = EnemyFleetRecord.EnemyFleetElement.CreateFromCurrentState();

            if (enemyFleetData != null)
            {
                RecordManager.Instance.EnemyFleet.Update(enemyFleetData);
            }


            // ロギング
            if (IsPractice)
            {
                Utility.Logger.Add(2,
                                   string.Format("Practiced with {1} {0}'s {2} fleet (Rank: {3}, Admiral exp+{4}, Ship exp+{5}).",
                                                 EnemyAdmiralName, EnemyAdmiralRank, Result.EnemyFleetName, Result.Rank, Result.AdmiralExp, Result.BaseExp));
            }
            else if (IsBaseAirRaid)
            {
                var initialHPs = BattleDay.Initial.FriendInitialHPs.TakeWhile(hp => hp >= 0);
                var damage     = initialHPs.Zip(BattleDay.ResultHPs.Take(initialHPs.Count()), (initial, result) => initial - result).Sum();
                var airraid    = ((BattleBaseAirRaid)BattleDay).BaseAirRaid;

                Utility.Logger.Add(2,
                                   string.Format("Encountered air raid at {0}-{1}-{2} ({3}, Damage taken: {4}, {5}).",
                                                 Compass.MapAreaID, Compass.MapInfoID, Compass.DestinationID,
                                                 Constants.GetAirSuperiority(airraid.IsAvailable ? airraid.AirSuperiority : -1), damage, Constants.GetAirRaidDamage(Compass.AirRaidDamageKind)));
            }
            else
            {
                Utility.Logger.Add(2,
                                   string.Format("Battled with 「{3}」 in {0}-{1}-{2} (Rank: {4}, Admiral exp+{5}, Ship exp+{6}).",
                                                 Compass.MapAreaID, Compass.MapInfoID, Compass.DestinationID, Result.EnemyFleetName, Result.Rank, Result.AdmiralExp, Result.BaseExp));
            }


            // Level up
            if (!IsBaseAirRaid)
            {
                var exps = Result.ExpList;
                var lvup = Result.LevelUpList;
                for (int i = 0; i < lvup.Length; i++)
                {
                    if (lvup[i].Length >= 2 && i < exps.Length && lvup[i][0] + exps[i] >= lvup[i][1])
                    {
                        var ship      = FirstBattle.Initial.FriendFleet.MembersInstance[i];
                        int increment = Math.Max(lvup[i].Length - 2, 1);

                        Utility.Logger.Add(2, string.Format("{0} has leveled up to lv{1}.", ship.Name, ship.Level + increment));
                    }
                }

                if (IsCombinedBattle)
                {
                    exps = Result.ExpListCombined;
                    lvup = Result.LevelUpListCombined;
                    for (int i = 0; i < lvup.Length; i++)
                    {
                        if (lvup[i].Length >= 2 && i < exps.Length && lvup[i][0] + exps[i] >= lvup[i][1])
                        {
                            var ship      = FirstBattle.Initial.FriendFleetEscort.MembersInstance[i];
                            int increment = Math.Max(lvup[i].Length - 2, 1);

                            Utility.Logger.Add(2, string.Format("{0} has leveled up to lv{1}.", ship.Name, ship.Level + increment));
                        }
                    }
                }
            }



            //ドロップ艦記録
            if (!IsPractice && !IsBaseAirRaid)
            {
                //checkme: とてもアレな感じ

                int  shipID  = Result.DroppedShipID;
                int  itemID  = Result.DroppedItemID;
                int  eqID    = Result.DroppedEquipmentID;
                bool showLog = Utility.Configuration.Config.Log.ShowSpoiler;

                if (shipID != -1)
                {
                    ShipDataMaster ship = KCDatabase.Instance.MasterShips[shipID];
                    DroppedShipCount++;

                    var defaultSlot = ship.DefaultSlot;
                    if (defaultSlot != null)
                    {
                        DroppedEquipmentCount += defaultSlot.Count(id => id != -1);
                    }

                    if (showLog)
                    {
                        Utility.Logger.Add(2, string.Format(LoggerRes.ShipAdded, ship.ShipTypeName, ship.NameWithClass));
                    }
                }

                if (itemID != -1)
                {
                    if (!DroppedItemCount.ContainsKey(itemID))
                    {
                        DroppedItemCount.Add(itemID, 0);
                    }
                    DroppedItemCount[itemID]++;

                    if (showLog)
                    {
                        var item       = KCDatabase.Instance.UseItems[itemID];
                        var itemmaster = KCDatabase.Instance.MasterUseItems[itemID];
                        Utility.Logger.Add(2, string.Format(LoggerRes.ItemObtained, itemmaster?.Name ?? ("Unknown item - ID: " + itemID), (item?.Count ?? 0) + DroppedItemCount[itemID]));
                    }
                }

                if (eqID != -1)
                {
                    EquipmentDataMaster eq = KCDatabase.Instance.MasterEquipments[eqID];
                    DroppedEquipmentCount++;

                    if (showLog)
                    {
                        Utility.Logger.Add(2, string.Format(LoggerRes.EquipmentObtained, eq.CategoryTypeInstance.Name, eq.Name));
                    }
                }


                // 満員判定
                if (shipID == -1 && (
                        KCDatabase.Instance.Admiral.MaxShipCount - (KCDatabase.Instance.Ships.Count + DroppedShipCount) <= 0 ||
                        KCDatabase.Instance.Admiral.MaxEquipmentCount - (KCDatabase.Instance.Equipments.Count + DroppedEquipmentCount) <= 0))
                {
                    shipID = -2;
                }

                RecordManager.Instance.ShipDrop.Add(shipID, itemID, eqID, Compass.MapAreaID, Compass.MapInfoID, Compass.Destination, Compass.MapInfo.EventDifficulty, Compass.EventID == 5, enemyFleetData.FleetID, Result.Rank, KCDatabase.Instance.Admiral.Level);
            }



            WriteBattleLog();



            /*//DEBUG
             * if (!IsBaseAirRaid && Utility.Configuration.Config.Log.LogLevel <= 1)
             * {
             *      var battle = SecondBattle ?? FirstBattle;
             *
             *      for (int i = 0; i < battle.Initial.EnemyMaxHPs.Length; i++)
             *      {
             *              if (battle.Initial.EnemyMaxHPs[i] > 0 && battle.ResultHPs[BattleIndex.Get(BattleSides.EnemyMain, i)] == 0)
             *                      Utility.Logger.Add(1, "justkill #" + (i + 1));
             *      }
             *
             * int rank = PredictWinRank(out var friend, out var enemy);
             *
             *      // SS -> S
             *      if (Constants.GetWinRank(rank).Substring(0, 1) != Result.Rank)
             *      {
             *              Utility.Logger.Add(1, $"勝利ランク予測が誤っています。予想 {Constants.GetWinRank(rank)} -> 実際 {Result.Rank}");
             *      }
             * }
             * //*/
        }
Beispiel #17
0
        /// <summary>
        /// 戦闘終了時に各種データの収集を行います。
        /// </summary>
        private void BattleFinished()
        {
            //敵編成記録
            if (Compass.EnemyFleetID != -1)
            {
                switch (BattleMode & BattleModes.BattlePhaseMask)
                {
                case BattleModes.Normal:
                case BattleModes.AirBattle:
                    RecordManager.Instance.EnemyFleet.Update(new EnemyFleetRecord.EnemyFleetElement(Compass.EnemyFleetID, Result.EnemyFleetName, BattleDay.Searching.FormationEnemy, BattleDay.Initial.EnemyMembers));
                    break;

                case BattleModes.NightOnly:
                case BattleModes.NightDay:
                    RecordManager.Instance.EnemyFleet.Update(new EnemyFleetRecord.EnemyFleetElement(Compass.EnemyFleetID, Result.EnemyFleetName, BattleNight.Searching.FormationEnemy, BattleNight.Initial.EnemyMembers));
                    break;
                }
            }


            //ドロップ艦記録
            if ((BattleMode & BattleModes.BattlePhaseMask) != BattleModes.Practice)
            {
                //checkme: とてもアレな感じ

                int  dropID  = Result.DroppedShipID;
                bool showLog = Utility.Configuration.Config.Log.ShowSpoiler;

                if (dropID != -1)
                {
                    ShipDataMaster ship = KCDatabase.Instance.MasterShips[dropID];

                    DroppedShipCount++;

                    var defaultSlot = ship.DefaultSlot;
                    if (defaultSlot != null)
                    {
                        DroppedEquipmentCount += defaultSlot.Count(id => id != -1);
                    }

                    if (showLog)
                    {
                        Utility.Logger.Add(2, string.Format("{0}「{1}」が戦列に加わりました。", ship.ShipTypeName, ship.NameWithClass));
                    }
                }

                if (dropID == -1)
                {
                    int itemID = Result.DroppedItemID;

                    if (itemID != -1)
                    {
                        dropID = itemID + 1000;
                        if (showLog)
                        {
                            Utility.Logger.Add(2, string.Format("アイテム「{0}」を入手しました。", KCDatabase.Instance.MasterUseItems[itemID].Name));
                        }
                    }
                }

                if (dropID == -1)
                {
                    int eqID = Result.DroppedEquipmentID;

                    if (eqID != -1)
                    {
                        dropID = eqID + 2000;
                        if (showLog)
                        {
                            EquipmentDataMaster eq = KCDatabase.Instance.MasterEquipments[eqID];
                            Utility.Logger.Add(2, string.Format("{0}「{1}」を入手しました。", eq.CategoryTypeInstance.Name, eq.Name));
                        }

                        DroppedEquipmentCount++;
                    }
                }


                if (dropID == -1 && (
                        KCDatabase.Instance.Admiral.MaxShipCount - (KCDatabase.Instance.Ships.Count + DroppedShipCount) <= 0 ||
                        KCDatabase.Instance.Admiral.MaxEquipmentCount - (KCDatabase.Instance.Equipments.Count + DroppedEquipmentCount) <= 0))
                {
                    dropID = -2;
                }

                RecordManager.Instance.ShipDrop.Add(dropID, Compass.MapAreaID, Compass.MapInfoID, Compass.Destination, Compass.EventID == 5, Compass.EnemyFleetID, Result.Rank, KCDatabase.Instance.Admiral.Level);
            }
        }
        /// <summary>
        /// 戦闘終了時に各種データの収集を行います。
        /// </summary>
        private void BattleFinished()
        {
            //敵編成記録
            EnemyFleetRecord.EnemyFleetElement enemyFleetData = EnemyFleetRecord.EnemyFleetElement.CreateFromCurrentState();

            if (enemyFleetData != null)
            {
                RecordManager.Instance.EnemyFleet.Update(enemyFleetData);
            }


            //ドロップ艦記録
            if ((BattleMode & BattleModes.BattlePhaseMask) != BattleModes.Practice)
            {
                //checkme: とてもアレな感じ

                int  shipID  = Result.DroppedShipID;
                int  itemID  = Result.DroppedItemID;
                int  eqID    = Result.DroppedEquipmentID;
                bool showLog = Utility.Configuration.Config.Log.ShowSpoiler;

                if (shipID != -1)
                {
                    ShipDataMaster ship = KCDatabase.Instance.MasterShips[shipID];
                    DroppedShipCount++;

                    var defaultSlot = ship.DefaultSlot;
                    if (defaultSlot != null)
                    {
                        DroppedEquipmentCount += defaultSlot.Count(id => id != -1);
                    }

                    if (showLog)
                    {
                        Utility.Logger.Add(2, string.Format(LoggerRes.ShipAdded, ship.ShipTypeName, ship.NameWithClass));
                    }
                }
                if (itemID != -1)
                {
                    if (!DroppedItemCount.ContainsKey(itemID))
                    {
                        DroppedItemCount.Add(itemID, 0);
                    }
                    DroppedItemCount[itemID]++;

                    if (showLog)
                    {
                        var item       = KCDatabase.Instance.UseItems[itemID];
                        var itemmaster = KCDatabase.Instance.MasterUseItems[itemID];
                        Utility.Logger.Add(2, string.Format(LoggerRes.ItemObtained, itemmaster != null ? itemmaster.Name : ("Unknown item - ID: " + itemID), (item != null ? item.Count : 0) + DroppedItemCount[itemID]));
                    }
                }

                if (eqID != -1)
                {
                    EquipmentDataMaster eq = KCDatabase.Instance.MasterEquipments[eqID];
                    DroppedEquipmentCount++;
                    if (showLog)
                    {
                        Utility.Logger.Add(2, string.Format(LoggerRes.EquipmentObtained, eq.CategoryTypeInstance.Name, eq.Name));
                    }
                }


                // 満員判定
                if (shipID == -1 && (
                        KCDatabase.Instance.Admiral.MaxShipCount - (KCDatabase.Instance.Ships.Count + DroppedShipCount) <= 0 ||
                        KCDatabase.Instance.Admiral.MaxEquipmentCount - (KCDatabase.Instance.Equipments.Count + DroppedEquipmentCount) <= 0))
                {
                    shipID = -2;
                }

                RecordManager.Instance.ShipDrop.Add(shipID, itemID, eqID, Compass.MapAreaID, Compass.MapInfoID, Compass.Destination, Compass.MapInfo.EventDifficulty, Compass.EventID == 5, enemyFleetData.FleetID, Result.Rank, KCDatabase.Instance.Admiral.Level);
            }


            //DEBUG

            /*/
             * if ( Utility.Configuration.Config.Log.LogLevel <= 1 && Utility.Configuration.Config.Connection.SaveReceivedData ) {
             *      IEnumerable<int> damages;
             *      switch ( BattleMode & BattleModes.BattlePhaseMask ) {
             *              case BattleModes.Normal:
             *              case BattleModes.AirBattle:
             *              case BattleModes.Practice:
             *              default:
             *                      damages = ( (BattleData)BattleNight ?? BattleDay ).AttackDamages;
             *                      break;
             *              case BattleModes.NightOnly:
             *              case BattleModes.NightDay:
             *                      damages = ( (BattleData)BattleDay ?? BattleNight ).AttackDamages;
             *                      break;
             *      }
             *
             *      damages = damages.Take( 6 ).Where( i => i > 0 );
             *
             *      if ( damages.Count( i => i == damages.Max() ) > 1 ) {
             *              Utility.Logger.Add( 1, LoggerRes.MultiplePossibleMvps );
             *      }
             * }
             * //*/
        }
        /// <summary>
        /// 夜戦における攻撃種別を取得します。
        /// </summary>
        /// <param name="slot">攻撃艦のスロット(マスターID)。</param>
        /// <param name="attackerShipID">攻撃艦の艦船ID。</param>
        /// <param name="defenerShipID">防御艦の艦船ID。なければ-1</param>
        /// <param name="includeSpecialAttack">カットイン/連撃の判定を含むか。falseなら除外して計算</param>
        public static int GetNightAttackKind(int[] slot, int attackerShipID, int defenerShipID, bool includeSpecialAttack = true)
        {
            int mainguncnt = 0;
            int subguncnt  = 0;
            int torpcnt    = 0;
            int rocketcnt  = 0;
            int landingcnt = 0;
            int uchibicnt  = 0;

            if (slot == null)
            {
                return(-1);
            }

            for (int i = 0; i < slot.Length; i++)
            {
                EquipmentDataMaster eq = KCDatabase.Instance.MasterEquipments[slot[i]];
                if (eq == null)
                {
                    continue;
                }

                int eqtype = eq.EquipmentType[2];

                switch (eqtype)
                {
                case 1:
                case 2:
                case 3:
                    mainguncnt++; break;                                //主砲

                case 4:
                    subguncnt++; break;                                         //副砲

                case 5:
                case 32:
                    torpcnt++; break;                                           //魚雷

                case 37:                                                        //対地装備
                    rocketcnt++; break;
                }
            }


            if (includeSpecialAttack)
            {
                if (torpcnt >= 2)
                {
                    return(3);                                          //カットイン(魚雷/魚雷)
                }
                else if (mainguncnt >= 3)
                {
                    return(5);                                          //カットイン(主砲x3)
                }
                else if (mainguncnt == 2 && subguncnt > 0)
                {
                    return(4);                                          //カットイン(主砲x2/副砲)
                }
                else if ((mainguncnt == 2 && subguncnt == 0 && torpcnt == 1) || (mainguncnt == 1 && torpcnt == 1))
                {
                    return(2);                                          //カットイン(主砲/魚雷)
                }
                else if ((mainguncnt == 2 && subguncnt == 0 & torpcnt == 0) ||
                         (mainguncnt == 1 && subguncnt > 0) ||
                         (subguncnt >= 2 && torpcnt <= 1))
                {
                    return(1);                                          //連撃
                }
            }


            ShipDataMaster atkship = KCDatabase.Instance.MasterShips[attackerShipID];
            ShipDataMaster defship = KCDatabase.Instance.MasterShips[defenerShipID];

            if (atkship != null)
            {
                if (defship != null)
                {
                    if (uchibicnt > 0 && (((atkship.ShipType == 13 || atkship.ShipType == 14) && defship.IsLandBase) || HardInstallationNames.Contains(defship.Name)))
                    {
                        return(12);                                     // 揚陸攻撃(内火艇)
                    }
                    if (landingcnt > 0 && HardInstallationNames.Contains(defship.Name))
                    {
                        return(11);                                     // 揚陸攻撃(大発動艇)
                    }
                    if (rocketcnt > 0 && defship.IsLandBase)
                    {
                        return(10);                                     //ロケット砲撃
                    }
                }


                if (atkship.ShipType == 7 || atkship.ShipType == 11 || atkship.ShipType == 18)                                  //軽空母/正規空母/装甲空母

                {
                    if (attackerShipID == 432 || attackerShipID == 353) //Graf Zeppelin(改)
                    {
                        return(0);                                      //砲撃
                    }
                    else if (atkship.Name == "リコリス棲姫")
                    {
                        return(0);                                      //砲撃
                    }
                    else
                    {
                        return(7);                                      //空撃
                    }
                }
                else if (atkship.ShipType == 13 || atkship.ShipType == 14)                      //潜水艦/潜水空母
                {
                    return(9);                                                                  //雷撃
                }
                else if (defship != null && (defship.ShipType == 13 || defship.ShipType == 14)) //潜水艦/潜水空母
                {
                    if (atkship.ShipType == 6 || atkship.ShipType == 10 ||
                        atkship.ShipType == 16 || atkship.ShipType == 17) //航空巡洋艦/航空戦艦/水上機母艦/揚陸艦
                    {
                        return(7);                                        //空撃
                    }
                    else
                    {
                        return(8);                                      //爆雷攻撃
                    }
                }
                else if (slot.Length > 0)
                {
                    EquipmentDataMaster eq = KCDatabase.Instance.MasterEquipments[slot[0]];
                    if (eq != null && (eq.CategoryType == 5 || eq.CategoryType == 32)) //最初のスロット==魚雷		(本来の判定とは微妙に異なるが無問題)
                    {
                        return(9);                                                     //雷撃
                    }
                }
            }

            return(0);                          //砲撃
        }
        /// <summary>
        /// 昼戦における攻撃種別を取得します。
        /// </summary>
        /// <param name="slot">攻撃艦のスロット(マスターID)。</param>
        /// <param name="attackerShipID">攻撃艦の艦船ID。</param>
        /// <param name="defenerShipID">防御艦の艦船ID。なければ-1</param>
        /// <param name="includeSpecialAttack">弾着観測砲撃を含むか。falseなら除外して計算</param>
        public static int GetDayAttackKind(int[] slot, int attackerShipID, int defenerShipID, bool includeSpecialAttack = true)
        {
            int reconcnt   = 0;
            int mainguncnt = 0;
            int subguncnt  = 0;
            int apshellcnt = 0;
            int radarcnt   = 0;
            int rocketcnt  = 0;

            if (slot == null)
            {
                return(-1);
            }

            for (int i = 0; i < slot.Length; i++)
            {
                EquipmentDataMaster eq = KCDatabase.Instance.MasterEquipments[slot[i]];
                if (eq == null)
                {
                    continue;
                }

                int eqtype = eq.CategoryType;

                switch (eqtype)
                {
                case 1:
                case 2:
                case 3:
                    mainguncnt++;
                    break;

                case 4:
                    subguncnt++;
                    break;

                case 10:
                case 11:
                    reconcnt++;
                    break;

                case 12:
                case 13:
                    radarcnt++;
                    break;

                case 19:
                    apshellcnt++;
                    break;

                case 37:
                    rocketcnt++;
                    break;
                }
            }

            if (reconcnt > 0 && includeSpecialAttack)
            {
                if (mainguncnt == 2 && apshellcnt == 1)
                {
                    return(6);                                  //カットイン(主砲/主砲)
                }
                else if (mainguncnt == 1 && subguncnt == 1 && apshellcnt == 1)
                {
                    return(5);                                  //カットイン(主砲/徹甲弾)
                }
                else if (mainguncnt == 1 && subguncnt == 1 && radarcnt == 1)
                {
                    return(4);                                  //カットイン(主砲/電探)
                }
                else if (mainguncnt >= 1 && subguncnt >= 1)
                {
                    return(3);                                  //カットイン(主砲/副砲)
                }
                else if (mainguncnt >= 2)
                {
                    return(2);                                  //連撃
                }
            }


            ShipDataMaster atkship = KCDatabase.Instance.MasterShips[attackerShipID];
            ShipDataMaster defship = KCDatabase.Instance.MasterShips[defenerShipID];

            if (atkship != null)
            {
                if (defship != null && defship.IsLandBase && rocketcnt > 0)
                {
                    return(10);                                 //ロケット砲撃
                }
                else if (attackerShipID == 352)                 //速吸改

                {
                    if (defship != null && (defship.ShipType == 13 || defship.ShipType == 14))
                    {
                        if (slot.Select(id => KCDatabase.Instance.MasterEquipments[id])
                            .Count(eq => eq != null && ((eq.CategoryType == 8 && eq.ASW > 0) || eq.CategoryType == 11 || eq.CategoryType == 25)) > 0)
                        {
                            return(7);                                          //空撃
                        }
                        else
                        {
                            return(8);                                  //爆雷攻撃
                        }
                    }
                    else if (slot.Select(id => KCDatabase.Instance.MasterEquipments[id]).Count(eq => eq != null && eq.CategoryType == 8) > 0)
                    {
                        return(7);                                      //空撃
                    }
                    else
                    {
                        return(0);                                      //砲撃
                    }
                }
                else if (atkship.ShipType == 7 || atkship.ShipType == 11 || atkship.ShipType == 18) //軽空母/正規空母/装甲空母
                {
                    return(7);                                                                      //空撃
                }
                else if (defship != null && (defship.ShipType == 13 || defship.ShipType == 14))     //潜水艦/潜水空母
                {
                    if (atkship.ShipType == 6 || atkship.ShipType == 10 ||
                        atkship.ShipType == 16 || atkship.ShipType == 17) //航空巡洋艦/航空戦艦/水上機母艦/揚陸艦
                    {
                        return(7);                                        //空撃
                    }
                    else
                    {
                        return(8);                                      //爆雷攻撃
                    }
                }
                //本来の雷撃は発生しない
                else if (atkship.ShipType == 13 || atkship.ShipType == 14) //潜水艦/潜水空母
                {
                    return(9);                                             //雷撃(特例措置, 本来のコード中には存在しない)
                }
            }

            return(0);
        }
        /// <summary>
        /// 夜戦における攻撃種別を取得します。
        /// </summary>
        /// <param name="slot">攻撃艦のスロット(マスターID)。</param>
        /// <param name="attackerShipID">攻撃艦の艦船ID。</param>
        /// <param name="defenerShipID">防御艦の艦船ID。なければ-1</param>
        public static int GetNightAttackKind(int[] slot, int attackerShipID, int defenerShipID)
        {
            int mainguncnt = 0;
            int subguncnt  = 0;
            int torpcnt    = 0;
            int rocketcnt  = 0;

            if (slot == null)
            {
                return(-1);
            }

            for (int i = 0; i < slot.Length; i++)
            {
                EquipmentDataMaster eq = KCDatabase.Instance.MasterEquipments[slot[i]];
                if (eq == null)
                {
                    continue;
                }

                int eqtype = eq.EquipmentType[2];

                switch (eqtype)
                {
                case 1:
                case 2:
                case 3:
                    mainguncnt++; break;                                //主砲

                case 4:
                    subguncnt++; break;                                         //副砲

                case 5:
                case 32:
                    torpcnt++; break;                                           //魚雷

                case 37:                                                        //対地装備
                    rocketcnt++; break;
                }
            }


            if (torpcnt >= 2)
            {
                return(3);                                      //カットイン(魚雷/魚雷)
            }
            else if (mainguncnt >= 3)
            {
                return(5);                                      //カットイン(主砲x3)
            }
            else if (mainguncnt == 2 && subguncnt > 0)
            {
                return(4);                                      //カットイン(主砲x2/副砲)
            }
            else if ((mainguncnt == 2 && subguncnt == 0 && torpcnt == 1) || (mainguncnt == 1 && torpcnt == 1))
            {
                return(2);                                      //カットイン(主砲/魚雷)
            }
            else if ((mainguncnt == 2 && subguncnt == 0 & torpcnt == 0) ||
                     (mainguncnt == 1 && subguncnt > 0) ||
                     (subguncnt >= 2 && torpcnt <= 1))
            {
                return(1);                                      //連撃
            }


            ShipDataMaster atkship = KCDatabase.Instance.MasterShips[attackerShipID];
            ShipDataMaster defship = KCDatabase.Instance.MasterShips[defenerShipID];

            if (atkship != null)
            {
                if (defship != null && defship.IsLandBase && rocketcnt > 0)
                {
                    return(10);                                                                     //ロケット砲撃
                }
                else if (atkship.ShipType == 7 || atkship.ShipType == 11 || atkship.ShipType == 18) //軽空母/正規空母/装甲空母
                {
                    return(7);                                                                      //空撃
                }
                else if (atkship.ShipType == 13 || atkship.ShipType == 14)                          //潜水艦/潜水空母
                {
                    return(9);                                                                      //雷撃
                }
                else if (defship != null && (defship.ShipType == 13 || defship.ShipType == 14))     //潜水艦/潜水空母
                {
                    if (atkship.ShipType == 6 || atkship.ShipType == 10 ||
                        atkship.ShipType == 16 || atkship.ShipType == 17) //航空巡洋艦/航空戦艦/水上機母艦/揚陸艦
                    {
                        return(7);                                        //空撃
                    }
                    else
                    {
                        return(8);                                      //爆雷攻撃
                    }
                }
                else if (slot.Length > 0)
                {
                    EquipmentDataMaster eq = KCDatabase.Instance.MasterEquipments[slot[0]];
                    if (eq != null && eq.EquipmentType[2] == 5)         //最初のスロット==魚雷		(本来の判定とは微妙に異なるが無問題)
                    {
                        return(9);                                      //雷撃
                    }
                }
            }

            return(0);                          //砲撃
        }
        private void UpdateAlbumPage(int equipmentID)
        {
            KCDatabase          db = KCDatabase.Instance;
            EquipmentDataMaster eq = db.MasterEquipments[equipmentID];

            if (eq == null)
            {
                return;
            }


            BasePanelEquipment.SuspendLayout();


            //header
            EquipmentID.Tag  = equipmentID;
            EquipmentID.Text = eq.EquipmentID.ToString();
            ToolTipInfo.SetToolTip(EquipmentID, string.Format("Type: [ {0} ]", string.Join(", ", eq.EquipmentType)));
            AlbumNo.Text = eq.AlbumNo.ToString();


            TableEquipmentName.SuspendLayout();

            EquipmentType.Text = db.EquipmentTypes[eq.EquipmentType[2]].Name;

            {
                int eqicon = eq.EquipmentType[3];
                if (eqicon >= (int)ResourceManager.EquipmentContent.Locked)
                {
                    eqicon = (int)ResourceManager.EquipmentContent.Unknown;
                }
                EquipmentType.ImageIndex = eqicon;

                StringBuilder sb = new StringBuilder();
                sb.AppendLine("装備可能艦種:");
                foreach (var stype in KCDatabase.Instance.ShipTypes.Values)
                {
                    if (stype.EquipmentType.Contains(eq.EquipmentType[2]))
                    {
                        sb.AppendLine(stype.Name);
                    }
                }
                ToolTipInfo.SetToolTip(EquipmentType, sb.ToString());
            }
            EquipmentName.Text = eq.Name;

            TableEquipmentName.ResumeLayout();


            //main parameter
            TableParameterMain.SuspendLayout();

            SetParameterText(Firepower, eq.Firepower);
            SetParameterText(Torpedo, eq.Torpedo);
            SetParameterText(AA, eq.AA);
            SetParameterText(Armor, eq.Armor);
            SetParameterText(ASW, eq.ASW);
            SetParameterText(Evasion, eq.Evasion);
            SetParameterText(LOS, eq.LOS);
            SetParameterText(Accuracy, eq.Accuracy);
            SetParameterText(Bomber, eq.Bomber);

            if (eq.CategoryType == 48)
            {
                TitleAccuracy.Text = "対爆";
                TitleEvasion.Text  = "迎撃";
            }
            else
            {
                TitleAccuracy.Text = "命中";
                TitleEvasion.Text  = "回避";
            }

            TableParameterMain.ResumeLayout();


            //sub parameter
            TableParameterSub.SuspendLayout();

            Speed.Text        = "なし";      //Constants.GetSpeed( eq.Speed );
            Range.Text        = Constants.GetRange(eq.Range);
            Rarity.Text       = Constants.GetEquipmentRarity(eq.Rarity);
            Rarity.ImageIndex = (int)ResourceManager.IconContent.RarityRed + Constants.GetEquipmentRarityID(eq.Rarity);                         //checkme

            TableParameterSub.ResumeLayout();


            // aircraft
            if (Calculator.IsAircraft(equipmentID, true, true))
            {
                TableAircraft.SuspendLayout();
                AircraftCost.Text = eq.AircraftCost.ToString();
                ToolTipInfo.SetToolTip(AircraftCost, "配備時のボーキ消費:" + ((Calculator.IsAircraft(equipmentID, false) ? 18 : 4) * eq.AircraftCost));
                AircraftDistance.Text = eq.AircraftDistance.ToString();
                TableAircraft.ResumeLayout();
                TableAircraft.Visible = true;
            }
            else
            {
                TableAircraft.Visible = false;
            }


            //default equipment
            DefaultSlots.BeginUpdate();
            DefaultSlots.Items.Clear();
            foreach (var ship in KCDatabase.Instance.MasterShips.Values)
            {
                if (ship.DefaultSlot != null && ship.DefaultSlot.Contains(equipmentID))
                {
                    DefaultSlots.Items.Add(ship);
                }
            }
            DefaultSlots.EndUpdate();


            Description.Text = eq.Message;


            //arsenal
            TableArsenal.SuspendLayout();

            MaterialFuel.Text    = eq.Material[0].ToString();
            MaterialAmmo.Text    = eq.Material[1].ToString();
            MaterialSteel.Text   = eq.Material[2].ToString();
            MaterialBauxite.Text = eq.Material[3].ToString();

            TableArsenal.ResumeLayout();



            //装備画像を読み込んでみる
            {
                string path = string.Format(@"{0}\\resources\\image\\slotitem\\card\\{1:D3}.png", Utility.Configuration.Config.Connection.SaveDataPath, equipmentID);
                if (File.Exists(path))
                {
                    try {
                        EquipmentImage.Image = new Bitmap(path);
                    } catch (Exception) {
                        if (EquipmentImage.Image != null)
                        {
                            EquipmentImage.Image.Dispose();
                        }
                        EquipmentImage.Image = null;
                    }
                }
                else
                {
                    if (EquipmentImage.Image != null)
                    {
                        EquipmentImage.Image.Dispose();
                    }
                    EquipmentImage.Image = null;
                }
            }


            BasePanelEquipment.ResumeLayout();
            BasePanelEquipment.Visible = true;


            this.Text = "装備図鑑 - " + eq.Name;
        }
            private string GetShipString(int shipID, int[] slot, int level, int hp, int firepower, int torpedo, int aa, int armor, int asw, int evasion, int los, int luck)
            {
                ShipDataMaster ship = KCDatabase.Instance.MasterShips[shipID];

                if (ship == null)
                {
                    return(null);
                }

                int firepower_c = firepower;
                int torpedo_c   = torpedo;
                int aa_c        = aa;
                int armor_c     = armor;
                int asw_c       = asw;
                int evasion_c   = evasion;
                int los_c       = los;
                int luck_c      = luck;
                int range       = ship.Range;

                asw     = Math.Max(asw, 0);
                evasion = Math.Max(evasion, 0);
                los     = Math.Max(los, 0);

                if (slot != null)
                {
                    int count = slot.Length;
                    for (int i = 0; i < count; i++)
                    {
                        EquipmentDataMaster eq = KCDatabase.Instance.MasterEquipments[slot[i]];
                        if (eq == null)
                        {
                            continue;
                        }

                        firepower += eq.Firepower;
                        torpedo   += eq.Torpedo;
                        aa        += eq.AA;
                        armor     += eq.Armor;
                        asw       += eq.ASW;
                        evasion   += eq.Evasion;
                        los       += eq.LOS;
                        luck      += eq.Luck;
                        range      = Math.Max(range, eq.Range);
                    }
                }

                return(string.Format(
                           GeneralRes.CompassShipTooltip,
                           ship.ShipTypeName, ship.NameWithClass, level < 1 ? "" : string.Format(" Lv. {0}", level),
                           hp,
                           firepower_c, firepower,
                           torpedo_c, torpedo,
                           aa_c, aa,
                           armor_c, armor,
                           asw_c == -1 ? "???" : asw_c.ToString(), asw,
                           evasion_c == -1 ? "???" : evasion_c.ToString(), evasion,
                           los_c == -1 ? "???" : los_c.ToString(), los,
                           luck_c, luck,
                           Constants.GetRange(range),
                           Constants.GetSpeed(ship.Speed)
                           ));
            }
Beispiel #24
0
        /// <summary>
        /// 対空カットイン種別を取得します。
        /// </summary>
        public static int GetAACutinKind(int shipID, int[] slot)
        {
            int highangle          = 0;
            int highangle_director = 0;
            int director           = 0;
            int radar              = 0;
            int aaradar            = 0;
            int maingunl           = 0;
            int aashell            = 0;
            int aagun              = 0;
            int aagun_concentrated = 0;


            foreach (int eid in slot)
            {
                EquipmentDataMaster eq = KCDatabase.Instance.MasterEquipments[eid];
                if (eq == null)
                {
                    continue;
                }

                if (eq.IconType == 16)                          //高角砲
                {
                    if (eq.AA >= 8)
                    {
                        highangle_director++;
                    }

                    highangle++;
                }
                else if (eq.CategoryType == 36)                         //高射装置
                {
                    director++;
                }
                else if (eq.CardType == 8)                              //電探
                {
                    if (eq.AA >= 2)
                    {
                        aaradar++;
                    }
                    radar++;
                }
                else if (eq.CategoryType == 3)                          //大口径主砲
                {
                    maingunl++;
                }
                else if (eq.CategoryType == 18)                         //対空強化弾
                {
                    aashell++;
                }
                else if (eq.CategoryType == 21)                         //対空機銃
                {
                    if (eq.AA >= 9)
                    {
                        aagun_concentrated++;
                    }

                    aagun++;
                }
            }


            // 固有カットイン
            switch (shipID)
            {
            case 421:                           //秋月
            case 330:                           //秋月改
            case 422:                           //照月
            case 346:                           //照月改
            case 423:                           //初月
            case 357:                           //初月改
                if (highangle >= 2 && radar >= 1)
                {
                    return(1);
                }
                if (highangle >= 1 && radar >= 1)
                {
                    return(2);
                }
                if (highangle >= 2)
                {
                    return(3);
                }
                break;

            case 428:                           //摩耶改二
                if (highangle >= 1 && aagun_concentrated >= 1)
                {
                    if (aaradar >= 1)
                    {
                        return(10);
                    }

                    return(11);
                }
                break;

            case 141:                           //五十鈴改二
                if (highangle >= 1 && aagun >= 1)
                {
                    if (aaradar >= 1)
                    {
                        return(14);
                    }
                    else
                    {
                        return(15);
                    }
                }
                break;

            case 470:                           //霞改二乙
                if (highangle >= 1 && aagun >= 1)
                {
                    if (aaradar >= 1)
                    {
                        return(16);
                    }
                    else
                    {
                        return(17);
                    }
                }
                break;

            case 418:                           //皐月改二
                if (aagun_concentrated >= 1)
                {
                    return(18);
                }
                break;
            }



            if (maingunl >= 1 && aashell >= 1 && director >= 1 && aaradar >= 1)
            {
                return(4);
            }
            if (highangle_director >= 2 && aaradar >= 1)
            {
                return(5);
            }
            if (maingunl >= 1 && aashell >= 1 && director >= 1)
            {
                return(6);
            }
            if (highangle >= 1 && director >= 1 && aaradar >= 1)
            {
                return(7);
            }
            if (highangle_director >= 1 && aaradar >= 1)
            {
                return(8);
            }
            if (highangle >= 1 && director >= 1)
            {
                return(9);
            }

            if (aagun_concentrated >= 1 && aagun >= 2 && aaradar >= 1)                  //注: 機銃2なのは集中機銃がダブるため
            {
                return(12);
            }

            return(0);
        }
        /// <summary>
        /// 戦闘終了時に各種データの収集を行います。
        /// </summary>
        private void BattleFinished()
        {
            //敵編成記録
            EnemyFleetRecord.EnemyFleetElement enemyFleetData = EnemyFleetRecord.EnemyFleetElement.CreateFromCurrentState();

            if (enemyFleetData != null)
            {
                RecordManager.Instance.EnemyFleet.Update(enemyFleetData);
            }


            // ロギング
            if (IsPractice)
            {
                Utility.Logger.Add(2, "", "同", string.Format("「{0}」[{1}]", EnemyAdmiralName, EnemyAdmiralRank),
                                   "的舰队", string.Format("「{0}」", Result.EnemyFleetName),
                                   string.Format("进行了演习。( 结果 : {0}, 提督经验 +{1}, 舰娘经验 +{2} )",
                                                 Result.Rank, Result.AdmiralExp, Result.BaseExp));
            }
            else if (IsBaseAirRaid)
            {
                var initialHPs = BattleDay.Initial.FriendInitialHPs.TakeWhile(hp => hp >= 0);
                var damage     = initialHPs.Zip(BattleDay.ResultHPs.Take(initialHPs.Count()), (initial, result) => initial - result).Sum();

                Utility.Logger.Add(2, "",
                                   string.Format("在 {0}-{1}-{2} 海域,基地受到了空袭。( 受损合计 : {3}, {4} )",
                                                 Compass.MapAreaID, Compass.MapInfoID, Compass.Destination, damage, Constants.GetAirRaidDamage(Compass.AirRaidDamageKind)));
            }
            else
            {
                Utility.Logger.Add(2, "", string.Format("在 {0}-{1}-{2} 海域与",
                                                        Compass.MapAreaID, Compass.MapInfoID, Compass.Destination),
                                   string.Format("「{0}」", Result.EnemyFleetName),
                                   string.Format("进行了战斗。( 结果 : {0}, 提督经验 +{1}, 舰娘经验 +{2} )",
                                                 Result.Rank, Result.AdmiralExp, Result.BaseExp));
            }


            // Level up
            if (!IsBaseAirRaid)
            {
                var exps = Result.ExpList;
                var lvup = Result.LevelUpList;
                for (int i = 0; i < lvup.Length; i++)
                {
                    if (lvup[i].Length >= 2 && i < exps.Length && lvup[i][0] + exps[i] >= lvup[i][1])
                    {
                        var ship      = FirstBattle.Initial.FriendFleet.MembersInstance[i];
                        int increment = Math.Max(lvup[i].Length - 2, 1);

                        Utility.Logger.Add(2, ship.Name, string.Format(" 的等级达到了 Lv. {0} 。", ship.Level + increment));
                    }
                }

                if (IsCombinedBattle)
                {
                    exps = Result.ExpListCombined;
                    lvup = Result.LevelUpListCombined;
                    for (int i = 0; i < lvup.Length; i++)
                    {
                        if (lvup[i].Length >= 2 && i < exps.Length && lvup[i][0] + exps[i] >= lvup[i][1])
                        {
                            var ship      = FirstBattle.Initial.FriendFleetEscort.MembersInstance[i];
                            int increment = Math.Max(lvup[i].Length - 2, 1);

                            Utility.Logger.Add(2, ship.Name, string.Format(" 的等级达到了 Lv. {0} 。", ship.Level + increment));
                        }
                    }
                }
            }



            //ドロップ艦記録
            if (!IsPractice && !IsBaseAirRaid)
            {
                //checkme: とてもアレな感じ

                int  shipID  = Result.DroppedShipID;
                int  itemID  = Result.DroppedItemID;
                int  eqID    = Result.DroppedEquipmentID;
                bool showLog = Utility.Configuration.Config.Log.ShowSpoiler;

                if (itemID != -1)
                {
                    if (!DroppedItemCount.ContainsKey(itemID))
                    {
                        DroppedItemCount.Add(itemID, 0);
                    }
                    DroppedItemCount[itemID]++;

                    if (showLog && shipID == -1)
                    {
                        var item       = KCDatabase.Instance.UseItems[itemID];
                        var itemmaster = KCDatabase.Instance.MasterUseItems[itemID];
                        Utility.Logger.Add(2, "", "获得了", string.Format("「{0}」。", itemmaster?.Name ?? ("不明なアイテム - ID:" + itemID)), string.Format("( 合计 : {0} 个 )", (item?.Count ?? 0) + DroppedItemCount[itemID]));
                    }
                }

                if (shipID != -1)
                {
                    ShipDataMaster ship = KCDatabase.Instance.MasterShips[shipID];
                    DroppedShipCount++;

                    var defaultSlot = ship.DefaultSlot;
                    if (defaultSlot != null)
                    {
                        DroppedEquipmentCount += defaultSlot.Count(id => id != -1);
                    }

                    if (showLog)
                    {
                        if (itemID != -1)
                        {
                            var item       = KCDatabase.Instance.UseItems[itemID];
                            var itemmaster = KCDatabase.Instance.MasterUseItems[itemID];
                            Utility.Logger.Add(2, string.Format("{0}「{1}」", ship.ShipTypeName, ship.NameWithClass), "加入了队伍。获得了", string.Format("「{0}」。", itemmaster?.Name ?? ("不明なアイテム - ID:" + itemID)), string.Format("( 合计 : {0} 个 )", (item?.Count ?? 0) + DroppedItemCount[itemID]));
                        }
                        else
                        {
                            Utility.Logger.Add(2, string.Format("{0}「{1}」", ship.ShipTypeName, ship.NameWithClass), "加入了队伍。");
                        }
                    }
                }

                if (eqID != -1)
                {
                    EquipmentDataMaster eq = KCDatabase.Instance.MasterEquipments[eqID];
                    DroppedEquipmentCount++;

                    if (showLog)
                    {
                        Utility.Logger.Add(2, "", "获得了 ", string.Format("{0}「{1}」。", eq.CategoryTypeInstance.Name, eq.Name));
                    }
                }


                // 満員判定
                if (shipID == -1 && (
                        KCDatabase.Instance.Admiral.MaxShipCount - (KCDatabase.Instance.Ships.Count + DroppedShipCount) <= 0 ||
                        KCDatabase.Instance.Admiral.MaxEquipmentCount - (KCDatabase.Instance.Equipments.Count + DroppedEquipmentCount) <= 0))
                {
                    shipID = -2;
                }

                RecordManager.Instance.ShipDrop.Add(shipID, itemID, eqID, Compass.MapAreaID, Compass.MapInfoID, Compass.Destination, Compass.MapInfo.EventDifficulty, Compass.EventID == 5, enemyFleetData.FleetID, Result.Rank, KCDatabase.Instance.Admiral.Level);
            }



            WriteBattleLog();



            /*//DEBUG
             * if (!IsBaseAirRaid && Utility.Configuration.Config.Log.LogLevel <= 1)
             * {
             *      var battle = SecondBattle ?? FirstBattle;
             *
             *      for (int i = 0; i < battle.Initial.EnemyMaxHPs.Length; i++)
             *      {
             *              if (battle.Initial.EnemyMaxHPs[i] > 0 && battle.ResultHPs[BattleIndex.Get(BattleSides.EnemyMain, i)] == 0)
             *                      Utility.Logger.Add(1, "justkill #" + (i + 1));
             *      }
             *
             * int rank = PredictWinRank(out var friend, out var enemy);
             *
             *      // SS -> S
             *      if (Constants.GetWinRank(rank).Substring(0, 1) != Result.Rank)
             *      {
             *              Utility.Logger.Add(1, $"勝利ランク予測が誤っています。予想 {Constants.GetWinRank(rank)} -> 実際 {Result.Rank}");
             *      }
             * }
             * //*/
        }
Beispiel #26
0
        /// <summary>
        /// 戦闘終了時に各種データの収集を行います。
        /// </summary>
        private void BattleFinished()
        {
            //敵編成記録
            EnemyFleetRecord.EnemyFleetElement enemyFleetData = EnemyFleetRecord.EnemyFleetElement.CreateFromCurrentState();

            if (enemyFleetData != null)
            {
                RecordManager.Instance.EnemyFleet.Update(enemyFleetData);
            }



            //ドロップ艦記録
            if ((BattleMode & BattleModes.BattlePhaseMask) != BattleModes.Practice)
            {
                //checkme: とてもアレな感じ

                int  shipID  = Result.DroppedShipID;
                int  itemID  = Result.DroppedItemID;
                int  eqID    = Result.DroppedEquipmentID;
                bool showLog = Utility.Configuration.Config.Log.ShowSpoiler;

                if (shipID != -1)
                {
                    ShipDataMaster ship = KCDatabase.Instance.MasterShips[shipID];
                    DroppedShipCount++;

                    var defaultSlot = ship.DefaultSlot;
                    if (defaultSlot != null)
                    {
                        DroppedEquipmentCount += defaultSlot.Count(id => id != -1);
                    }

                    if (showLog)
                    {
                        Utility.Logger.Add(2, string.Format("{0}「{1}」が戦列に加わりました。", ship.ShipTypeName, ship.NameWithClass));
                    }
                }

                if (itemID != -1)
                {
                    if (showLog)
                    {
                        Utility.Logger.Add(2, string.Format("アイテム「{0}」を入手しました。", KCDatabase.Instance.MasterUseItems[itemID].Name));
                    }
                }

                if (eqID != -1)
                {
                    EquipmentDataMaster eq = KCDatabase.Instance.MasterEquipments[eqID];
                    DroppedEquipmentCount++;

                    if (showLog)
                    {
                        Utility.Logger.Add(2, string.Format("{0}「{1}」を入手しました。", eq.CategoryTypeInstance.Name, eq.Name));
                    }
                }


                // 満員判定
                if (shipID == -1 && (
                        KCDatabase.Instance.Admiral.MaxShipCount - (KCDatabase.Instance.Ships.Count + DroppedShipCount) <= 0 ||
                        KCDatabase.Instance.Admiral.MaxEquipmentCount - (KCDatabase.Instance.Equipments.Count + DroppedEquipmentCount) <= 0))
                {
                    shipID = -2;
                }

                RecordManager.Instance.ShipDrop.Add(shipID, itemID, eqID, Compass.MapAreaID, Compass.MapInfoID, Compass.Destination, Compass.MapInfo.EventDifficulty, Compass.EventID == 5, enemyFleetData.FleetID, Result.Rank, KCDatabase.Instance.Admiral.Level);
            }
        }
        private string GetAlbumInfo(dynamic data)
        {
            StringBuilder sb = new StringBuilder();

            if (data != null && data.api_list() && data.api_list != null)
            {
                if (data.api_list[0].api_yomi())
                {
                    //艦娘図鑑
                    const int bound      = 70;                      // 図鑑1ページあたりの艦船数
                    int       startIndex = (((int)data.api_list[0].api_index_no - 1) / bound) * bound + 1;
                    bool[]    flags      = Enumerable.Repeat <bool>(false, bound).ToArray();

                    sb.AppendLine("[中破絵未回収]");

                    foreach (dynamic elem in data.api_list)
                    {
                        flags[(int)elem.api_index_no - startIndex] = true;

                        dynamic[] state = elem.api_state;
                        for (int i = 0; i < state.Length; i++)
                        {
                            if ((int)state[i][1] == 0)
                            {
                                var target = KCDatabase.Instance.MasterShips[(int)elem.api_table_id[i]];
                                if (target != null)                                     //季節の衣替え艦娘の場合存在しないことがある
                                {
                                    sb.AppendLine(target.Name);
                                }
                            }
                        }
                    }

                    sb.AppendLine("[未保有艦]");
                    for (int i = 0; i < bound; i++)
                    {
                        if (!flags[i])
                        {
                            ShipDataMaster ship = KCDatabase.Instance.MasterShips.Values.FirstOrDefault(s => s.AlbumNo == startIndex + i);
                            if (ship != null)
                            {
                                sb.AppendLine(ship.Name);
                            }
                        }
                    }
                }
                else
                {
                    //装備図鑑
                    const int bound      = 70;                      // 図鑑1ページあたりの装備数
                    int       startIndex = (((int)data.api_list[0].api_index_no - 1) / bound) * bound + 1;
                    bool[]    flags      = Enumerable.Repeat <bool>(false, bound).ToArray();

                    foreach (dynamic elem in data.api_list)
                    {
                        flags[(int)elem.api_index_no - startIndex] = true;
                    }

                    sb.AppendLine("[未保有装備]");
                    for (int i = 0; i < bound; i++)
                    {
                        if (!flags[i])
                        {
                            EquipmentDataMaster eq = KCDatabase.Instance.MasterEquipments.Values.FirstOrDefault(s => s.AlbumNo == startIndex + i);
                            if (eq != null)
                            {
                                sb.AppendLine(eq.Name);
                            }
                        }
                    }
                }
            }

            return(sb.ToString());
        }
        /// <summary>
        /// 対空カットイン種別を取得します。
        /// </summary>
        public static int GetAACutinKind(int shipID, int[] slot)
        {
            int highangle          = 0;
            int highangle_director = 0;
            int director           = 0;
            int radar              = 0;
            int aaradar            = 0;
            int maingunl           = 0;
            int aashell            = 0;
            int aagun              = 0;
            int aagun_concentrated = 0;


            foreach (int eid in slot)
            {
                EquipmentDataMaster eq = KCDatabase.Instance.MasterEquipments[eid];
                if (eq == null)
                {
                    continue;
                }

                if (eq.IconType == 16)                          //高角砲
                // 10cm連装高角砲+高射装置 or 12.7cm高角砲+高射装置 or 90mm単装高角砲 or 5inch連装砲 Mk.28 mod.2
                {
                    if (eq.EquipmentID == 122 || eq.EquipmentID == 130 || eq.EquipmentID == 135 || eq.EquipmentID == 172)
                    {
                        highangle_director++;
                    }
                    highangle++;
                }
                else if (eq.CategoryType == 36)                         //高射装置
                {
                    director++;
                }
                else if (eq.CardType == 8)                              //電探
                {
                    if (eq.AA > 0)
                    {
                        aaradar++;
                    }
                    radar++;
                }
                else if (eq.CategoryType == 3)                          //大口径主砲
                {
                    maingunl++;
                }
                else if (eq.CategoryType == 18)                         //対空強化弾
                {
                    aashell++;
                }
                else if (eq.CategoryType == 21)                         //対空機銃
                // 25mm三連装機銃 集中配備 or Bofors 40mm四連装機関砲 or QF 2ポンド8連装ポンポン砲
                {
                    if (eq.EquipmentID == 131 || eq.EquipmentID == 173 || eq.EquipmentID == 191)
                    {
                        aagun_concentrated++;
                    }
                    aagun++;
                }
            }


            // 固有カットイン
            switch (shipID)
            {
            case 421:                           //秋月
            case 330:                           //秋月改
            case 422:                           //照月
            case 346:                           //照月改
            case 423:                           //初月
            case 357:                           //初月改
                if (highangle >= 2 && radar >= 1)
                {
                    return(1);
                }
                if (highangle >= 1 && radar >= 1)
                {
                    return(2);
                }
                if (highangle >= 2)
                {
                    return(3);
                }
                break;

            case 428:                           //摩耶改二
                if (highangle >= 1 && aagun_concentrated >= 1)
                {
                    if (aaradar >= 1)
                    {
                        return(10);
                    }

                    return(11);
                }
                break;

            case 141:                           //五十鈴改二
                if (highangle >= 1 && aagun >= 1)
                {
                    if (aaradar >= 1)
                    {
                        return(14);
                    }
                    else
                    {
                        return(15);
                    }
                }
                break;

            case 470:                           //霞改二乙
                if (highangle >= 1 && aagun >= 1)
                {
                    if (aaradar >= 1)
                    {
                        return(16);
                    }
                    else
                    {
                        return(17);
                    }
                }
                break;

            case 418:                           //皐月改二
                if (aagun_concentrated >= 1)
                {
                    return(18);
                }
                break;
            }



            if (maingunl >= 1 && aashell >= 1 && director >= 1 && aaradar >= 1)
            {
                return(4);
            }
            if (highangle_director >= 2 && aaradar >= 1)
            {
                return(5);
            }
            if (maingunl >= 1 && aashell >= 1 && director >= 1)
            {
                return(6);
            }
            if (highangle >= 1 && director >= 1 && aaradar >= 1)
            {
                return(7);
            }
            if (highangle_director >= 1 && aaradar >= 1)
            {
                return(8);
            }
            if (highangle >= 1 && director >= 1)
            {
                return(9);
            }

            if (aagun_concentrated >= 1 && aagun >= 2 && aaradar >= 1)                  //注: 機銃2なのは集中機銃がダブるため
            {
                return(12);
            }

            return(0);
        }
Beispiel #29
0
        /// <summary>
        /// 戦闘終了時に各種データの収集を行います。
        /// </summary>
        private void BattleFinished()
        {
            //敵編成記録
            EnemyFleetRecord.EnemyFleetElement enemyFleetData = EnemyFleetRecord.EnemyFleetElement.CreateFromCurrentState();

            if (enemyFleetData != null)
            {
                RecordManager.Instance.EnemyFleet.Update(enemyFleetData);
            }


            // ロギング
            if (IsPractice)
            {
                Utility.Logger.Add(2,
                                   string.Format("演習 で「{0}」{1}の「{2}」と交戦しました。( ランク: {3}, 提督Exp+{4}, 艦娘Exp+{5} )",
                                                 EnemyAdmiralName, EnemyAdmiralRank, Result.EnemyFleetName, Result.Rank, Result.AdmiralExp, Result.BaseExp));
            }
            else
            {
                Utility.Logger.Add(2,
                                   string.Format("{0}-{1}-{2} で「{3}」と交戦しました。( ランク: {4}, 提督Exp+{5}, 艦娘Exp+{6} )",
                                                 Compass.MapAreaID, Compass.MapInfoID, Compass.Destination, Result.EnemyFleetName, Result.Rank, Result.AdmiralExp, Result.BaseExp));
            }



            //ドロップ艦記録
            if (!IsPractice)
            {
                //checkme: とてもアレな感じ

                int  shipID  = Result.DroppedShipID;
                int  itemID  = Result.DroppedItemID;
                int  eqID    = Result.DroppedEquipmentID;
                bool showLog = Utility.Configuration.Config.Log.ShowSpoiler;

                if (shipID != -1)
                {
                    ShipDataMaster ship = KCDatabase.Instance.MasterShips[shipID];
                    DroppedShipCount++;

                    var defaultSlot = ship.DefaultSlot;
                    if (defaultSlot != null)
                    {
                        DroppedEquipmentCount += defaultSlot.Count(id => id != -1);
                    }

                    if (showLog)
                    {
                        Utility.Logger.Add(2, string.Format("{0}「{1}」が戦列に加わりました。", ship.ShipTypeName, ship.NameWithClass));
                    }
                }

                if (itemID != -1)
                {
                    if (!DroppedItemCount.ContainsKey(itemID))
                    {
                        DroppedItemCount.Add(itemID, 0);
                    }
                    DroppedItemCount[itemID]++;

                    if (showLog)
                    {
                        var item       = KCDatabase.Instance.UseItems[itemID];
                        var itemmaster = KCDatabase.Instance.MasterUseItems[itemID];
                        Utility.Logger.Add(2, string.Format("アイテム「{0}」を入手しました。( 合計: {1}個 )", itemmaster != null ? itemmaster.Name : ("不明なアイテム - ID:" + itemID), (item != null ? item.Count : 0) + DroppedItemCount[itemID]));
                    }
                }

                if (eqID != -1)
                {
                    EquipmentDataMaster eq = KCDatabase.Instance.MasterEquipments[eqID];
                    DroppedEquipmentCount++;

                    if (showLog)
                    {
                        Utility.Logger.Add(2, string.Format("{0}「{1}」を入手しました。", eq.CategoryTypeInstance.Name, eq.Name));
                    }
                }


                // 満員判定
                if (shipID == -1 && (
                        KCDatabase.Instance.Admiral.MaxShipCount - (KCDatabase.Instance.Ships.Count + DroppedShipCount) <= 0 ||
                        KCDatabase.Instance.Admiral.MaxEquipmentCount - (KCDatabase.Instance.Equipments.Count + DroppedEquipmentCount) <= 0))
                {
                    shipID = -2;
                }

                RecordManager.Instance.ShipDrop.Add(shipID, itemID, eqID, Compass.MapAreaID, Compass.MapInfoID, Compass.Destination, Compass.MapInfo.EventDifficulty, Compass.EventID == 5, enemyFleetData.FleetID, Result.Rank, KCDatabase.Instance.Admiral.Level);
            }


            //DEBUG

            /*/
             * if ( Utility.Configuration.Config.Log.LogLevel <= 1 && Utility.Configuration.Config.Connection.SaveReceivedData ) {
             *      IEnumerable<int> damages;
             *      switch ( BattleMode & BattleModes.BattlePhaseMask ) {
             *              case BattleModes.Normal:
             *              case BattleModes.AirBattle:
             *              case BattleModes.Practice:
             *              default:
             *                      damages = ( (BattleData)BattleNight ?? BattleDay ).AttackDamages;
             *                      break;
             *              case BattleModes.NightOnly:
             *              case BattleModes.NightDay:
             *                      damages = ( (BattleData)BattleDay ?? BattleNight ).AttackDamages;
             *                      break;
             *      }
             *
             *      damages = damages.Take( 6 ).Where( i => i > 0 );
             *
             *      if ( damages.Count( i => i == damages.Max() ) > 1 ) {
             *              Utility.Logger.Add( 1, "MVP候補が複数存在します。ログを確認してください。" );
             *      }
             * }
             * //*/
        }
        private void UpdateAlbumPage(int equipmentID)
        {
            KCDatabase          db = KCDatabase.Instance;
            EquipmentDataMaster eq = db.MasterEquipments[equipmentID];

            if (eq == null)
            {
                return;
            }


            BasePanelEquipment.SuspendLayout();


            //header
            EquipmentID.Tag  = equipmentID;
            EquipmentID.Text = eq.EquipmentID.ToString();
            ToolTipInfo.SetToolTip(EquipmentID, string.Format("Type: [ {0} ]", string.Join(", ", eq.EquipmentType)));
            AlbumNo.Text = eq.AlbumNo.ToString();


            TableEquipmentName.SuspendLayout();

            EquipmentType.Text = eq.CategoryTypeInstance.Name;

            {
                int eqicon = eq.IconType;
                if (eqicon >= (int)ResourceManager.EquipmentContent.Locked)
                {
                    eqicon = (int)ResourceManager.EquipmentContent.Unknown;
                }
                EquipmentType.ImageIndex = eqicon;

                ToolTipInfo.SetToolTip(EquipmentType, GetEquippableShips(equipmentID));
            }
            EquipmentName.Text = eq.Name;
            ToolTipInfo.SetToolTip(EquipmentName, "(右クリックでコピー)");

            TableEquipmentName.ResumeLayout();


            //main parameter
            TableParameterMain.SuspendLayout();

            SetParameterText(Firepower, eq.Firepower);
            SetParameterText(Torpedo, eq.Torpedo);
            SetParameterText(AA, eq.AA);
            SetParameterText(Armor, eq.Armor);
            SetParameterText(ASW, eq.ASW);
            SetParameterText(Evasion, eq.Evasion);
            SetParameterText(LOS, eq.LOS);
            SetParameterText(Accuracy, eq.Accuracy);
            SetParameterText(Bomber, eq.Bomber);

            if (eq.CategoryType == EquipmentTypes.Interceptor)
            {
                TitleAccuracy.Text       = "対爆";
                TitleAccuracy.ImageIndex = (int)ResourceManager.IconContent.ParameterAntiBomber;
                TitleEvasion.Text        = "迎撃";
                TitleEvasion.ImageIndex  = (int)ResourceManager.IconContent.ParameterInterception;
            }
            else
            {
                TitleAccuracy.Text       = "命中";
                TitleAccuracy.ImageIndex = (int)ResourceManager.IconContent.ParameterAccuracy;
                TitleEvasion.Text        = "回避";
                TitleEvasion.ImageIndex  = (int)ResourceManager.IconContent.ParameterEvasion;
            }

            TableParameterMain.ResumeLayout();


            //sub parameter
            TableParameterSub.SuspendLayout();

            Speed.Text        = "なし";      //Constants.GetSpeed( eq.Speed );
            Range.Text        = Constants.GetRange(eq.Range);
            Rarity.Text       = Constants.GetEquipmentRarity(eq.Rarity);
            Rarity.ImageIndex = (int)ResourceManager.IconContent.RarityRed + Constants.GetEquipmentRarityID(eq.Rarity);                 //checkme

            TableParameterSub.ResumeLayout();


            // aircraft
            if (eq.IsAircraft)
            {
                TableAircraft.SuspendLayout();
                AircraftCost.Text = eq.AircraftCost.ToString();
                ToolTipInfo.SetToolTip(AircraftCost, "配備時のボーキ消費:" + ((eq.IsCombatAircraft ? 18 : 4) * eq.AircraftCost));
                AircraftDistance.Text = eq.AircraftDistance.ToString();
                TableAircraft.ResumeLayout();
                TableAircraft.Visible = true;
            }
            else
            {
                TableAircraft.Visible = false;
            }


            //default equipment
            DefaultSlots.BeginUpdate();
            DefaultSlots.Items.Clear();
            foreach (var ship in KCDatabase.Instance.MasterShips.Values)
            {
                if (ship.DefaultSlot != null && ship.DefaultSlot.Contains(equipmentID))
                {
                    DefaultSlots.Items.Add(ship);
                }
            }
            DefaultSlots.EndUpdate();


            Description.Text = eq.Message;


            //arsenal
            TableArsenal.SuspendLayout();

            MaterialFuel.Text    = eq.Material[0].ToString();
            MaterialAmmo.Text    = eq.Material[1].ToString();
            MaterialSteel.Text   = eq.Material[2].ToString();
            MaterialBauxite.Text = eq.Material[3].ToString();

            TableArsenal.ResumeLayout();



            //装備画像を読み込んでみる
            {
                var img =
                    KCResourceHelper.LoadEquipmentImage(equipmentID, KCResourceHelper.ResourceTypeEquipmentCard) ??
                    KCResourceHelper.LoadEquipmentImage(equipmentID, KCResourceHelper.ResourceTypeEquipmentCardSmall);

                if (img != null)
                {
                    EquipmentImage.Image?.Dispose();
                    EquipmentImage.Image = img;
                }
                else
                {
                    EquipmentImage.Image?.Dispose();
                    EquipmentImage.Image = null;
                }
            }


            BasePanelEquipment.ResumeLayout();
            BasePanelEquipment.Visible = true;


            this.Text = "装備図鑑 - " + eq.Name;
        }