Пример #1
0
        /// <summary>
        /// 通常実行ボタン
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void m_ExecuteButton_Click(object sender, EventArgs e)
        {
            this.Enabled = false;
            Application.DoEvents();
            Cursor.Current = Cursors.WaitCursor;

            // 打撃結果の格納コレクション
            List<BattingResultKind> results = new List<BattingResultKind>();

            // 打点、暴投、投球数を集計
            int ribby = 0;
            int wildPitch = 0;
            int throwBollCount = 0;

            // 捕球時間を集計
            int catchTime = 0;

            // チーム設定以外のパラメータ設定
            int baseAbilityValue = int.Parse(m_BaseAbilityValue.Text);
            Constants.FlyPercent = int.Parse(m_FlyPercent.Text);
            Constants.BaseToFenceDistance = int.Parse(m_FenseValue.Text);
            Constants.FastBallPercent = int.Parse(m_FastBollPercent.Text);
            Enum.TryParse(m_Direction.Text, out GameManager.DebugBattingDirection);
            int executeCount = int.Parse(m_ExecuteCount.Text);

            // 指定したパラメータで既定回数実行)
            for (int i = 0; i < executeCount; i++)
            {
                GameManager gameManager = GetGameManager(baseAbilityValue);
                TeamSetting topTeamSetting = gameManager.GameData.TopTeamSetting;
                TeamSetting bottomTeamSetting = gameManager.GameData.BottomTeamSetting;

                // 投球戦術の設定
                PitchingMissionManager.PitchingMissionsForDebug.Clear();
                if (m_PitchingMission.Text != string.Empty)
                {
                    // 検証用の投球作戦として設定する
                    PitchingMissionKind pitchingMission = (PitchingMissionKind)Enum.Parse(typeof(PitchingMissionKind), m_PitchingMission.Text);
                    PitchingMissionManager.PitchingMissionsForDebug.Add(new PitchingMission(pitchingMission));

                    // 検証用の投球作戦を設定した場合、「球種変更補正を含めた強い球種を多用」は常に設定する
                    PitchingMissionManager.PitchingMissionsForDebug.Add(new PitchingMission(PitchingMissionKind.StrongBallByChangeBollKind));
                }

                // 打撃戦術の設定
                if (m_BattingMission.Text != string.Empty)
                {
                    // 打者のチーム(先行チーム)がユーザチームであることを利用して
                    // ユーザ指定の作戦として設定する
                    BattingMissionKind battingMission = (BattingMissionKind)Enum.Parse(typeof(BattingMissionKind), m_BattingMission.Text);
                    gameManager.GameData.RequestedBattingMissions.Add(new BattingMission(battingMission));
                }

                // 試合の実行
                // (暴投でランナーが生還した場合も継続するため打順変わるまで継続する)
                gameManager.ContinueGameByOneBatter(false);

                results.Add(topTeamSetting.CurrentPlayingMembers.First().BattingResults.First());
                ribby += topTeamSetting.CurrentPlayingMembers.First().Ribby;
                wildPitch += bottomTeamSetting.WildPitchCount;
                throwBollCount += bottomTeamSetting.GetMember(DefensePosition.Pitcher).PitchingResult.ThrowBollCount;
                if (gameManager.GameData.LatestPitchingBollResult.PitchingBollResultKind == PitchingBollResultKind.BattingBoll)
                {
                    catchTime += gameManager.CatchTime;
                }
                gameManager.Dispose();
            }

            // 打撃結果を出力するためにメンバを作成
            GameMember member = new GameMember(new Player(), DefensePosition.Sub);
            int inFielderHitCount = 0;
            int inFielderGroundCount = 0;
            int outFielderGroundCount = 0;
            int inFielderFlyCount = 0;
            int outFielderFlyCount = 0;
            int errorCount = 0;
            int gounrd1 = 0;
            int gounrd2 = 0;
            int gounrd3 = 0;
            int gounrd4 = 0;
            int gounrd5 = 0;
            int gounrd6 = 0;
            int getTwoCount = 0;
            int sacrificeCount = 0;
            foreach (BattingResultKind result in results)
            {
                member.AddBattingResult(result, 0);
                if (BattingResultKindHelper.IsInFielderHit(result))
                {
                    // 内安打
                    inFielderHitCount++;
                }
                if (BattingResultKindHelper.IsInFielderGround(result))
                {
                    // 内野ゴロ
                    inFielderGroundCount++;
                    if (result == BattingResultKind.PitcherGround || result == BattingResultKind.PitcherGetTwo) gounrd1++;
                    if (result == BattingResultKind.CatcherGround || result == BattingResultKind.CatcherGetTwo) gounrd2++;
                    if (result == BattingResultKind.FirstGround || result == BattingResultKind.FirstGetTwo) gounrd3++;
                    if (result == BattingResultKind.SecondGround || result == BattingResultKind.SecondGetTwo) gounrd4++;
                    if (result == BattingResultKind.ThirdGround || result == BattingResultKind.ThirdGetTwo) gounrd5++;
                    if (result == BattingResultKind.ShortGround || result == BattingResultKind.ShortGetTwo) gounrd6++;
                }
                if (BattingResultKindHelper.IsOutFielderGround(result))
                {
                    // 外野ゴロ
                    outFielderGroundCount++;
                }
                if (BattingResultKindHelper.IsInFielderFly(result))
                {
                    // 内野フライ
                    inFielderFlyCount++;
                }
                if (BattingResultKindHelper.IsOutFielderFly(result))
                {
                    // 外野フライ
                    outFielderFlyCount++;
                }
                if (BattingResultKindHelper.IsError(result))
                {
                    // 失策
                    errorCount++;
                }
                if (BattingResultKindHelper.IsGetTwo(result))
                {
                    // 併殺
                    getTwoCount++;
                }
                if (result == BattingResultKind.SacrificeBunt || result == BattingResultKind.SacrificeFly)
                {
                    // 犠打
                    sacrificeCount++;
                }
            }

            int outBatCount = member.BatCount - member.HitCount;

            // 表示に用いる際の基準の回数に変換する補正値を計算
            double executeCountRasio = ((double)executeCount / ExecuteBasicCount);

            // 打撃結果を出力
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.AppendLine(string.Format("打率 :{0}", member.Player.BattingAverage));
            stringBuilder.AppendLine(string.Format("出塁率:{0}", member.Player.OnBasePercentage));
            stringBuilder.AppendLine(string.Format("長打率:{0}", member.Player.SluggingAverage));
            stringBuilder.AppendLine(string.Format("OPS   :{0}", member.Player.OPS));
            stringBuilder.AppendLine(string.Format("安打数:{0}", (int)(member.HitCount / executeCountRasio)));
            stringBuilder.AppendLine(string.Format("二塁打:{0}", (int)(member.TwoBaseHitCount / executeCountRasio)));
            stringBuilder.AppendLine(string.Format("三塁打:{0}", (int)(member.ThreeBaseHitCount / executeCountRasio)));
            stringBuilder.AppendLine(string.Format("本塁打:{0}", (int)(member.HomeRunCount / executeCountRasio)));
            stringBuilder.AppendLine(string.Format("内安打:{0}", (int)(inFielderHitCount / executeCountRasio)));
            stringBuilder.AppendLine(string.Format("四死球:{0}", (int)(member.FourBollOrDeadBollCount / executeCountRasio)));
            stringBuilder.AppendLine(string.Format("打点 :{0}", (int)(ribby / executeCountRasio)));
            stringBuilder.AppendLine(string.Format("三振率:{0}%", (member.StrikeOutCount * 100 / outBatCount)));
            stringBuilder.AppendLine(string.Format("内野ゴ:{0}%", (inFielderGroundCount * 100 / outBatCount)));
            stringBuilder.AppendLine(string.Format("外野ゴ:{0}%", (outFielderGroundCount * 100 / outBatCount)));
            stringBuilder.AppendLine(string.Format("内野飛:{0}%", (inFielderFlyCount * 100 / outBatCount)));
            stringBuilder.AppendLine(string.Format("外野飛:{0}%", (outFielderFlyCount * 100 / outBatCount)));
            stringBuilder.AppendLine(string.Format("失策 :{0}%", (errorCount * 100 / outBatCount)));
            stringBuilder.AppendLine(string.Format("三振数:{0}", (int)(member.StrikeOutCount / executeCountRasio)));
            stringBuilder.AppendLine(string.Format("投ゴ :{0}", (int)(gounrd1 / executeCountRasio)));
            stringBuilder.AppendLine(string.Format("捕ゴ :{0}", (int)(gounrd2 / executeCountRasio)));
            stringBuilder.AppendLine(string.Format("一ゴ :{0}", (int)(gounrd3 / executeCountRasio)));
            stringBuilder.AppendLine(string.Format("ニゴ :{0}", (int)(gounrd4 / executeCountRasio)));
            stringBuilder.AppendLine(string.Format("遊ゴ :{0}", (int)(gounrd6 / executeCountRasio)));
            stringBuilder.AppendLine(string.Format("三ゴ :{0}", (int)(gounrd5 / executeCountRasio)));
            stringBuilder.AppendLine(string.Format("外ゴ :{0}", (int)(outFielderGroundCount / executeCountRasio)));
            stringBuilder.AppendLine(string.Format("併殺 :{0}(内ゴ{1})", (int)(getTwoCount / executeCountRasio), (int)(inFielderGroundCount / executeCountRasio)));
            stringBuilder.AppendLine(string.Format("犠打 :{0}", (int)(sacrificeCount / executeCountRasio)));
            stringBuilder.AppendLine(string.Format("暴投 :{0}", (int)(wildPitch / executeCountRasio)));
            stringBuilder.AppendLine(string.Format("投球数:{0}", (int)((double)throwBollCount / outBatCount * 27)));
            stringBuilder.AppendLine(string.Format("捕球時間平均:{0}", (catchTime / Math.Max(1, executeCount - member.StrikeOutCount - member.FourBollOrDeadBollCount))));
            m_ResultText.Text = stringBuilder.ToString();

            Cursor.Current = Cursors.Default;
            this.Enabled = true;
        }