Пример #1
0
        /// <summary>
        /// Spielt die Matches des Loser Brackets
        /// </summary>
        private void PlayLoserBracket()
        {
            var           loserRound   = new TournamentBracketLogRound(1);
            List <Player> doubleLosers = new List <Player>();

            for (int i = 0; i < Losers.Count - 1; i += 2)
            {
                if (Losers[i].PlayerID.Id == 0 && Losers[i + 1].PlayerID.Id == 0) // prüfen ob beides WildCards sind
                {
                    doubleLosers.Add(Losers[i]);
                    loserRound.AddMatch(Losers[i].ToString(), Losers[i + 1].ToString(), false);
                }
                else if ((Losers[i].PlayerID.Id == 0 || Losers[i + 1].PlayerID.Id == 0)) // prüfen ob im Match eine Wildcard vorhanden ist
                {
                    if (Losers[i].PlayerID.Id == 0)
                    {
                        doubleLosers.Add(Losers[i]);
                        loserRound.AddMatch(Losers[i].ToString(), Losers[i + 1].ToString(), false);
                    }
                    else
                    {
                        doubleLosers.Add(Losers[i + 1]);
                        loserRound.AddMatch(Losers[i].ToString(), Losers[i + 1].ToString(), true);
                    }
                }
                else
                {
                    Console.WriteLine("Who is the Winner?");
                    Console.WriteLine(Losers[i].ToString() + " Or " + Losers[i + 1].ToString());
                    bool correctPlayerInput = false;
                    while (!correctPlayerInput)
                    {
                        string whoWonInput = Console.ReadLine();
                        if (whoWonInput == Losers[i].PlayerName.Title || whoWonInput == Losers[i].PlayerID.ToString())
                        {
                            Console.WriteLine("You Choose: " + Losers[i].ToString());
                            doubleLosers.Add(Losers[i + 1]);
                            correctPlayerInput = true;
                        }
                        else if (whoWonInput == Losers[i + 1].PlayerName.Title || whoWonInput == Losers[i + 1].PlayerID.ToString())
                        {
                            Console.WriteLine("You Choose: " + Losers[i + 1].ToString());
                            doubleLosers.Add(Losers[i]);
                            correctPlayerInput = true;
                        }
                        else
                        {
                            Console.WriteLine("Wrong Input! Try Again.");
                        }
                        if (correctPlayerInput)
                        {
                            loserRound.AddMatch(Losers[i].ToString(), Losers[i + 1].ToString(), whoWonInput == Losers[i].PlayerName.Title || whoWonInput == Losers[i].PlayerID.ToString());
                        }
                        Console.WriteLine();
                    }
                }
            }

            EliminateLosingPlayers(doubleLosers);
            TournamentDoubleKoLog.LoserRounds.Add(loserRound);

            // Für 16 Spieler muss an der Stelle nochmals Loser Bracket gespielt werden und dann erst wieder Winner
            if (Winners.Count == 4 && Losers.Count == 4)
            {
                Console.Clear();
                Console.WriteLine(CreateTree(Losers, "Losing Bracket"));
                PlayLoserBracket();
            }
        }
Пример #2
0
        /// <summary>
        /// startet Doppel Ko System mit dem Winning Bracket
        /// </summary>
        public void StartElimination()
        {
            Console.WriteLine(CreateTree(Winners, "Winning Bracket"));
            Console.WriteLine("Elimination starts!");
            int round = 1;

            while (Winners.Count > 1)
            {
                Console.WriteLine("Next Round!");
                var           winnerRound = new TournamentBracketLogRound(round);
                List <Player> losers      = new List <Player>();
                for (int i = 0; i < Winners.Count - 1; i += 2)
                {
                    if (Winners[i].PlayerID.Id == 0 || Winners[i + 1].PlayerID.Id == 0) // prüfen ob im Match eine Wildcard vorhanden ist
                    {
                        if (Winners[i].PlayerID.Id == 0)
                        {
                            losers.Add(Winners[i]);
                            winnerRound.AddMatch(Winners[i].ToString(), Winners[i + 1].ToString(), false);
                        }
                        else
                        {
                            losers.Add(Winners[i + 1]);
                            winnerRound.AddMatch(Winners[i].ToString(), Winners[i + 1].ToString(), false);
                        }
                    }
                    else
                    {
                        Console.WriteLine("Who is the Winner?");
                        Console.WriteLine(Winners[i].ToString() + " Or " + Winners[i + 1].ToString());
                        bool correctPlayerInput = false;
                        while (!correctPlayerInput)
                        {
                            string whoWonInput = Console.ReadLine();
                            if (whoWonInput == Winners[i].PlayerName.Title || whoWonInput == Winners[i].PlayerID.ToString())
                            {
                                Console.WriteLine("You Choose: " + Winners[i].ToString());
                                losers.Add(Winners[i + 1]);
                                correctPlayerInput = true;
                            }
                            else if (whoWonInput == Winners[i + 1].PlayerName.Title || whoWonInput == Winners[i + 1].PlayerID.ToString())
                            {
                                Console.WriteLine("You Choose: " + Winners[i + 1].ToString());
                                losers.Add(Winners[i]);
                                correctPlayerInput = true;
                            }
                            else
                            {
                                Console.WriteLine("Wrong Input! Try Again.");
                            }
                            if (correctPlayerInput)
                            {
                                winnerRound.AddMatch(Winners[i].ToString(), Winners[i + 1].ToString(), whoWonInput == Winners[i].PlayerName.Title || whoWonInput == Winners[i].PlayerID.ToString());
                            }
                            Console.WriteLine();
                        }
                    }
                }

                // Sondersitation, damit nicht 3 Spieler im Loser übrig bleiben
                if (Winners.Count == 2)
                {
                    Console.Clear();
                    Console.WriteLine(CreateTree(Losers, "Losing Bracket"));
                    PlayLoserBracket();
                }

                MoveLosingPlayers(losers);
                Console.Clear();
                Console.WriteLine(CreateTree(Losers, "Losing Bracket"));
                PlayLoserBracket();

                round++;
                TournamentDoubleKoLog.WinnerRounds.Add(winnerRound);

                Console.Clear();
                if (Winners.Count > 1)
                {
                    Console.WriteLine(CreateTree(Winners, "Winning Bracket"));
                }
            }

            Console.Clear();
            PlayFinale(Winners[0], Losers[0]);
            CreateLogOfTournament(log, true);
        }
Пример #3
0
        public void StartElimination()
        {
            Console.WriteLine(CreateTree(Players));
            Console.WriteLine("Elimination starts!");
            int round = 1;

            while (Players.Count != 1)
            {
                Console.WriteLine("Next Round!");
                var           tournamentBracketLogRound = new TournamentBracketLogRound(round);
                List <Player> losers = new List <Player>();
                for (int i = 0; i < Players.Count - 1; i += 2)
                {
                    if (Players[i].PlayerID.Id == 0 || Players[i + 1].PlayerID.Id == 0) // prüfen ob im Match eine Wildcard vorhanden ist
                    {
                        if (Players[i].PlayerID.Id == 0)
                        {
                            losers.Add(Players[i]);
                            tournamentBracketLogRound.AddMatch(Players[i].ToString(), Players[i + 1].ToString(), false);
                        }
                        else
                        {
                            losers.Add(Players[i + 1]);
                            tournamentBracketLogRound.AddMatch(Players[i].ToString(), Players[i + 1].ToString(), true);
                        }
                    }
                    else
                    {
                        Console.WriteLine("Who is the Winner? Name or ID");
                        Console.WriteLine(Players[i].ToString() + " Or " + Players[i + 1].ToString());
                        bool correctPlayerInput = false;
                        while (!correctPlayerInput)
                        {
                            string whoWonInput = Console.ReadLine();
                            if (whoWonInput == Players[i].PlayerName.Title || whoWonInput == Players[i].PlayerID.ToString())
                            {
                                Console.WriteLine("You Choose: " + Players[i].ToString());
                                losers.Add(Players[i + 1]);
                                correctPlayerInput = true;
                            }
                            else if (whoWonInput == Players[i + 1].PlayerName.Title || whoWonInput == Players[i + 1].PlayerID.ToString())
                            {
                                Console.WriteLine("You Choose: " + Players[i + 1].ToString());
                                losers.Add(Players[i]);
                                correctPlayerInput = true;
                            }
                            else
                            {
                                Console.WriteLine("Wrong Input! Try Again.");
                            }
                            if (correctPlayerInput)
                            {
                                tournamentBracketLogRound.AddMatch(Players[i].ToString(), Players[i + 1].ToString(), whoWonInput == Players[i].PlayerName.Title || whoWonInput == Players[i].PlayerID.ToString());
                            }
                            Console.WriteLine();
                        }
                    }
                }

                EliminateLosingPlayers(losers);
                round++;
                TournamentBracketLog.Rounds.Add(tournamentBracketLogRound);

                if (Players.Count != 1)
                {
                    Console.Clear();
                    Console.WriteLine(CreateTree(Players));
                }
            }
            Console.Clear();
            Console.WriteLine("Winner of the Tournament: " + Players[0].ToString());
            log.AddEntry("Winner: " + Players[0].ToString());
            CreateLogOfTournament(log);
        }