Beispiel #1
0
        public static void CreateNewLeague()
        {
            _scoreboard = new Scoreboard();
            List <Contestant> newPlayers = new List <Contestant>();

            var count = ConsoleWorker.GetNumberOfPlayers();

            for (int i = 0; i < count; i++)
            {
                var newPlayer = new Contestant(ConsoleWorker.GetPlayerName(), 0);
                newPlayers.Add(newPlayer);
            }

            Randomize(ref newPlayers);

            List <Contestant> newPlayersRandomized = new List <Contestant>();

            foreach (var contestant in newPlayers)
            {
                var newPlayer = new Contestant(contestant.Name, _scoreboard.CurrentPlayerPosition);
                _scoreboard.CurrentPlayerPosition += newPlayer.Name.Length + 1;
                newPlayersRandomized.Add(newPlayer);
            }

            EndRound(newPlayersRandomized);
        }
Beispiel #2
0
 private static List <Match> ChooseWinnerOfMatchesInGrid(List <Match> matchesInGrid)
 {
     foreach (var match in matchesInGrid)
     {
         bool firstPlayerChosen = ConsoleWorker.ChooseMatchWinner(match) == 1;
         match.SetWinner(firstPlayerChosen ? 1 : 2);
     }
     return(matchesInGrid);
 }
Beispiel #3
0
        private static void Main()
        {
            _leagueType = ConsoleWorker.ChooseLeagueType() == 1 ? LeagueType.SingleElumination : LeagueType.DoubleElumination;

            while (true)
            {
                ConsoleWorker.Menu();
                bool successfulOperation = false;
                while (!successfulOperation)
                {
                    successfulOperation = RunChoice() != 0;
                }
            }
        }
Beispiel #4
0
 public static bool CheckPlayerNumber()
 {
     if (_currentPlayersGrid1.Count == 1 && _currentPlayersGrid2.Count == 0 ||
         _currentPlayersGrid1.Count == 0 && _currentPlayersGrid2.Count == 1)
     {
         ConsoleWorker.OnePlayerLeft();
         return(false);
     }
     if (_currentPlayersGrid1.Count == 0 && _currentPlayersGrid2.Count == 0)
     {
         ConsoleWorker.NoPlayersLeft();
         return(false);
     }
     return(true);
 }
Beispiel #5
0
        public static int RunChoice()
        {
            var choice = ConsoleWorker.MenuChoice();

            switch (choice)
            {
            case "1":
            {
                CreateNewLeague();
                break;
            }

            case "2":
            {
                if (!CheckPlayerNumber())
                {
                    break;
                }
                ChooseWinners();
                break;
            }

            case "3":
            {
                _scoreboard.Print();
                break;
            }

            case "4":
            {
                Environment.Exit(0);
                break;
            }

            default:
            {
                ConsoleWorker.IncorrectMenuChoice();
                ConsoleWorker.Menu();
                return(0);
            }
            }
            return(1);
        }
Beispiel #6
0
 public void Print()
 {
     ConsoleWorker.PrintScoreboard(_matchResultsDisplayGrid1, _matchResultsDisplayGrid2);
 }