예제 #1
0
        public static List <Qualification> AdjustQualificationsToNotPromoteReserves(List <Qualification> initialQualifications, List <Club> ranking, Tournament from)
        {
            List <Qualification> qualifications = new List <Qualification>(initialQualifications);

            for (int i = 0; i < qualifications.Count; i++)
            {
                qualifications.Sort(new QualificationComparator());
                Qualification q             = qualifications[i];
                Club          concernedClub = ranking[q.ranking - 1];
                bool          ok            = RuleIsRespected(concernedClub, q, from.level);
                int           j             = i;
                if (from.isChampionship)
                {
                    while (!ok)
                    {
                        int           tempValue = qualifications[j].ranking;
                        Qualification first     = qualifications[j];
                        Qualification second    = qualifications[j + 1];
                        first.ranking         = qualifications[j + 1].ranking;
                        second.ranking        = tempValue;
                        qualifications[j]     = first;
                        qualifications[j + 1] = second;
                        ok = RuleIsRespected(concernedClub, qualifications[j], from.level);
                        j++;
                    }
                }
            }

            /*
             * for (int j = 0; j < qualifications.Count; j++)
             * {
             *  Qualification q = qualifications[j];
             *  //If the two tournaments involved are championship and the level of the destination is higher in league structure than the current league
             *  if (from.isChampionship && q.tournament.isChampionship && q.tournament.level < from.level)
             *  {
             *      int offset = 0;
             *      bool pursue = true;
             *      while (pursue && j + offset < qualifications.Count)
             *      {
             *          //This is a reserve club so it must not be promoted
             *          if (ranking[q.ranking - 1 + offset] as ReserveClub != null)
             *          {
             *              offset++;
             *          }
             *          else
             *          {
             *              pursue = false;
             *              //If there is an offset, make a swap
             *              if (offset > 0)
             *              {
             *                  Qualification first = qualifications[j];
             *                  Qualification second = qualifications[j + offset];
             *                  int tempRanking = second.ranking;
             *                  second.ranking = first.ranking;
             *                  first.ranking = tempRanking;
             *                  qualifications[j] = second;
             *                  qualifications[j + offset] = first;
             *              }
             *          }
             *      }
             *  }
             * }*/

            return(qualifications);
        }
예제 #2
0
 public static string LogoTournament(Tournament tournament)
 {
     return(System.IO.Directory.GetCurrentDirectory() + "\\" + Utils.imagesFolderName + "\\" + Utils.tournamentLogoFolderName + "\\" + tournament.logo + ".png");
 }