Example #1
0
        private void PoolsQuarterSeed_Click(object sender, RoutedEventArgs e)
        {
            // Don't do anything if there are already data
            RoundData rd = tournamentData.GetRound(poolsDivision, ERound.Quarterfinals);

            foreach (PoolData pd in rd.pools)
            {
                if (pd.teamList.teams.Count > 0)
                {
                    return;
                }
            }

            // Seed the first 24 teams like normal
            List <TeamData> byeTeams = new List <TeamData>();

            for (int i = 0; i < poolsAllTeamsForDivision.Count() && i < 24; ++i)
            {
                byeTeams.Add(poolsAllTeamsForDivision[i]);
            }
            FillPoolTeams(poolsDivision, ERound.Quarterfinals, byeTeams);

            // Take the top 8 from prelims
            List <TeamData> prelimMadeCutTeams = new List <TeamData>();
            RoundData       prelimData         = tournamentData.GetRound(poolsDivision, ERound.Prelims);
            int             prelimPoolIndex    = 0;
            int             prelimRank         = 1;

            for (int teamCount = 0; teamCount < 8; ++teamCount)
            {
                if (prelimPoolIndex >= prelimData.pools.Count)
                {
                    // Error, something is wrong
                    break;
                }

                int teamIndex = GetRankTeamIndex(prelimData.pools[prelimPoolIndex].resultRank, prelimRank);
                if (teamIndex < 0)
                {
                    // Ran out of prelim teams
                    break;
                }

                prelimMadeCutTeams.Add(prelimData.pools[prelimPoolIndex].teamList.teams[teamIndex]);

                if (prelimPoolIndex + 1 < prelimData.pools.Count)
                {
                    ++prelimPoolIndex;
                }
                else
                {
                    prelimPoolIndex = 0;
                    ++prelimRank;
                }
            }

            FillPoolTeams(poolsDivision, ERound.Quarterfinals, prelimMadeCutTeams, false);
        }
Example #2
0
        public void SetRoutineLength(ERound inRound, ERoutineLength length)
        {
            RoundData rd = GetRoundData(inRound);

            if (rd != null)
            {
                rd.routineLength = RoutineLengthToFloat(length);
            }
        }
Example #3
0
        private void FillPoolTeams(EDivision division, ERound round, List <TeamData> teams, bool bClearPreviousTeams)
        {
            int       rawPoolIndex      = 0;
            int       adjustedPoolIndex = 0;
            bool      bReversePoolAssignmentDirection = false;
            RoundData rd           = tournamentData.GetRound(division, round);
            int       maxPoolCount = rd.pools.Count;

            if (bClearPreviousTeams)
            {
                for (int poolIndex = 0; poolIndex < maxPoolCount; ++poolIndex)
                {
                    PoolData pd = tournamentData.GetPool(division, round, (EPool)poolIndex);
                    pd.teamList.teams.Clear();
                }
            }

            for (int teamIndex = 0; teamIndex < teams.Count; ++teamIndex)
            {
                if (rawPoolIndex >= maxPoolCount)
                {
                    bReversePoolAssignmentDirection = !bReversePoolAssignmentDirection;
                    rawPoolIndex = 0;

                    if (bReversePoolAssignmentDirection)
                    {
                        adjustedPoolIndex = maxPoolCount - 1;
                    }
                    else
                    {
                        adjustedPoolIndex = 0;
                    }
                }

                PoolData pd = tournamentData.GetPool(division, round, (EPool)adjustedPoolIndex);
                pd.teamList.teams.Add(teams[teamIndex]);

                if (bReversePoolAssignmentDirection)
                {
                    --adjustedPoolIndex;
                }
                else
                {
                    ++adjustedPoolIndex;
                }
                ++rawPoolIndex;
            }

            // Reverse the teams in the pool so first play is at the top
            foreach (PoolData pd in rd.pools)
            {
                pd.teamList.teams = new ObservableCollection <TeamData>(pd.teamList.teams.Reverse());
            }

            PoolsUpdateBindings();
        }
Example #4
0
        public ERoutineLength GetRoutineLength(ERound inRound)
        {
            RoundData rd = GetRoundData(inRound);

            if (rd != null)
            {
                return(RoutineLengthFromFloat(rd.routineLength));
            }

            return(ERoutineLength.None);
        }
Example #5
0
        public RoundData GetRoundData(ERound inRound)
        {
            RoundData rd = parentWindow.tournamentData.GetRound(division, inRound);

            if (rd != null)
            {
                return(rd);
            }

            return(null);
        }
Example #6
0
        void ImportDivisionData(TournamentData importedData, XmlNode node, EDivision division)
        {
            DivisionData divisionData = new DivisionData(division);

            foreach (XmlNode roundNode in node.ChildNodes)             // Rounds
            {
                ERound round = ERound.Finals;
                foreach (XmlNode roundDataNode in roundNode.ChildNodes)
                {
                    RoundData roundData = new RoundData(division, round);
                    EPool     pool      = EPool.A;
                    foreach (XmlNode poolDataNode in roundDataNode.FirstChild.ChildNodes)                     // Pools
                    {
                        PoolData poolData = new PoolData(pool);
                        foreach (XmlNode poolDataChildNode in poolDataNode.ChildNodes)
                        {
                            if (poolDataChildNode.Name == "PoolName")
                            {
                                poolData.pool = (EPool)Enum.Parse(typeof(EPool), poolDataChildNode.FirstChild.Value);
                            }
                            else if (poolDataChildNode.Name == "Teams")
                            {
                                ImportTeams(importedData, divisionData, poolData, poolDataChildNode);
                                ImportJudges(importedData, divisionData, poolData, poolDataChildNode);
                            }
                            else if (poolDataChildNode.Name == "ResultsByTeamIndex")
                            {
                                ImportPoolResults(poolData, poolDataChildNode);
                            }
                        }

                        roundData.pools.Add(poolData);

                        ++pool;
                    }

                    divisionData.rounds.Add(roundData);

                    ++round;
                }
            }

            importedData.divisions.Add(divisionData);
        }
Example #7
0
        private void PoolsRandomizePlayOrder(EDivision division, ERound round)
        {
            RoundData rd = tournamentData.GetRound(poolsDivision, round);

            foreach (PoolData pd in rd.pools)
            {
                ObservableCollection <TeamData> teams       = pd.teamList.teams;
                ObservableCollection <TeamData> newTeamList = new ObservableCollection <TeamData>();
                while (teams.Count > 0)
                {
                    int pickIndex = random.Next(0, teams.Count());
                    newTeamList.Add(teams[pickIndex]);
                    teams.RemoveAt(pickIndex);
                }

                pd.teamList.teams = newTeamList;
            }

            PoolsUpdateBindings();
        }
Example #8
0
        private void SeedPrelimPools(EDivision division, int numPools)
        {
            RoundData rd = tournamentData.GetRound(division, ERound.Prelims);

            rd.pools.Clear();
            for (int i = 0; i < numPools; ++i)
            {
                rd.pools.Add(new PoolData((EPool)i));
            }

            // Only seed teams 25-40 in prelims
            List <TeamData> teams = new List <TeamData>();

            for (int i = 24; i < poolsAllTeamsForDivision.Count() && i < 40; ++i)
            {
                teams.Add(poolsAllTeamsForDivision[i]);
            }

            PrelimAPoolItemsControl.SetItemsSource(tournamentData.GetPool(poolsDivision, ERound.Prelims, EPool.A));

            if (numPools > 1)
            {
                PrelimBPoolItemsControl.SetItemsSource(tournamentData.GetPool(poolsDivision, ERound.Prelims, EPool.B));
            }
            if (numPools > 2)
            {
                PrelimCPoolItemsControl.SetItemsSource(tournamentData.GetPool(poolsDivision, ERound.Prelims, EPool.C));
            }
            if (numPools > 3)
            {
                PrelimDPoolItemsControl.SetItemsSource(tournamentData.GetPool(poolsDivision, ERound.Prelims, EPool.D));
            }


            FillPoolTeams(poolsDivision, poolsRound, teams);
        }
Example #9
0
        public void Init()
        {
            if (divisions.Count == 0)
            {
                for (int i = 0; i < (int)EDivision.Max; ++i)
                {
                    DivisionData dd = new DivisionData((EDivision)i);
                    dd.CreateData();
                    divisions.Add(dd);
                }
            }
            else
            {
                for (EDivision division = EDivision.Open; division < EDivision.Max; ++division)
                {
                    if ((int)division < divisions.Count)
                    {
                        DivisionData dd = divisions[(int)division];

                        if (dd.division == EDivision.None)
                        {
                            dd.division = division;
                        }

                        for (ERound round = ERound.Finals; round < ERound.Max; ++round)
                        {
                            if ((int)round < dd.rounds.Count)
                            {
                                RoundData rd = dd.rounds[(int)round];
                                if (rd.round == ERound.None || rd.round == ERound.Max)
                                {
                                    rd.round = round;
                                }

                                if (rd.maxTeams == 0)
                                {
                                    rd.InitMaxTeams(division, round);
                                }

                                int poolCount = GetPoolCount(round);
                                for (EPool pool = EPool.A; (int)pool < poolCount; ++pool)
                                {
                                    if ((int)pool < rd.pools.Count)
                                    {
                                        PoolData pd = rd.pools[(int)pool];

                                        if (pd.pool == EPool.None)
                                        {
                                            pd.pool = pool;
                                        }
                                    }
                                    else
                                    {
                                        PoolData pd = new PoolData(pool);
                                        pd.CreateData();
                                        rd.pools.Add(pd);
                                    }
                                }
                            }
                            else
                            {
                                RoundData rd = new RoundData(division, round);
                                rd.CreateData();
                                dd.rounds.Add(rd);
                            }
                        }
                    }
                    else
                    {
                        DivisionData dd = new DivisionData(division);
                        dd.CreateData();
                        divisions.Add(dd);
                    }
                }
            }
        }