public bool CreateTeams1s()
        {
            //By default we're generating teams for 2s

            List <Player> tempPlayers = new List <Player>();

            foreach (Player p in _players)
            {
                tempPlayers.Add(p);
            }

            _teams.Clear();

            while (tempPlayers.Count > 0)
            {
                Team1s t = new Team1s();
                t.ID      = _teams.Count;
                t.Player1 = tempPlayers.First();
                t.Captain = t.Player1;

                //Remove the entires
                tempPlayers.RemoveAt(0);

                _teams.Add(t);
            }

            return(true);
        }
Exemplo n.º 2
0
        public void Populate(List <Team> teams)
        {
            //Check if there are enough teams for the bracket
            List <Team> teamsTemp = new List <Team>();

            foreach (Team t in teams)
            {
                teamsTemp.Add(t);
            }


            while (teamsTemp.Count < BracketRequiredTeams)
            {
                //Add random Teams
                if (teams[0] is Team2s)
                {
                    Team2s t = new Team2s();
                    t.ID      = -1;
                    t.IsDummy = true;
                    teamsTemp.Add(t);
                }
                else if (teams[0] is Team1s)
                {
                    Team1s t = new Team1s();
                    t.ID      = -1;
                    t.IsDummy = true;
                    teamsTemp.Add(t);
                }
                else if (teams[0] is Team3s)
                {
                    Team3s t = new Team3s();
                    t.ID      = -1;
                    t.IsDummy = true;
                    teamsTemp.Add(t);
                }
                else
                {
                    Console.WriteLine("Not Supported");
                }
            }

            Round       first_round  = Rounds[0];
            Random      rnd          = new Random();
            List <Team> randTeamList = teamsTemp.Select(x => new { value = x, order = rnd.Next() })
                                       .OrderBy(x => x.order).Select(x => x.value).ToList();

            int team_index = 0;

            foreach (Matchup match in first_round.Matchups)
            {
                match.Team1 = randTeamList[team_index];
                match.Team2 = randTeamList[team_index + 1];
                team_index += 2;
            }

            FindEarlyWinners();
        }