Пример #1
0
        private void WinningStats()
        {
            #region variables
            int win = 0, loss = 0, i = 0;
            int onew = 0, twow = 0, threew = 0, fourw = 0, fivew = 0, sixw = 0, sevenw = 0,
                eightw = 0, ninew = 0, tenw = 0, elevenw = 0, twelvew = 0;
            #endregion

            #region userInput Form2
            using (formClass form2 = new formClass())
            {
                form2.ShowDialog();
            }

            string userChoice;
            userChoice = formClass.userChoice;

            bool toRun = true;
            switch (formClass.userChoice)
            {
            case "Druid":
            case "Hunter":
            case "Mage":
            case "Paladin":
            case "Priest":
            case "Rogue":
            case "Shaman":
            case "Warlock":
            case "Warrior":
            case "All":
                break;

            default:
                toRun      = false;
                userChoice = "Error, Try Again";
                break;
            }
            #endregion

            #region mainFunction
            if (toRun)
            {
                fileChecker();
                string[] stats = System.IO.File.ReadAllLines(@"newStat.txt");

                if (userChoice == "All")
                {
                    userChoice = " ";
                }
                foreach (string s in stats)
                {
                    if (s.Contains(userChoice))
                    {
                        string pattern = @"[0-9]+";
                        Match  m       = Regex.Match(s, pattern);
                        win  = Convert.ToInt32(m.Value);
                        m    = m.NextMatch();
                        loss = Convert.ToInt32(m.Value);

                        switch (win)
                        {
                        case 1:
                            onew++;
                            break;

                        case 2:
                            twow++;
                            break;

                        case 3:
                            threew++;
                            break;

                        case 4:
                            fourw++;
                            break;

                        case 5:
                            fivew++;
                            break;

                        case 6:
                            sixw++;
                            break;

                        case 7:
                            sevenw++;
                            break;

                        case 8:
                            eightw++;
                            break;

                        case 9:
                            ninew++;
                            break;

                        case 10:
                            tenw++;
                            break;

                        case 11:
                            elevenw++;
                            break;

                        case 12:
                            twelvew++;
                            break;
                        }
                        i++;
                    }
                }
            }

            #endregion

            #region output
            if (toRun)
            {
                richTextBox2.Text = String.Format("Number of wins on all {0} {1} {3} {2} \n\n", i, (i > 1 ? "runs" : "run"), userChoice, (userChoice == " " ? " " : "with"));
                if (onew > 0)
                {
                    richTextBox2.Text += String.Format("{0,-4} {2,-11} -            {1,-4} {3} \n\n", 1, onew, "win", (onew > 1 ? "times" : "time"));
                }
                if (twow > 0)
                {
                    richTextBox2.Text += String.Format("{0,-4} {2,-11} -            {1,-4} {3} \n\n", 2, twow, "wins", (twow > 1 ? "times" : "time"));
                }
                if (threew > 0)
                {
                    richTextBox2.Text += String.Format("{0,-4} {2,-11} -            {1,-4} {3} \n\n", 3, threew, "wins", (threew > 1 ? "times" : "time"));
                }
                if (fourw > 0)
                {
                    richTextBox2.Text += String.Format("{0,-4} {2,-11} -            {1,-4} {3} \n\n", 4, fourw, "wins", (fourw > 1 ? "times" : "time"));
                }
                if (fivew > 0)
                {
                    richTextBox2.Text += String.Format("{0,-4} {2,-11} -            {1,-4} {3} \n\n", 5, fivew, "wins", (fivew > 1 ? "times" : "time"));
                }
                if (sixw > 0)
                {
                    richTextBox2.Text += String.Format("{0,-4} {2,-11} -            {1,-4} {3} \n\n", 6, sixw, "wins", (sixw > 1 ? "times" : "time"));
                }
                if (sevenw > 0)
                {
                    richTextBox2.Text += String.Format("{0,-4} {2,-11} -            {1,-4} {3} \n\n", 7, sevenw, "wins", (sevenw > 1 ? "times" : "time"));
                }
                if (eightw > 0)
                {
                    richTextBox2.Text += String.Format("{0,-4} {2,-11} -            {1,-4} {3} \n\n", 8, eightw, "wins", (eightw > 1 ? "times" : "time"));
                }
                if (ninew > 0)
                {
                    richTextBox2.Text += String.Format("{0,-4} {2,-11} -            {1,-4} {3} \n\n", 9, ninew, "wins", (ninew > 1 ? "times" : "time"));
                }
                if (tenw > 0)
                {
                    richTextBox2.Text += String.Format("{0,-4} {2,-11} -            {1,-4} {3} \n\n", 10, tenw, "wins", (tenw > 1 ? "times" : "time"));
                }
                if (elevenw > 0)
                {
                    richTextBox2.Text += String.Format("{0,-4} {2,-11} -            {1,-4} {3} \n\n", 11, elevenw, "wins", (elevenw > 1 ? "times" : "time"));
                }
                if (twelvew > 0)
                {
                    richTextBox2.Text += String.Format("{0,-4} {2,-11} -            {1,-4} {3}\n\n", 12, twelvew, "wins", (twelvew > 1 ? "times" : "time"));
                }
            }
            else
            {
                richTextBox2.Text = userChoice;
            }
            #endregion
        }
Пример #2
0
        private void ClassStat()
        {
            #region variables
            int    win = 0, loss = 0, i = 0, k = 0, played = 0, matches = 0;
            double winp = 0.00, classPoint = 0.00;
            #endregion

            #region userInput Form2
            using (formClass form2 = new formClass())
            {
                form2.ShowDialog();
            }

            string userChoice = "";
            userChoice = formClass.userChoice;

            bool toRun = true;
            switch (formClass.userChoice)
            {
            case "Druid":
            case "Hunter":
            case "Mage":
            case "Paladin":
            case "Priest":
            case "Rogue":
            case "Shaman":
            case "Warlock":
            case "Warrior":
            case "All":
                break;

            default:
                toRun      = false;
                userChoice = "Error, Try Again";
                break;
            }
            #endregion

            #region mainFunction
            if (toRun)
            {
                fileChecker();
                string[] stats = System.IO.File.ReadAllLines(@"newStat.txt");

                if (userChoice == "All")
                {
                    userChoice = " ";
                }
                foreach (string s in stats)
                {
                    if (s.Contains(userChoice))
                    {
                        string[] run = s.Split(' ');
                        win  += Convert.ToInt32(run[1]);
                        loss += Convert.ToInt32(run[2]);
                        i++;
                    }
                    k++;
                }
            }
            #endregion

            #region statCalculator
            if (toRun)
            {
                if (win == 0)
                {
                    winp = 00.00;
                }
                else
                {
                    winp = ((double)win / ((double)win + (double)loss)) * 100;
                }

                matches    = win + loss;
                classPoint = (double)win / (double)i;
                played     = i / k * 100;
            }
            #endregion

            #region output
            if (toRun)
            {
                richTextBox2.Text  = String.Format("{0,-59}{1}\n", "Matches Played: ", matches);
                richTextBox2.Text += String.Format("{0,-50}{1:0.00}%\n\n", "Matches Played in Percentage: ", played);
                richTextBox2.Text += String.Format("{0,-63}{1}\n", "Total Runs: ", i);
                richTextBox2.Text += String.Format("{0,-66}{1}\n", "Wins: ", win);
                richTextBox2.Text += String.Format("{0,-67}{1}\n", "Loss: ", loss);
                richTextBox2.Text += String.Format("{0,-59}{1:0.00}%\n\n", "Win Percentage: ", winp);

                if (userChoice != " ")
                {
                    richTextBox2.Text += String.Format("{0,-64}{1:0.00} Points", "Class Points: ", classPoint);
                }
            }
            else
            {
                richTextBox2.Text = userChoice;
            }

            #endregion
        }