Exemplo n.º 1
0
        /// <summary>
        /// 戦闘詳細の情報を出力します。
        /// </summary>
        public override string ToString()
        {
            StringBuilder builder = new StringBuilder();

            builder.AppendFormat("{0} → {1}\r\n", GetAttackerName(), GetDefenderName());


            if (AttackType >= 0)
            {
                builder.Append("[").Append(GetAttackKind()).Append("] ");
            }

            for (int i = 0; i < Damages.Length; i++)
            {
                if (CriticalTypes[i] == CriticalType.Invalid)                   // カットイン(主砲/主砲)、カットイン(主砲/副砲)時に発生する
                {
                    continue;
                }

                if (i > 0)
                {
                    builder.Append(" , ");
                }

                switch (CriticalTypes[i])
                {
                case CriticalType.Miss:
                    builder.Append("Miss");
                    break;

                case CriticalType.Hit:
                    builder.Append(Damages[i]).Append(" Dmg");
                    break;

                case CriticalType.Critical:
                    builder.Append(Damages[i]).Append(" Critical!");
                    break;
                }
            }

            {
                int before = Math.Max(DefenderHP, 0);
                int after  = Math.Max(DefenderHP - Damages.Sum(), 0);
                if (before != after)
                {
                    builder.AppendFormat(" ( {0} → {1} )", before, after);
                }
            }


            builder.AppendLine();
            return(builder.ToString());
        }
        /// <summary>
        /// 航空戦での与ダメージを推測します。
        /// </summary>
        /// <param name="damages">与ダメージリスト。</param>
        private void CalculateAttackDamage(int[] damages)
        {
            // 敵はめんどくさすぎるので省略
            // 仮想火力を求め、それに従って合計ダメージを分配

            var firepower = new int[6];
            var members   = _battleData.Initial.FriendFleet.MembersWithoutEscaped;

            for (int i = 0; i < members.Count; i++)
            {
                var ship = members[i];
                if (ship == null)
                {
                    continue;
                }

                var slots     = ship.SlotInstanceMaster;
                var aircrafts = ship.Aircraft;
                for (int s = 0; s < slots.Count; s++)
                {
                    if (slots[s] == null)
                    {
                        continue;
                    }

                    switch (slots[s].CategoryType)
                    {
                    case 7:                                     //艦上爆撃機
                    case 11:                                    //水上爆撃機
                        firepower[i] += (int)(1.0 * (slots[s].Bomber * Math.Sqrt(aircrafts[s]) + 25));
                        break;

                    case 8:                                     //艦上攻撃機 (80%と150%はランダムのため係数は平均値)
                        firepower[i] += (int)(1.15 * (slots[s].Torpedo * Math.Sqrt(aircrafts[s]) + 25));
                        break;
                    }
                }
            }

            int totalFirepower = firepower.Sum();
            int totalDamage    = Damages.Sum();

            for (int i = 0; i < 6; i++)
            {
                damages[i] += (int)((double)totalDamage * firepower[i] / Math.Max(totalFirepower, 1));
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 戦闘詳細の情報を出力します。
        /// </summary>
        public override string ToString()
        {
            StringBuilder builder = new StringBuilder();


            if (Battle.IsPractice)
            {
                builder.AppendFormat("{0}{1} → {2}{3}",
                                     Attacker == null ? "" : AttackerIndex.IsFriend ? "自軍 " : "敵軍 ", GetAttackerName(),
                                     DefenderIndex.IsFriend ? "自軍 " : "敵軍 ", GetDefenderName()
                                     ).AppendLine();
            }
            else
            {
                builder.AppendFormat("{0} → {1}", GetAttackerName(), GetDefenderName()).AppendLine();
            }


            if (AttackType >= 0)
            {
                builder.Append("[").Append(GetAttackKind()).Append("] ");
            }

            /*//
             * if ( EquipmentIDs != null ) {
             *      var eqs = EquipmentIDs.Select( id => KCDatabase.Instance.MasterEquipments[id] ).Where( eq => eq != null ).Select( eq => eq.Name );
             *      if ( eqs.Any() )
             *              builder.Append( "(" ).Append( string.Join( ", ", eqs ) ).Append( ") " );
             * }
             * //*/

            for (int i = 0; i < Damages.Length; i++)
            {
                if (CriticalTypes[i] == CriticalType.Invalid)                   // カットイン(主砲/主砲)、カットイン(主砲/副砲)時に発生する
                {
                    continue;
                }

                if (i > 0)
                {
                    builder.Append(" , ");
                }

                if (GuardsFlagship[i])
                {
                    builder.Append("<かばう> ");
                }

                switch (CriticalTypes[i])
                {
                case CriticalType.Miss:
                    builder.Append("Miss");
                    break;

                case CriticalType.Hit:
                    builder.Append(Damages[i]).Append(" Dmg");
                    break;

                case CriticalType.Critical:
                    builder.Append(Damages[i]).Append(" Critical!");
                    break;
                }
            }


            int beforeHP = Math.Max(DefenderHP, 0);
            int afterHP  = Math.Max(DefenderHP - Damages.Sum(), 0);

            if (beforeHP != afterHP)
            {
                builder.AppendFormat(" ( {0} → {1} )", beforeHP, afterHP);
            }



            builder.AppendLine();


            // damage control
            if (beforeHP > 0 && afterHP <= 0 && DefenderIndex.IsFriend && !Battle.IsPractice && !Battle.IsBaseAirRaid)
            {
                // 友軍艦隊時は常に beforeHP == 0 になるので、ここには来ないはず
                // 暫定対策でしかないのでできればまともにしたい

                var defender = (DefenderIndex.Side == BattleSides.FriendEscort ? Battle.Initial.FriendFleetEscort : Battle.Initial.FriendFleet)
                               ?.MembersInstance?.ElementAtOrDefault(DefenderIndex.Index);
                if (defender != null)
                {
                    int id = defender.DamageControlID;

                    if (id == 42)
                    {
                        builder.AppendFormat(" 応急修理要員発動 HP{0}", (int)(defender.HPMax * 0.2)).AppendLine();
                    }

                    else if (id == 43)
                    {
                        builder.AppendFormat(" 応急修理女神発動 HP{0}", defender.HPMax).AppendLine();
                    }
                }
            }
            return(builder.ToString());
        }
Exemplo n.º 4
0
        /// <summary>
        /// 戦闘詳細の情報を出力します。
        /// </summary>
        public override string ToString()
        {
            StringBuilder builder = new StringBuilder();

            builder.AppendFormat("{0} → {1}\r\n", GetAttackerName(), GetDefenderName());


            if (AttackType >= 0)
            {
                builder.Append("[").Append(GetAttackKind()).Append("] ");
            }

            /*//
             * if ( EquipmentIDs != null ) {
             *      var eqs = EquipmentIDs.Select( id => KCDatabase.Instance.MasterEquipments[id] ).Where( eq => eq != null ).Select( eq => eq.Name );
             *      if ( eqs.Any() )
             *              builder.Append( "(" ).Append( string.Join( ", ", eqs ) ).Append( ") " );
             * }
             * //*/

            for (int i = 0; i < Damages.Length; i++)
            {
                if (CriticalTypes[i] == CriticalType.Invalid)                   // カットイン(主砲/主砲)、カットイン(主砲/副砲)時に発生する
                {
                    continue;
                }

                if (i > 0)
                {
                    builder.Append(" , ");
                }

                if (GuardsFlagship[i])
                {
                    builder.Append("<かばう> ");
                }

                switch (CriticalTypes[i])
                {
                case CriticalType.Miss:
                    builder.Append("Miss");
                    break;

                case CriticalType.Hit:
                    builder.Append(Damages[i]).Append(" Dmg");
                    break;

                case CriticalType.Critical:
                    builder.Append(Damages[i]).Append(" Critical!");
                    break;
                }
            }

            {
                int before = Math.Max(DefenderHP, 0);
                int after  = Math.Max(DefenderHP - Damages.Sum(), 0);
                if (before != after)
                {
                    builder.AppendFormat(" ( {0} → {1} )", before, after);
                }
            }


            builder.AppendLine();
            return(builder.ToString());
        }
Exemplo n.º 5
0
		/// <summary>
		/// 戦闘詳細の情報を出力します。
		/// </summary>
		public override string ToString()
		{

			StringBuilder builder = new StringBuilder();


			if (Battle.IsPractice)
				builder.AppendFormat("{0}{1} → {2}{3}",
					Attacker == null ? "" : AttackerIndex.IsFriend ? "Friendly " : "Enemy ", GetAttackerName(),
					DefenderIndex.IsFriend ? "Friendly " : "Enemy ", GetDefenderName()
					).AppendLine();
			else
				builder.AppendFormat("{0} → {1}", GetAttackerName(), GetDefenderName()).AppendLine();


			if (AttackType >= 0)
				builder.Append("[").Append(GetAttackKind()).Append("] ");

			/*//
			if ( EquipmentIDs != null ) {
				var eqs = EquipmentIDs.Select( id => KCDatabase.Instance.MasterEquipments[id] ).Where( eq => eq != null ).Select( eq => eq.Name );
				if ( eqs.Any() )
					builder.Append( "(" ).Append( string.Join( ", ", eqs ) ).Append( ") " );
			}
			//*/

			for (int i = 0; i < Damages.Length; i++)
			{
				if (CriticalTypes[i] == CriticalType.Invalid)   // カットイン(主砲/主砲)、カットイン(主砲/副砲)時に発生する
					continue;

				if (i > 0)
					builder.Append(" , ");

				if (GuardsFlagship[i])
					builder.Append("<Protected> ");

				switch (CriticalTypes[i])
				{
					case CriticalType.Miss:
						builder.Append("Miss");
						break;
					case CriticalType.Hit:
						builder.Append(Damages[i]).Append(" Dmg");
						break;
					case CriticalType.Critical:
						builder.Append(Damages[i]).Append(" Critical!");
						break;
				}

			}


			int beforeHP = Math.Max(DefenderHP, 0);
			int afterHP = Math.Max(DefenderHP - Damages.Sum(), 0);
			if (beforeHP != afterHP)
				builder.AppendFormat(" ( {0} → {1} )", beforeHP, afterHP);



			builder.AppendLine();


			// damage control
			if (beforeHP > 0 && afterHP <= 0 && DefenderIndex.IsFriend && !Battle.IsPractice && !Battle.IsBaseAirRaid)
			{				
				var defender = (DefenderIndex.Side == BattleSides.FriendEscort ? Battle.Initial.FriendFleetEscort : Battle.Initial.FriendFleet)
					?.MembersInstance?.ElementAtOrDefault(DefenderIndex.Index);
				if (defender != null)
				{
					int id = defender.DamageControlID;

					if (id == 42)
						builder.AppendFormat(" Emergency Repair Personnel activated. HP{0}", (int)(defender.HPMax * 0.2)).AppendLine();

					else if (id == 43)
						builder.AppendFormat(" Emergency Repair Goddess activated. HP{0}", defender.HPMax).AppendLine();

				}
			}
			return builder.ToString();
		}
        /// <summary>
        /// 戦闘詳細の情報を出力します。
        /// </summary>
        public override string ToString()
        {
            StringBuilder builder = new StringBuilder();

            // 航空戦・支援攻撃時 AttackerIndex = BattleIndex.Invalid 、それで AttackerIndex.Side = BattleSides.FriendMain になる
            // DefenderIndex.Side で判断すれば航空戦も正確に識別できるが表示が変になるので、最終的には AttackerIndex.Side で判断した
            builder.AppendFormat(AttackerIndex.IsFriend ? "{0} → {1}\r\n" : "{1} ← {0}\r\n", GetAttackerName(), GetDefenderName());


            if (AttackType >= 0)
            {
                builder.Append("[").Append(GetAttackKind()).Append("] ");
            }

            /*//
             * if ( EquipmentIDs != null ) {
             *      var eqs = EquipmentIDs.Select( id => KCDatabase.Instance.MasterEquipments[id] ).Where( eq => eq != null ).Select( eq => eq.Name );
             *      if ( eqs.Any() )
             *              builder.Append( "(" ).Append( string.Join( ", ", eqs ) ).Append( ") " );
             * }
             * //*/

            for (int i = 0; i < Damages.Length; i++)
            {
                if (CriticalTypes[i] == CriticalType.Invalid)                   // カットイン(主砲/主砲)、カットイン(主砲/副砲)時に発生する
                {
                    continue;
                }

                if (i > 0)
                {
                    builder.Append(" , ");
                }

                if (GuardsFlagship[i])
                {
                    builder.Append("<援护> ");
                }

                switch (CriticalTypes[i])
                {
                case CriticalType.Miss:
                    builder.Append("Miss");
                    break;

                case CriticalType.Hit:
                    builder.Append(Damages[i]).Append(" Dmg");
                    break;

                case CriticalType.Critical:
                    builder.Append(Damages[i]).Append(" Critical!");
                    break;
                }
            }


            int beforeHP = Math.Max(DefenderHP, 0);
            int afterHP  = Math.Max(DefenderHP - Damages.Sum(), 0);

            if (beforeHP != afterHP)
            {
                builder.AppendFormat(" ( {0} → {1} )", beforeHP, afterHP);
            }



            builder.AppendLine();


            // damage control
            if (afterHP <= 0 && DefenderIndex.IsFriend && !Battle.IsPractice && !Battle.IsBaseAirRaid)
            {
                var defender = (DefenderIndex.Side == BattleSides.FriendEscort ? Battle.Initial.FriendFleetEscort : Battle.Initial.FriendFleet).MembersInstance[DefenderIndex.Index];
                if (defender != null)
                {
                    int id = defender.DamageControlID;

                    if (id == 42)
                    {
                        builder.AppendFormat(" 应急修理要员发动 HP{0}", (int)(defender.HPMax * 0.2)).AppendLine();
                    }

                    else if (id == 43)
                    {
                        builder.AppendFormat(" 应急修理女神发动 HP{0}", defender.HPMax).AppendLine();
                    }
                }
            }
            return(builder.ToString());
        }