Пример #1
0
        public void GenerateTournamentTree()
        {
            SingleEliminationGames = new List <MatchNode>();

            SingleEliminationFinal = GenerateMatchNode();

            ConnectLeafNodesToMatch(SingleEliminationFinal);

            while (DoMerge())
            {
            }

            if (SingleEliminationTeamEntryPoints.Count >= 2)
            {
                EndNode firstPlace  = new EndNode();
                EndNode SecondPlace = new EndNode();


                firstPlace.AddFinalist(SingleEliminationFinal, MatchOutcome.OneVsOneWinner);
                SecondPlace.AddFinalist(SingleEliminationFinal, MatchOutcome.OneVsOneLooser);
                SingleEliminationPlacements.Add(firstPlace);
                SingleEliminationPlacements.Add(SecondPlace);
            }
            if (SingleEliminationTeamEntryPoints.Count >= 4)
            {
                EndNode ThirdPlace  = new EndNode();
                EndNode FourthPlace = new EndNode();

                List <FinalistData> finalistData = SingleEliminationFinal.GetFinalists();

                if (finalistData.Count > 1)
                {
                    MatchNode thirdPlaceFianl = GenerateMatchNode();
                    thirdPlaceFianl.AddFinalist(
                        finalistData[0].GetNode(),
                        MatchOutcome.OneVsOneLooser);
                    thirdPlaceFianl.AddFinalist(
                        finalistData[1].GetNode(),
                        MatchOutcome.OneVsOneLooser);
                    thirdPlaceFianl.SetName("Third place final");
                    SingleEliminationThirdPlaceFinal = thirdPlaceFianl;

                    ThirdPlace.AddFinalist(thirdPlaceFianl, MatchOutcome.OneVsOneWinner);
                    FourthPlace.AddFinalist(thirdPlaceFianl, MatchOutcome.OneVsOneLooser);
                    SingleEliminationPlacements.Add(ThirdPlace);
                    SingleEliminationPlacements.Add(FourthPlace);
                    SingleEliminationGames.Add(thirdPlaceFianl);
                }
            }

            foreach (var v in SingleEliminationGames)
            {
                v.SetName("Third place Final");
            }

            SingleEliminationFinal.SetName("Final");
            SingleEliminationGames.Add(SingleEliminationFinal);

            RenameNodes();
        }