Esempio n. 1
0
        public void RemoveSportsCategoryPlayed(SportsMatchCategory category)
        {
            // Update amount of sports played if this sport was only played once
            if (this.SportsCategoryCounts[category] == 1)
            {
                AmountOfSportsPlayed--;
                UpdateSportsCoveragePenalty();
            }

            this.SportsCategoryCounts[category]--;

            // If this category was the most played one, we may have to find a new largest element
            if (category == _maxPlayedCategory)
            {
                UpdateMostPlayedCategory();
            }

            int newCount = this.SportsCategoryCounts[category];

            if (newCount < _minSportsPlayedCount)
            {
                _minSportsPlayedCount = newCount;
                _minPlayedCategory    = category;
            }

            this.UpdateSportImbalance();
        }
Esempio n. 2
0
        /// <summary>
        /// Updates the variety penalty for the singles or doubles counterpart of a category that has just been added or
        /// removed.
        /// </summary>
        /// <param name="match"></param>
        /// <param name="added"></param>
        public void UpdateVarietyPenaltyForSimilarCategories(SportsMatch match, bool added)
        {
            // If a category's counterpart has just been added/removed, consider it when updating the variety penalty
            // e.g. if a badminton match has just been added, check the badmintonDoubles category for duplicates as well
            SportsMatchCategory cat = match.MatchType;

            switch (cat)
            {
            case SportsMatchCategory.Badminton:
                UpdateVarietyPenaltyAfterMatchUpdate(SportsMatchCategory.BadmintonDoubles, added);
                break;

            case SportsMatchCategory.BadmintonDoubles:
                UpdateVarietyPenaltyAfterMatchUpdate(SportsMatchCategory.Badminton, added);
                break;

            case SportsMatchCategory.TableTennis:
                UpdateVarietyPenaltyAfterMatchUpdate(SportsMatchCategory.TableTennisDoubles, added);
                break;

            case SportsMatchCategory.TableTennisDoubles:
                UpdateVarietyPenaltyAfterMatchUpdate(SportsMatchCategory.TableTennis, added);
                break;
            }
        }
Esempio n. 3
0
        public void AddSportsCategoryPlayed(SportsMatchCategory category)
        {
            // Update amount of sports played if this is the first time this sport is played by this team
            if (this.SportsCategoryCounts[category] == 0)
            {
                AmountOfSportsPlayed++;
                UpdateSportsCoveragePenalty();
            }

            this.SportsCategoryCounts[category]++;

            // If this category was the least played one, we may have to find a new smallest element
            if (category == _minPlayedCategory)
            {
                UpdateLeastPlayedCategory();
            }

            // Update _maxSportsPlayedCount if this category is now played more than any other category
            int newCount = this.SportsCategoryCounts[category];

            if (newCount > _maxSportsPlayedCount)
            {
                _maxSportsPlayedCount = newCount;
                _maxPlayedCategory    = category;
            }

            this.UpdateSportImbalance();
        }
Esempio n. 4
0
 public ScheduleTeamStatistics(int[] roundPlayerCounts, int[] eventsPerRound, int sportImbalance,
                               int maxSportsPlayedCount, SportsMatchCategory maxPlayedCategory, int minSportsPlayedCount,
                               SportsMatchCategory minPlayedCategory, Dictionary <SportsMatchCategory, int> sportsCategoryCounts,
                               int[] matchUpCountsVersusTeams, int breaks, int amountOfTeamsPlayed, int amountOfSportsPlayed,
                               int teamCoveragePenalty, int sportsCoveragePenalty, int sportsToPlay, int teamsToPlay,
                               int roundPlayerLimitPenalty)
 {
     RoundPlayerCounts        = roundPlayerCounts;
     EventsPerRound           = eventsPerRound;
     SportImbalance           = sportImbalance;
     _maxSportsPlayedCount    = maxSportsPlayedCount;
     _maxPlayedCategory       = maxPlayedCategory;
     _minSportsPlayedCount    = minSportsPlayedCount;
     _minPlayedCategory       = minPlayedCategory;
     SportsCategoryCounts     = sportsCategoryCounts;
     MatchUpCountsVersusTeams = matchUpCountsVersusTeams;
     Breaks = breaks;
     AmountOfTeamsPlayed      = amountOfTeamsPlayed;
     AmountOfSportsPlayed     = amountOfSportsPlayed;
     TeamCoveragePenalty      = teamCoveragePenalty;
     SportsCoveragePenalty    = sportsCoveragePenalty;
     _sportsToPlay            = sportsToPlay;
     _teamsToPlay             = teamsToPlay;
     _roundPlayerLimitPenalty = roundPlayerLimitPenalty;
 }
Esempio n. 5
0
 public void UpdateVarietyPenaltyAfterMatchRemoval(SportsMatchCategory category)
 {
     // Decrease the variety penalty if there were duplicate sport categories in this event
     if (_categoryCounts[category] > 1)
     {
         this.VarietyPenalty--;
     }
 }
Esempio n. 6
0
 public void UpdateVarietyPenaltyAfterMatchAddition(SportsMatchCategory category)
 {
     // Increase the variety penalty if this event will now have (even more) duplicate sport categories
     if (_categoryCounts[category] > 0)
     {
         this.VarietyPenalty++;
     }
 }
Esempio n. 7
0
        public void UpdateRequiredRefereeAmount(SportsMatchCategory category, bool added)
        {
            int modification = added ? 1 : -1;

            if (Globals.MatchTypesRequiringReferee.Contains(category))
            {
                this.RefereesRequired += modification;
            }
        }
Esempio n. 8
0
        public SportsMatch(SportsMatchCategory matchType, int playersPerTeam, int minPlayers = 1, int maxPlayers = 8,
                           bool refereeRequired = false)
        {
            this.MatchType      = matchType;
            this.PlayersPerTeam = playersPerTeam;

            this.LowerPlayerLimit = minPlayers;
            this.UpperPlayerLimit = maxPlayers;

            this.RefereeRequired = refereeRequired;
        }
Esempio n. 9
0
 public void UpdateVarietyPenaltyAfterMatchUpdate(SportsMatchCategory category, bool added)
 {
     if (added)
     {
         UpdateVarietyPenaltyAfterMatchAddition(category);
     }
     else
     {
         UpdateVarietyPenaltyAfterMatchRemoval(category);
     }
 }
Esempio n. 10
0
        public bool ModifyPlayerAssignmentIfWithinLimit(SportsMatchCategory category, int modification)
        {
            int  newAmount       = PlayersPerMatchType[category] + modification;
            bool legalAssignment = newAmount <= Globals.MatchTypePlayerLimitsPerTeam[category];

            if (legalAssignment)
            {
                PlayersPerMatchType[category] = newAmount;
            }

            return(legalAssignment);
        }
Esempio n. 11
0
        private void UpdateMostPlayedCategory()
        {
            int largest = -1;

            foreach (KeyValuePair <SportsMatchCategory, int> pair in SportsCategoryCounts)
            {
                if (pair.Value > largest)
                {
                    _maxSportsPlayedCount = pair.Value;
                    _maxPlayedCategory    = pair.Key;
                }
            }
        }
Esempio n. 12
0
        private void UpdateLeastPlayedCategory()
        {
            int smallest = 999;

            foreach (KeyValuePair <SportsMatchCategory, int> pair in SportsCategoryCounts)
            {
                if (pair.Value < smallest)
                {
                    _minSportsPlayedCount = pair.Value;
                    _minPlayedCategory    = pair.Key;
                }
            }
        }
Esempio n. 13
0
 private void RemoveCategoryFromEventTeamStats(Event evnt, SportsMatchCategory category)
 {
     _teamStats[evnt.TeamOneId].RemoveSportsCategoryPlayed(category);
     _teamStats[evnt.TeamTwoId].RemoveSportsCategoryPlayed(category);
 }
Esempio n. 14
0
 private void AddCategoryToEventTeamStats(Event evnt, SportsMatchCategory category)
 {
     _teamStats[evnt.TeamOneId].AddSportsCategoryPlayed(category);
     _teamStats[evnt.TeamTwoId].AddSportsCategoryPlayed(category);
 }
Esempio n. 15
0
 public void ModifyPlayerAssignment(SportsMatchCategory category, int modification)
 {
     PlayersPerMatchType[category] += modification;
 }
Esempio n. 16
0
 /// <summary>
 /// Returns whether the given player amount modification to the given category is legal or not.
 /// </summary>
 /// <param name="category"></param>
 /// <param name="modification"></param>
 /// <returns></returns>
 public bool LegalPlayerAssignment(SportsMatchCategory category, int modification)
 {
     return(PlayersPerMatchType[category] + modification <= Globals.MatchTypePlayerLimitsPerTeam[category]);
 }