public void ComputerTeamDraft(LeaugeTeam a_team, String a_name)
        {
            int BestPick   = 0;
            int MostPoints = 0;
            int index      = 0;
            int totalPoints;

            foreach (string player in PlayerPoints.Skip(1))
            {
                index++;
                totalPoints = Int32.Parse(player);
                if (totalPoints > MostPoints && CheckIfPlayerTaken(index) == false && a_team.CanDraftPosition(PlayerPos, index) == true)
                {
                    MostPoints = totalPoints;
                    BestPick   = index;
                }
            }
            String[] aPick = PlayerName[BestPick].Split('\\');
            PlayerName[BestPick] = aPick[0];
            Console.WriteLine("{0} Drafted: {1}", a_name, PlayerName[BestPick]);
            if (PlayerPos[BestPick].Contains('G'))
            {
                a_team.AddGuard();
            }
            else if (PlayerPos[BestPick].Contains('F'))
            {
                a_team.AddForward();
            }
            else if (PlayerPos[BestPick].Contains('C'))
            {
                a_team.AddCenters();
            }
            AddTakenPlayer(BestPick);
            a_team.AddingPlayer(BestPick);
        }
        public void AskForTrade(LeaugeTeam a_player, LeaugeTeam a_CPU, LeaugeTeam a_CPU2, LeaugeTeam a_CPU3)
        {
            foreach (LeaugeTeam team in Teams)
            {
                Console.WriteLine(team.GetName());
                team.ShowTeam(PlayerName);
            }
            Console.WriteLine("Who would you like to trade with?");
            string input = Console.ReadLine();

            switch (input)
            {
            case "CPU1":
                Trade(a_player, a_CPU);
                break;

            case "CPU2":
                Trade(a_player, a_CPU2);
                break;

            case "CPU3":
                Trade(a_player, a_CPU3);
                break;

            default:
                Console.WriteLine("invalid");
                break;
            }
        }
        public void ShowFreeAgents(LeaugeTeam a_player)
        {
            int    BestPick   = 0;
            int    MostPoints = 0;
            int    index      = 0;
            int    totalPoints;
            string input;

            Console.WriteLine("What Positon? (all,G,F,C)");
            input = Console.ReadLine();
            for (int i = 0; i < 10; i++)
            {
                foreach (string player in PlayerPoints.Skip(1))
                {
                    index++;
                    totalPoints = Int32.Parse(player);
                    String[] PlayerNames = PlayerName[index].Split('\\');
                    if (input == "all")
                    {
                        if (totalPoints > MostPoints && CheckIfPlayerTaken(index) != true && TopTenFree.Contains(index) != true)
                        {
                            MostPoints = totalPoints;
                            BestPick   = index;
                        }
                    }
                    else if (PlayerPos[index].Contains(input))
                    {
                        if (totalPoints > MostPoints && CheckIfPlayerTaken(index) != true && TopTenFree.Contains(index) != true)
                        {
                            MostPoints = totalPoints;
                            BestPick   = index;
                        }
                    }
                }
                String[] FreeAgent = PlayerName[BestPick].Split('\\');
                PlayerName[BestPick] = FreeAgent[0];
                TopTenFree.Add(BestPick);
                BestPick    = 0;
                MostPoints  = 0;
                index       = 0;
                totalPoints = 0;
            }
            foreach (int player in TopTenFree)
            {
                Console.Write("{0}.", index);
                PrintPlayer(player);
                index++;
            }
            Console.WriteLine("Would you like to add/drop a player? (y/n)");
            input = Console.ReadLine();
            if (input == "y")
            {
                AddDrop(a_player);
            }
            TopTenFree.Clear();
        }
        public void HumanTeamDraft(LeaugeTeam a_player)
        {
            bool validInput = false;

            do
            {
                Console.Write("Enter players name:");
                string input  = Console.ReadLine();
                string value1 = Array.Find(PlayerName,
                                           element => element.StartsWith(input, StringComparison.Ordinal));
                int pID = Array.FindIndex(PlayerName, item => item == value1);
                try
                {
                    if (pID == -1)
                    {
                        throw new Exception();
                    }
                    try
                    {
                        if (CheckIfPlayerTaken(pID) == true)
                        {
                            throw new ArgumentException();
                        }
                        try
                        {
                            if (a_player.CanDraftPosition(PlayerPos, pID) == false)
                            {
                                throw new Exception();
                            }
                            else
                            {
                                PlayerName[pID] = input;
                                AddTakenPlayer(pID);
                                a_player.AddingPlayer(pID);
                                validInput = true;
                            }
                        }
                        catch
                        {
                            Console.WriteLine("Too many players of the same position on the team");
                        }
                    }
                    catch
                    {
                        Console.WriteLine("That Player has already been drafted");
                    }
                }
                catch
                {
                    Console.WriteLine("Invalid Player entry");
                }
            } while (validInput == false);
        }
        public void RandomizingDraftOrder()
        {
            Random rng = new Random();
            int    n   = Teams.Count;

            while (n > 1)
            {
                n--;
                int        k     = rng.Next(n + 1);
                LeaugeTeam value = Teams[k];
                Teams[k] = Teams[n];
                Teams[n] = value;
            }
        }
        public void Trade(LeaugeTeam a_player, LeaugeTeam a_CPU)
        {
            int  playerPlayer;
            int  cpuPlayer;
            bool tradeApprove;

            a_player.ShowTeam(PlayerName);
            a_CPU.ShowTeam(PlayerName);
            Console.WriteLine("Who would you like to offer?");
            string input = Console.ReadLine();

            playerPlayer = Int32.Parse(input);
            Console.WriteLine("Who would you like to get?");
            input     = Console.ReadLine();
            cpuPlayer = Int32.Parse(input);
            if (a_player.CanDraftPosition(PlayerPos, a_CPU.team[cpuPlayer]) == true && a_CPU.CanDraftPosition(PlayerPos, a_player.team[playerPlayer]) == true)
            {
                tradeApprove = true;
            }
            else if (PlayerPos[a_player.team[playerPlayer]] == "C" && PlayerPos[a_CPU.team[cpuPlayer]] == "C")
            {
                tradeApprove = true;
            }
            else if (PlayerPos[a_player.team[playerPlayer]].Substring(1, 1) == "G" && PlayerPos[a_CPU.team[cpuPlayer]].Substring(1, 1) == "G")
            {
                tradeApprove = true;
            }
            else if (PlayerPos[a_player.team[playerPlayer]].Substring(1, 1) == "F" && PlayerPos[a_CPU.team[cpuPlayer]].Substring(1, 1) == "F")
            {
                tradeApprove = true;
            }
            else
            {
                tradeApprove = false;
            }
            if (tradeApprove == true && a_CPU.AssessTrade(a_player.team[playerPlayer], a_CPU.team[cpuPlayer], PlayerPoints, PlayerOffensReb, PlayerDefenceReb, PlayerAssist, PlayerBlock, PlayerSteal, PlayerTurnover) == true)
            {
                Console.WriteLine("{0} for {1}", PlayerName[a_player.team[playerPlayer]], PlayerName[a_CPU.team[cpuPlayer]]);
                a_player.AddingPlayer(a_CPU.team[cpuPlayer]);
                a_CPU.AddingPlayer(a_player.team[playerPlayer]);
                a_player.DroppingPlayer(playerPlayer);
                a_CPU.DroppingPlayer(cpuPlayer);
            }
        }
        public void AddDrop(LeaugeTeam a_player)
        {
            int    playerAdding;
            int    playerDropping;
            string input;

            do
            {
                Console.WriteLine("Who would you like to add?");
                input        = Console.ReadLine();
                playerAdding = Int32.Parse(input);
                a_player.ShowTeam(PlayerName);
                Console.WriteLine("Who would you like to drop?");
                input          = Console.ReadLine();
                playerDropping = Int32.Parse(input);
            } while (PlayerPos[TopTenFree[playerAdding]] != PlayerPos[TopTenFree[playerDropping]] && a_player.CanDraftPosition(PlayerPos, TopTenFree[playerAdding]) == false);
            Console.WriteLine("{0} for {1}", PlayerName[TopTenFree[playerAdding]], PlayerName[a_player.team[playerDropping]]);
            a_player.AddingPlayer(TopTenFree[playerAdding]);
            AddTakenPlayer(TopTenFree[playerAdding]);
            drafted.RemoveAt(drafted.IndexOf(a_player.team[playerDropping]));
            a_player.DroppingPlayer(playerDropping);
        }
        public string SetUpWeekMatchup(LeaugeTeam a_player, LeaugeTeam a_CPU1, LeaugeTeam a_CPU2, LeaugeTeam a_CPU3)
        {
            matchup = 0;
            int indexX = 0;

            RandomGen = new Random();
            foreach (int week in Week)
            {
                Console.WriteLine("week {0}", week);
                if (matchup == 0)
                {
                    matchup = 1;
                }
                else if (matchup == 1)
                {
                    Teams   = MatchupType2.Select(i => Teams[i]).ToList();
                    matchup = 2;
                }
                else if (matchup == 2)
                {
                    Teams   = MatchupType3.Select(i => Teams[i]).ToList();
                    Teams   = MatchupType4.Select(i => Teams[i]).ToList();
                    matchup = 0;
                }
                foreach (LeaugeTeam teams in Teams)
                {
                    //index = 0;
                    for (int indexY = 0; indexY < 7; indexY++)
                    {
                        indexX = 0;
                        //https://stackoverflow.com/questions/37858551/implement-percent-chance-in-c-sharp 5/25/20
                        foreach (int player in teams.team)
                        {
                            PlayerGamesPlayed = Int32.Parse(GetPlayerGamesPlayed(player));
                            ChanceMissing     = (Math.Round((PlayerGamesPlayed / Totalgames) * 100, MidpointRounding.AwayFromZero));
                            int RandomVal = RandomGen.Next(100);
                            //chance of missing a game
                            if (RandomVal < ChanceMissing)
                            {
                                RandomVal = RandomGen.Next(100);
                                //average game
                                if (15 < RandomVal && RandomVal < 85)
                                {
                                    RandomVal        = RandomGen.Next(-10, 10);
                                    PlayerGameScore += RandomVal;
                                    RandomVal        = RandomGen.Next(-2, 3);
                                    PlayerGameScore += Math.Round(Double.Parse(GetPlayerPoints(player)) / Double.Parse(GetPlayerGamesPlayed(player)), MidpointRounding.ToEven);
                                    PlayerGameScore += Math.Round(Double.Parse(GetPlayerAssist(player)) / Double.Parse(GetPlayerGamesPlayed(player)), MidpointRounding.ToEven);
                                    PlayerGameScore += Math.Round(Double.Parse(GetPlayerBlock(player)) / Double.Parse(GetPlayerGamesPlayed(player)), MidpointRounding.ToEven);
                                    PlayerGameScore += Math.Round(Double.Parse(GetPlayerSteal(player)) / Double.Parse(GetPlayerGamesPlayed(player)), MidpointRounding.ToEven);
                                    PlayerGameScore += Math.Round(Double.Parse(GetPlayerDefenceReb(player)) / Double.Parse(GetPlayerGamesPlayed(player)), MidpointRounding.ToEven);
                                    PlayerGameScore += Math.Round(Double.Parse(GetPlayerOffensiveReb(player)) / Double.Parse(GetPlayerGamesPlayed(player)), MidpointRounding.ToEven);
                                    PlayerGameScore += Math.Round(Double.Parse(GetPlayerFt(player)) / Double.Parse(GetPlayerGamesPlayed(player)), MidpointRounding.ToEven);
                                    PlayerGameScore -= Math.Round((Double.Parse(GetPlayerFieldGoalAtt(player)) - Double.Parse(GetPlayerFieldGoal(player))) / Double.Parse(GetPlayerGamesPlayed(player)), MidpointRounding.ToEven);
                                    PlayerGameScore -= Math.Round((Double.Parse(GetPlayerFtAtt(player)) - Double.Parse(GetPlayerFt(player))) / Double.Parse(GetPlayerGamesPlayed(player)), MidpointRounding.ToEven);
                                    PlayerGameScore -= Math.Round(Double.Parse(GetPlayerTurnover(player)) / Double.Parse(GetPlayerGamesPlayed(player)), MidpointRounding.ToEven);
                                    //foul out
                                    if (Math.Round((Double.Parse(GetPlayerPersFoul(player)) / Double.Parse(GetPlayerGamesPlayed(player))) + RandomVal, MidpointRounding.ToEven) >= 5)
                                    {
                                        PlayerGameScore -= 4;
                                    }
                                }
                                //below average
                                else if (RandomVal < 15)
                                {
                                    RandomVal        = RandomGen.Next(-10, 5);
                                    PlayerGameScore += RandomVal;
                                    RandomVal        = RandomGen.Next(-2, 3);
                                    PlayerGameScore += Math.Round((Double.Parse(GetPlayerPoints(player)) / Double.Parse(GetPlayerGamesPlayed(player)) * 0.75), MidpointRounding.ToEven);
                                    PlayerGameScore += Math.Round((Double.Parse(GetPlayerAssist(player)) / Double.Parse(GetPlayerGamesPlayed(player)) * 0.75), MidpointRounding.ToEven);
                                    PlayerGameScore += Math.Round((Double.Parse(GetPlayerBlock(player)) / Double.Parse(GetPlayerGamesPlayed(player)) * 0.75), MidpointRounding.ToEven);
                                    PlayerGameScore += Math.Round((Double.Parse(GetPlayerSteal(player)) / Double.Parse(GetPlayerGamesPlayed(player)) * 0.75), MidpointRounding.ToEven);
                                    PlayerGameScore += Math.Round((Double.Parse(GetPlayerDefenceReb(player)) / Double.Parse(GetPlayerGamesPlayed(player)) * 0.75), MidpointRounding.ToEven);
                                    PlayerGameScore += Math.Round((Double.Parse(GetPlayerOffensiveReb(player)) / Double.Parse(GetPlayerGamesPlayed(player)) * 0.75), MidpointRounding.ToEven);
                                    PlayerGameScore += Math.Round((Double.Parse(GetPlayerFt(player)) / Double.Parse(GetPlayerGamesPlayed(player)) * 0.75), MidpointRounding.ToEven);
                                    PlayerGameScore -= Math.Round(((Double.Parse(GetPlayerFieldGoalAtt(player)) - Double.Parse(GetPlayerFieldGoal(player))) / Double.Parse(GetPlayerGamesPlayed(player)) * 1.15), MidpointRounding.ToEven);
                                    PlayerGameScore -= Math.Round((Double.Parse(GetPlayerTurnover(player)) / Double.Parse(GetPlayerGamesPlayed(player)) * 1.15), MidpointRounding.ToEven);
                                    if (Math.Round((Double.Parse(GetPlayerPersFoul(player)) / Double.Parse(GetPlayerGamesPlayed(player))) + RandomVal, MidpointRounding.ToEven) >= 5)
                                    {
                                        PlayerGameScore -= 4;
                                    }
                                }
                                //above average
                                else if (RandomVal >= 85)
                                {
                                    RandomVal        = RandomGen.Next(-5, 15);
                                    PlayerGameScore += RandomVal;
                                    RandomVal        = RandomGen.Next(-2, 3);
                                    PlayerGameScore += Math.Round((Double.Parse(GetPlayerPoints(player)) / Double.Parse(GetPlayerGamesPlayed(player)) * 1.75), MidpointRounding.ToEven);
                                    PlayerGameScore += Math.Round((Double.Parse(GetPlayerAssist(player)) / Double.Parse(GetPlayerGamesPlayed(player)) * 1.75), MidpointRounding.ToEven);
                                    PlayerGameScore += Math.Round((Double.Parse(GetPlayerBlock(player)) / Double.Parse(GetPlayerGamesPlayed(player)) * 1.75), MidpointRounding.ToEven);
                                    PlayerGameScore += Math.Round((Double.Parse(GetPlayerSteal(player)) / Double.Parse(GetPlayerGamesPlayed(player)) * 1.75), MidpointRounding.ToEven);
                                    PlayerGameScore += Math.Round((Double.Parse(GetPlayerDefenceReb(player)) / Double.Parse(GetPlayerGamesPlayed(player)) * 1.75), MidpointRounding.ToEven);
                                    PlayerGameScore += Math.Round((Double.Parse(GetPlayerOffensiveReb(player)) / Double.Parse(GetPlayerGamesPlayed(player)) * 1.75), MidpointRounding.ToEven);
                                    PlayerGameScore += Math.Round((Double.Parse(GetPlayerFt(player)) / Double.Parse(GetPlayerGamesPlayed(player)) * 1.75), MidpointRounding.ToEven);
                                    PlayerGameScore -= Math.Round(((Double.Parse(GetPlayerFieldGoalAtt(player)) - Double.Parse(GetPlayerFieldGoal(player))) / Double.Parse(GetPlayerGamesPlayed(player)) * 0.75), MidpointRounding.ToEven);
                                    PlayerGameScore -= Math.Round((Double.Parse(GetPlayerTurnover(player)) / Double.Parse(GetPlayerGamesPlayed(player)) * 0.75), MidpointRounding.ToEven);
                                    if (Math.Round((Double.Parse(GetPlayerPersFoul(player)) / Double.Parse(GetPlayerGamesPlayed(player))) + RandomVal, MidpointRounding.ToEven) >= 5)
                                    {
                                        PlayerGameScore -= 4;
                                    }
                                }
                            }
                            //missing game
                            else
                            {
                                PlayerGameScore += 0;
                            }
                            //Console.WriteLine("{0}: {1}", PlayerName[player], PlayerGameScore);
                            teams.PlayersScores[indexX][indexY] = PlayerGameScore;
                            teams.WeekScore += PlayerGameScore;
                            PlayerGameScore  = 0;
                            indexX++;
                        }
                    }
                }
                WinnerMatch1 = (Teams.ElementAt(0).WeekScore < Teams.ElementAt(1).WeekScore) ? 1 : 0;
                WinnerMatch2 = (Teams.ElementAt(2).WeekScore < Teams.ElementAt(3).WeekScore) ? 3 : 2;
                winners.Add(Teams.ElementAt(WinnerMatch1).GetName() + " " + Teams.ElementAt(WinnerMatch2).GetName());
                foreach (LeaugeTeam team in Teams)
                {
                    if (WinnerMatch1 == Teams.IndexOf(team) || WinnerMatch2 == Teams.IndexOf(team))
                    {
                        team.Wins++;
                    }
                    else
                    {
                        team.Losses++;
                    }
                }
                Console.WriteLine("{0}: {1} vs. {2}: {3}", Teams.ElementAt(0).GetName(), Teams.ElementAt(0).WeekScore, Teams.ElementAt(1).GetName(), Teams.ElementAt(1).WeekScore);
                Console.WriteLine("{0}: {1} vs. {2}: {3}", Teams.ElementAt(2).GetName(), Teams.ElementAt(2).WeekScore, Teams.ElementAt(3).GetName(), Teams.ElementAt(3).WeekScore);
                Console.WriteLine("{0} wins with {1} points", Teams.ElementAt(WinnerMatch1).GetName(), Teams.ElementAt(WinnerMatch1).WeekScore);
                Console.WriteLine("{0} wins with {1} points", Teams.ElementAt(WinnerMatch2).GetName(), Teams.ElementAt(WinnerMatch2).WeekScore);
                int advance;
                advance = a_player.Menu(PlayerName, Teams);
                while (advance == 3)
                {
                    ShowStandings(Teams);
                    advance = a_player.Menu(PlayerName, Teams);
                }
                while (advance == 4)
                {
                    ShowSchedule();
                    advance = a_player.Menu(PlayerName, Teams);
                }
                while (advance == 5)
                {
                    ShowFreeAgents(a_player);
                    advance = a_player.Menu(PlayerName, Teams);
                }
                while (advance == 6)
                {
                    AskForTrade(a_player, a_CPU1, a_CPU2, a_CPU3);
                    advance = a_player.Menu(PlayerName, Teams);
                }
                foreach (LeaugeTeam teams in Teams)
                {
                    teams.WeekScore = 0;
                    for (int indexY = 0; indexY < 7; indexY++)
                    {
                        indexX = 0;
                        foreach (int player in teams.team)
                        {
                            teams.PlayersScores[indexX][indexY] = 0;
                            indexX++;
                        }
                    }
                }
            }
            ShowStandings(Teams);
            return(Champion);
        }