Esempio n. 1
0
        //returns the top 3 players by win percentage
        private void GetTop3Players(Player[] bracket, out Player first, out Player second, out Player third)
        {
            //first, second, and third are initialized to the first 3 players in the bracket, and sorted
            first = bracket[0];
            if (bracket[1].GetWinPercentage() > first.GetWinPercentage())
            {
                second = first;
                first  = bracket[1];
            }
            else
            {
                second = bracket[1];
            }

            if (bracket[2].GetWinPercentage() > first.GetWinPercentage())
            {
                third  = second;
                second = first;
                first  = bracket[2];
            }
            else if (bracket[2].GetWinPercentage() > second.GetWinPercentage())
            {
                third  = second;
                second = bracket[2];
            }
            else
            {
                third = bracket[2];
            }

            for (int i = 3; i < playersPerBracket; i++)
            {
                if (bracket[i].GetWinPercentage() > first.GetWinPercentage())//new first place found
                {
                    third  = second;
                    second = first;
                    first  = bracket[2];
                }
                else if (bracket[i].GetWinPercentage() > second.GetWinPercentage())//new second place found
                {
                    third  = second;
                    second = bracket[i];
                }
                else if (bracket[i].GetWinPercentage() > third.GetWinPercentage())//new third place found
                {
                    third = bracket[i];
                }
            }
        }
Esempio n. 2
0
        //Returns the player with the best win percentage
        private Player GetTopPlayer(Player[] players)
        {
            Player top = players[0];

            foreach (Player p in players)
            {
                if (p.GetWinPercentage() > top.GetWinPercentage())
                {
                    top = p;
                }
            }
            return(top);
        }