private void getSingleResult()
        {
            loadCard();
            clearStats();
            bool secondcolumn = false;
            char grade;
            int  result;
            int  balls   = Convert.ToInt32(this.textBoxBalls.Text);
            int  strikes = Convert.ToInt32(this.textBoxStrikes.Text);
            int  outs    = Convert.ToInt32(this.textBoxOuts.Text);

            //int roll;
            List <string> pitcherControl = new List <string>();

            if (checkBoxRandomizePitchingControl.Checked)
            {
                pitcherControl = getRandomPitchingControl();
            }
            else
            {
                foreach (object itemChecked in checkedListBoxControl.CheckedItems)
                {
                    pitcherControl.Add(itemChecked.ToString());
                }
            }
            if (checkBoxRandomizePitchingGrade.Checked)
            {
                grade = GetRandomPitchingGrade();
            }
            else
            {
                grade = Convert.ToChar(this.comboBoxPitchingGrade.SelectedItem.ToString());
            }

            result = Convert.ToInt32(comboBoxResult.SelectedItem.ToString());

            richTextBoxResult.Text = "Result: " + result.ToString();

            Player hitter = homeTeam.players[0];

            string baseSituation = "";

            if (checkBoxRandomizeBaseSituation.Checked)
            {
                getRandomBaseSituationAndOuts(out outs, out baseSituation);
            }
            else
            {
                baseSituation = this.comboBoxBaseSituation.SelectedItem.ToString();
            }

            int fielding = 2;

            if (checkBoxRandomizeFielding.Checked)
            {
                int oneroll;
                Die die = new Die(10);
                oneroll = die.Roll();
                if (oneroll <= 5)
                {
                    fielding = 2;
                    fielding2Total++;
                }
                if (oneroll > 5 && oneroll <= 8)
                {
                    fielding = 1;
                    fielding1Total++;
                }
                if (oneroll > 8)
                {
                    fielding = 3;
                    fielding3Total++;
                }
            }
            else
            {
                fielding = Convert.ToInt32(this.comboBoxFielding.SelectedItem.ToString());
            }

            switch (baseSituation)
            {
            case "Bases Empty":
                resultsdescription = basesEmpty.GetResult(result, grade, fielding, ref hitter, outs, pitcherControl, secondcolumn, strikes, balls);
                break;

            case "Runner on first base":
                resultsdescription = runnerOnFirst.GetResult(result, grade, fielding, ref hitter, outs, pitcherControl, getRandomRunnerSpeed(), secondcolumn, strikes, balls);
                break;

            case "Runner on second base":
                resultsdescription = runnerOnSecond.GetResult(result, grade, fielding, ref hitter, outs, pitcherControl, getRandomRunnerSpeed(), secondcolumn, strikes, balls);
                break;

            case "Runner on third base":
                resultsdescription = runnerOnThird.GetResult(result, grade, fielding, ref hitter, outs, pitcherControl, getRandomRunnerSpeed(), strikes, balls, secondcolumn);
                break;

            case "Runners on 1st and 2nd":
                resultsdescription = runnerOnFirstAndSecond.GetResult(result, grade, fielding, ref hitter, outs, pitcherControl, strikes, balls, secondcolumn);
                break;

            case "Runners on 1st and 3rd":
                resultsdescription = runnerOnFirstAndThird.GetResult(result, grade, fielding, ref hitter, outs, pitcherControl, getRandomRunnerSpeed(), getRandomRunnerSpeed(), strikes, balls, secondcolumn);
                break;

            case "Runners on 2nd and 3rd":
                resultsdescription = runnerOnSecondAndThird.GetResult(result, grade, fielding, ref hitter, outs, pitcherControl, getRandomRunnerSpeed(), getRandomRunnerSpeed(), strikes, balls, secondcolumn);
                break;

            case "Bases Full":
                resultsdescription = basesFull.GetResult(result, grade, fielding, ref hitter, outs, pitcherControl, getRandomRunnerSpeed(), getRandomRunnerSpeed(), getRandomRunnerSpeed(), strikes, balls, secondcolumn);
                break;

            default:
                throw new System.Exception("Error, invalid base situation->" + this.comboBoxBaseSituation.SelectedItem.ToString());
            }
            this.richTextBoxResult.Text += " " + resultsdescription;
        }
        public void getRandomBaseSituationAndOuts(out int outs, out string baseSituation)
        {
            // move to get random base situation and outs
            Die die     = new Die(100000);
            int dieroll = die.Roll();

            baseSituation = "";
            outs          = 0;
            if (dieroll >= 1 && dieroll <= 24239)//	0	0
            {
                baseSituation = "Bases Empty";
                outs          = 0;
            }
            if (dieroll >= 24240 && dieroll <= 30487)//	1	0
            {
                baseSituation = "Runner on first base";
                outs          = 0;
            }
            if (dieroll >= 30488 && dieroll <= 32158)//	2	0
            {
                baseSituation = "Runner on second base";
                outs          = 0;
            }
            if (dieroll >= 32159 && dieroll <= 32347)//	3	0
            {
                baseSituation = "Runner on third base";
                outs          = 0;
            }
            if (dieroll >= 32348 && dieroll <= 33271)//	12	0
            {
                baseSituation = "Runners on 1st and 2nd";
                outs          = 0;
            }
            if (dieroll >= 33272 && dieroll <= 33855)//	13	0
            {
                baseSituation = "Runners on 1st and 3rd";
                outs          = 0;
            }
            if (dieroll >= 33856 && dieroll <= 34351)//	23	0
            {
                baseSituation = "Runners on 2nd and 3rd";
                outs          = 0;
            }
            if (dieroll >= 34352 && dieroll <= 34584)//	123	0
            {
                baseSituation = "Bases Full";
                outs          = 0;
            }
            if (dieroll >= 34585 && dieroll <= 51868)//	0	1
            {
                baseSituation = "Bases Empty";
                outs          = 1;
            }
            if (dieroll >= 51869 && dieroll <= 59330)//	1	1
            {
                baseSituation = "Runner on first base";
                outs          = 1;
            }
            if (dieroll >= 59331 && dieroll <= 62648)//	2	1
            {
                baseSituation = "Runner on second base";
                outs          = 1;
            }
            if (dieroll >= 62649 && dieroll <= 63376)//	3	1
            {
                baseSituation = "Runner on third base";
                outs          = 1;
            }
            if (dieroll >= 63377 && dieroll <= 65040)//	12	1
            {
                baseSituation = "Runners on 1st and 2nd";
                outs          = 1;
            }
            if (dieroll >= 65041 && dieroll <= 66168)//	13	1
            {
                baseSituation = "Runners on 1st and 3rd";
                outs          = 1;
            }
            if (dieroll >= 66169 && dieroll <= 67181)//	23	1
            {
                baseSituation = "Runners on 2nd and 3rd";
                outs          = 1;
            }
            if (dieroll >= 67182 && dieroll <= 67696)   //123	1
            {
                baseSituation = "Bases Full";
                outs          = 1;
            }
            if (dieroll >= 67697 && dieroll <= 81214)//	0	2
            {
                baseSituation = "Bases Empty";
                outs          = 2;
            }
            if (dieroll >= 81215 && dieroll <= 88573)   //1	2
            {
                baseSituation = "Runner on first base";
                outs          = 2;
            }
            if (dieroll >= 88574 && dieroll <= 92920)//	2	2
            {
                baseSituation = "Runner on second base";
                outs          = 2;
            }
            if (dieroll >= 92921 && dieroll <= 94411)//3	2
            {
                baseSituation = "Runner on third base";
                outs          = 2;
            }
            if (dieroll >= 94412 && dieroll <= 96306)//	12	2
            {
                baseSituation = "Runners on 1st and 2nd";
                outs          = 2;
            }
            if (dieroll >= 96307 && dieroll <= 98050)//	13	2
            {
                baseSituation = "Runners on 1st and 3rd";
                outs          = 2;
            }
            if (dieroll >= 98051 && dieroll <= 99355)//	23	2
            {
                baseSituation = "Runners on 2nd and 3rd";
                outs          = 2;
            }
            if (dieroll >= 99356 && dieroll <= 100000)//	123	2
            {
                baseSituation = "Bases Full";
                outs          = 2;
            }
        }
Esempio n. 3
0
 public Dice()
 {
     RedDie   = new Die(7);
     WhiteDie = new Die(7);
 }