示例#1
0
        /// <summary>
        /// Creates next rounds after the first one
        /// </summary>
        /// <param name="tournament"></param>
        /// <param name="rounds">Total number of rounds</param>
        private static void CreateOtherRounds(TournamentModel tournament, int rounds)
        {
            // Set next number of round, is 2
            int round = 2;

            // Previous round is the first element in a list
            // because it is the first round of a tournament
            List <MatchUpModel> previousRound = tournament.Rounds[0];

            // current match up will be added to the current list of matches of current round
            MatchUpModel currentMatchUp = new MatchUpModel();

            // List of matches in the current round
            List <MatchUpModel> currRound = new List <MatchUpModel>();

            while (round <= rounds)
            {
                // Loop through each game in a prev round
                foreach (MatchUpModel match in previousRound)
                {
                    currentMatchUp.Entries.Add(new MatchupEntryModel {
                        ParentMatchUp = match
                    });

                    if (currentMatchUp.Entries.Count > 1)
                    {
                        currentMatchUp.MatchUpRound = round;
                        currRound.Add(currentMatchUp);
                        currentMatchUp = new MatchUpModel();
                    }
                }

                round++;
                tournament.Rounds.Add(currRound);
                previousRound = currRound;

                currRound = new List <MatchUpModel>();
            }
        }
示例#2
0
 private static void AdvancedWinner(List <MatchUpModel> models, TournamentModel tournament)
 {
     foreach (MatchUpModel m in models)
     {
         foreach (List <MatchUpModel> round in tournament.Rounds)
         {
             foreach (MatchUpModel rm in round)
             {
                 foreach (MatchupEntryModel entry in rm.Entries)
                 {
                     if (entry.ParentMatchUp != null)
                     {
                         if (entry.ParentMatchUp.Id == m.Id)
                         {
                             entry.TeamCompeting = m.Winner;
                             GlobalConfig.Connection.UpdateMatchUp(rm);
                         }
                     }
                 }
             }
         }
     }
 }