예제 #1
0
        /// <summary>
        /// 일반 포격전, 개막뇌격, 개막 항공전등을 계산.
        /// </summary>
        /// <param name="battle"></param>
        /// <param name="Combined">연합함대인경우 True로 설정합니다.</param>
        /// <param name="IsWater">수뢰전대인지 채크합니다</param>
        /// <param name="IsPractice">연습전인지 채크합니다. 연습전인경우 True</param>
        private void Battle(bool IsWater, bool IsPractice, kcsapi_battle battle, bool Combined)
        {
            //this.Combined = IsCombined;
            this.PracticeStatus = IsPractice;

            this.IsCritical = false;
            List<int> CurrentHPList = new List<int>();
            List<listup> lists = new List<listup>();

            this.ResetEnemyInfo(battle);
            try
            {
                if (battle.api_support_flag != 0) Support(battle.api_support_flag, battle, lists);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
                KanColleClient.Current.CatchedErrorLogWriter.ReportException(ex.Source, ex);
            }
            List<listup> Combinelists = new List<listup>();
            //모든 형태의 전투에서 타게팅이 되는 함선의 번호와 데미지를 순서대로 입력한다.
            //포격전 시작
            if (IsWater)
            {
                if (!Combined && battle.api_hougeki3 != null)
                    ObjectListmake(battle.api_hougeki3.api_df_list, battle.api_hougeki3.api_damage, lists);
                else if (Combined && battle.api_hougeki3 != null)//1차 포격전은 2함대만 맞을지도...?
                    ObjectListmake(battle.api_hougeki3.api_df_list, battle.api_hougeki3.api_damage, Combinelists);
                if (battle.api_hougeki1 != null)
                    ObjectListmake(battle.api_hougeki1.api_df_list, battle.api_hougeki1.api_damage, lists);
            }
            else
            {
                if (!Combined && battle.api_hougeki1 != null)
                    ObjectListmake(battle.api_hougeki1.api_df_list, battle.api_hougeki1.api_damage, lists);
                else if (Combined && battle.api_hougeki1 != null)//1차 포격전은 2함대만 맞을지도...?
                    ObjectListmake(battle.api_hougeki1.api_df_list, battle.api_hougeki1.api_damage, Combinelists);
                if (battle.api_hougeki3 != null)
                    ObjectListmake(battle.api_hougeki3.api_df_list, battle.api_hougeki3.api_damage, lists);
            }
            if (battle.api_hougeki2 != null)
                ObjectListmake(battle.api_hougeki2.api_df_list, battle.api_hougeki2.api_damage, lists);

            //포격전 끝

            //뇌격전 시작
            if (battle.api_raigeki != null)
            {
                int[] numlist = battle.api_raigeki.api_erai;
                decimal[] damlist = battle.api_raigeki.api_eydam;
                if (!Combined)
                    DecimalListmake(numlist, damlist, lists, true);
                else
                    DecimalListmake(numlist, damlist, Combinelists, true);

                //적 뇌격 데미지
                numlist = battle.api_raigeki.api_frai;
                damlist = battle.api_raigeki.api_fydam;
                if (!Combined)
                    DecimalListmake(numlist, damlist, lists, false);
                else
                    DecimalListmake(numlist, damlist, Combinelists, false);
            }
            //뇌격전 끝

            //항공전 시작. 폭장과 뇌격 데미지는 합산되어있고 플래그로 맞는 녀석을 선별. ChangeKoukuFlagToNumber에 모든 플래그를 집어넣어서 합산시킴.
            if (battle.api_kouku != null && battle.api_kouku.api_stage3 != null)
            {
                int[] numlist = new int[7];
                decimal[] damlist = battle.api_kouku.api_stage3.api_fdam;

                ChangeKoukuFlagToNumber(battle.api_kouku.api_stage3.api_frai_flag,
                    battle.api_kouku.api_stage3.api_fbak_flag,
                    numlist);
                DecimalListmake(numlist, damlist, lists, true);

                //적군 데미지
                numlist = new int[7];
                damlist = battle.api_kouku.api_stage3.api_edam;
                ChangeKoukuFlagToNumber(
                    battle.api_kouku.api_stage3.api_erai_flag,
                    battle.api_kouku.api_stage3.api_ebak_flag,
                    numlist);
                DecimalListmake(numlist, damlist, lists, false);

                if (Combined)
                {
                    if (battle.api_kouku.api_stage3_combined != null)
                    {
                        numlist = new int[7];

                        damlist = battle.api_kouku.api_stage3_combined.api_fdam;
                        ChangeKoukuFlagToNumber(battle.api_kouku.api_stage3_combined.api_frai_flag,
                            battle.api_kouku.api_stage3_combined.api_fbak_flag,
                            numlist);
                        DecimalListmake(numlist, damlist, Combinelists, true);

                        //적군피해
                        numlist = new int[7];
                        if (battle.api_kouku.api_stage3_combined.api_edam != null)
                        {
                            try
                            {
                                damlist = battle.api_kouku.api_stage3_combined.api_edam;
                                ChangeKoukuFlagToNumber(battle.api_kouku.api_stage3_combined.api_erai_flag,
                                    battle.api_kouku.api_stage3_combined.api_ebak_flag,
                                    numlist);
                                DecimalListmake(numlist, damlist, Combinelists, false);
                            }
                            catch (Exception e)
                            {
                                Debug.WriteLine(e);
                                KanColleClient.Current.CatchedErrorLogWriter.ReportException(e.Source, e);
                            }
                        }
                    }//연합함대 리스트 작성 끝
                }
            }
            //항공전 끝

            //개막전 시작
            if (battle.api_opening_atack != null)
            {
                int[] numlist = battle.api_opening_atack.api_erai;
                decimal[] damlist = battle.api_opening_atack.api_eydam;
                DecimalListmake(numlist, damlist, lists, true);

                //적 데미지 계산
                numlist = battle.api_opening_atack.api_frai;
                damlist = battle.api_opening_atack.api_fydam;
                DecimalListmake(numlist, damlist, lists, false);
            }
            //개막전 끝
            if (!Combined) BattleCalc(lists, CurrentHPList, battle.api_maxhps, battle.api_nowhps, false, false, IsPractice, Combined);

            else if (Combined)//연합함대인경우 연산을 한번 더 시행
            {
                try
                {
                    BattleCalc(lists, CurrentHPList, battle.api_maxhps, battle.api_nowhps, false, false, IsPractice, Combined);

                    //적 HP계산을 위해 아군리스트와 적군 리스트를 병합.
                    int[] CombinePlusEnemyMaxHPs = new int[13];
                    int[] CombinePlusEnemyNowHPs = new int[13];
                    //최대 HP병합
                    for (int i = 0; i < battle.api_maxhps_combined.Length; i++)
                    {
                        CombinePlusEnemyMaxHPs[i] = battle.api_maxhps_combined[i];
                    }
                    for (int i = 7; i < battle.api_maxhps.Length; i++)
                    {
                        CombinePlusEnemyMaxHPs[i] = battle.api_maxhps[i];
                    }

                    //현재 HP병합
                    for (int i = 0; i < battle.api_nowhps_combined.Length; i++)
                    {
                        CombinePlusEnemyNowHPs[i] = battle.api_nowhps_combined[i];
                    }
                    for (int i = 7; i < battle.api_nowhps.Length; i++)
                    {
                        CombinePlusEnemyNowHPs[i] = CurrentHPList[i];
                    }
                    //재활용 위해 초기화.
                    CurrentHPList = new List<int>();

                    BattleCalc(Combinelists, CurrentHPList, CombinePlusEnemyMaxHPs, CombinePlusEnemyNowHPs, true, false, IsPractice, Combined);
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e);
                    KanColleClient.Current.CatchedErrorLogWriter.ReportException(e.Source, e);
                }

            }
            if (EnableBattlePreview)
            {
                this.PreviewCriticalCondition();
                this.IsBattleCalculated = true;
            }
        }
예제 #2
0
        /// <summary>
        /// 지원함대 데미지를 계산합니다.
        /// </summary>
        /// <param name="SupportFlag">지원함대 플래그를 입력합니다. 0:지원x 1:항공	2:포격	3:뇌격</param>
        /// <param name="battle"></param>
        /// <param name="lists"></param>
        private void Support(int SupportFlag, kcsapi_battle battle, List<listup> lists)
        {
            if (battle.api_support_flag == 0) return;
            if (battle.api_support_flag == 1)//항공지원
            {
                decimal[] Damage;

                if (battle.api_support_info.api_support_airatack == null) return;

                Damage = battle.api_support_info.api_support_airatack.api_stage3.api_edam;
                int[] Numlist = new int[Damage.Length];

                ChangeKoukuFlagToNumber(
                    battle.api_support_info.api_support_airatack.api_stage3.api_erai_flag,
                    battle.api_support_info.api_support_airatack.api_stage3.api_ebak_flag,
                    Numlist);
                DecimalListmake(Numlist, Damage, lists, false);
            }
            else if (battle.api_support_flag == 2 || battle.api_support_flag == 3)//포격,뇌격지원. 포격:2 뇌격:3
            {
                decimal[] Damage;

                if (battle.api_support_info.api_support_hourai == null) return;

                Damage = battle.api_support_info.api_support_hourai.api_damage;
                int[] Numlist = new int[Damage.Length];

                for (int i = 0; i < Damage.Length; i++)
                {
                    if (Damage[i] > 0) Numlist[i] = i;
                    else Numlist[i] = 0;
                }

                DecimalListmake(Numlist, Damage, lists, false);
            }
        }
예제 #3
0
        /// <summary>
        /// 연합함대를 사용한 전투에서 항공전을 처리하는데 사용.
        /// </summary>
        /// <param name="battle"></param>
        private void AirBattle(kcsapi_battle battle)
        {
            //this.Combined = true;

            this.IsCritical = false;
            List<listup> lists = new List<listup>();
            List<int> CurrentHPList = new List<int>();

            this.ResetEnemyInfo(battle);

            try
            {
                if (battle.api_support_flag != 0) Support(battle.api_support_flag, battle, lists);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
                KanColleClient.Current.CatchedErrorLogWriter.ReportException(ex.Source, ex);
            }

            List<listup> Combinelists = new List<listup>();

            //api_kouku시작
            if (battle.api_kouku != null && battle.api_kouku.api_stage3 != null)
            {
                int[] numlist = new int[7];
                decimal[] damlist = battle.api_kouku.api_stage3.api_fdam;

                ChangeKoukuFlagToNumber(
                    battle.api_kouku.api_stage3.api_frai_flag,
                    battle.api_kouku.api_stage3.api_fbak_flag,
                    numlist);
                DecimalListmake(numlist, damlist, lists, true);

                //적에게 준 데미지
                numlist = new int[7];
                damlist = battle.api_kouku.api_stage3.api_edam;

                ChangeKoukuFlagToNumber(
                    battle.api_kouku.api_stage3.api_erai_flag,
                    battle.api_kouku.api_stage3.api_ebak_flag,
                    numlist);
                DecimalListmake(numlist, damlist, lists, false);

                //리스트의 재활용. 여기부터 연합함대 리스트 작성
                if (battle.api_kouku != null && battle.api_kouku.api_stage3_combined != null)
                {
                    numlist = new int[7];
                    damlist = battle.api_kouku.api_stage3_combined.api_fdam;

                    ChangeKoukuFlagToNumber(
                        battle.api_kouku.api_stage3_combined.api_frai_flag,
                        battle.api_kouku.api_stage3_combined.api_fbak_flag,
                        numlist);
                    DecimalListmake(numlist, damlist, Combinelists, true);

                    //적에게 준 데미지
                    numlist = new int[7];
                    damlist = battle.api_kouku.api_stage3_combined.api_edam;

                    ChangeKoukuFlagToNumber(
                        battle.api_kouku.api_stage3_combined.api_erai_flag,
                        battle.api_kouku.api_stage3_combined.api_ebak_flag,
                        numlist);
                    DecimalListmake(numlist, damlist, Combinelists, false);
                }//연합함대 리스트 작성 끝
            }
            //api_kouku끝

            //api_kouku2시작
            if (battle.api_kouku2 != null && battle.api_kouku2.api_stage3 != null)
            {
                int[] numlist = new int[7];
                decimal[] damlist = battle.api_kouku2.api_stage3.api_fdam;

                ChangeKoukuFlagToNumber(battle.api_kouku2.api_stage3.api_frai_flag,
                    battle.api_kouku2.api_stage3.api_fbak_flag,
                    numlist);
                DecimalListmake(numlist, damlist, lists, true);//메인 함대 리스트 작성 끝

                //적에게 준 데미지
                numlist = new int[7];
                damlist = battle.api_kouku2.api_stage3.api_edam;

                ChangeKoukuFlagToNumber(
                    battle.api_kouku2.api_stage3.api_erai_flag,
                    battle.api_kouku2.api_stage3.api_ebak_flag,
                    numlist);
                DecimalListmake(numlist, damlist, lists, false);

                //리스트의 재활용. 여기부터 연합함대 리스트 작성
                if (battle.api_kouku2 != null && battle.api_kouku2.api_stage3_combined != null)
                {
                    numlist = new int[7];
                    damlist = battle.api_kouku2.api_stage3_combined.api_fdam;
                    for (int i = 0; i < battle.api_kouku2.api_stage3_combined.api_frai_flag.Count(); i++)//컴바인 함대 플래그
                    {
                        if (
                            battle.api_kouku2.api_stage3_combined.api_fbak_flag[i] == 1 ||
                            battle.api_kouku2.api_stage3_combined.api_frai_flag[i] == 1)

                            numlist[i] = i;
                    }
                    DecimalListmake(numlist, damlist, Combinelists, true);

                    //적에게 준 데미지
                    numlist = new int[7];
                    damlist = battle.api_kouku2.api_stage3_combined.api_edam;
                    for (int i = 0; i < battle.api_kouku2.api_stage3_combined.api_erai_flag.Count(); i++)//컴바인 함대 플래그
                    {
                        if (
                            battle.api_kouku2.api_stage3_combined.api_ebak_flag[i] == 1 ||
                            battle.api_kouku2.api_stage3_combined.api_erai_flag[i] == 1)

                            numlist[i] = i;
                    }
                    DecimalListmake(numlist, damlist, Combinelists, false);
                }//연합함대 리스트 작성 끝
            }
            //api_kouku끝
            BattleCalc(lists, CurrentHPList, battle.api_maxhps, battle.api_nowhps, false, false, false, true);

            try
            {
                //적 HP계산을 위해 아군리스트와 적군 리스트를 병합.
                int[] CombinePlusEnemyMaxHPs = new int[13];
                int[] CombinePlusEnemyNowHPs = new int[13];
                //최대 HP병합
                for (int i = 0; i < battle.api_maxhps_combined.Length; i++)
                {
                    CombinePlusEnemyMaxHPs[i] = battle.api_maxhps_combined[i];
                }
                for (int i = 7; i < battle.api_maxhps.Length; i++)
                {
                    CombinePlusEnemyMaxHPs[i] = battle.api_maxhps[i];
                }

                //현재 HP병합
                for (int i = 0; i < battle.api_nowhps_combined.Length; i++)
                {
                    CombinePlusEnemyNowHPs[i] = battle.api_nowhps_combined[i];
                }
                for (int i = 7; i < battle.api_nowhps.Length; i++)
                {
                    CombinePlusEnemyNowHPs[i] = CurrentHPList[i];
                }

                //재활용 위해 초기화.
                CurrentHPList = new List<int>();

                BattleCalc(Combinelists, CurrentHPList, CombinePlusEnemyMaxHPs, CombinePlusEnemyNowHPs, true, false, false, true);
                //BattleCalc(HPList, MHPList, Combinelists, CurrentHPList, battle.api_maxhps_combined, battle.api_nowhps_combined,true);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                KanColleClient.Current.CatchedErrorLogWriter.ReportException(e.Source, e);
            }

            if (EnableBattlePreview)
            {
                this.PreviewCriticalCondition();
                this.IsBattleCalculated = true;
            }
        }
예제 #4
0
        private void ResetEnemyInfo(kcsapi_battle battle)
        {
            if (EnableBattlePreview)
            {
                int i = battle.api_ship_ke.Count();
                DataLists.EnemyID = new int[i];
                DataLists.EnemyID = battle.api_ship_ke;
                i = battle.api_ship_lv.Count();
                DataLists.EnemyLv = new int[i];
                DataLists.EnemyLv = battle.api_ship_lv;

                this.DockId = battle.api_dock_id;
            }
        }