Esempio n. 1
0
        public void Calculate_Max_Number_Of_Sets(bool isBestOf, int numOfSets, int expected)
        {
            var rule = new MatchRuleEntity {
                BestOf = isBestOf, NumOfSets = numOfSets
            };

            Assert.AreEqual(expected, rule.MaxNumOfSets());
        }
        /// <summary>
        /// Assigns &quot;set points&quot; to each of the <see cref="SetEntity"/>s in the list.
        /// For &quot;Best-of&quot; matches, <see cref="SetEntity.IsTieBreak"/> is flagged, too.
        /// </summary>
        /// <param name="setList">An <see cref="IList{SetEntity}"/>.</param>
        /// <param name="setRule">The <see cref="SetRuleEntity"/> with the set rules to apply.</param>
        /// <param name="matchRule">The <see cref="MatchRuleEntity"/> with the set rules to apply.</param>
        /// <returns>Returns the <see cref="IList{SetEntity}"/> after &quot;set points&quot; were set.</returns>
        public static IList <SetEntity> CalculateSetPoints(this IList <SetEntity> setList, SetRuleEntity setRule, MatchRuleEntity matchRule)
        {
            var wonSets = new PointResult(0, 0);

            foreach (var set in setList)
            {
                set.CalculateSetPoints(setRule);
                set.IsTieBreak = false || matchRule.BestOf && wonSets.Home == wonSets.Guest &&
                                 wonSets.Home + wonSets.Guest == matchRule.MaxNumOfSets() - 1;
                wonSets.Home  += set.HomeBallPoints > set.GuestBallPoints ? 1 : 0;
                wonSets.Guest += set.HomeBallPoints < set.GuestBallPoints ? 0 : 1;
            }

            return(setList);
        }
Esempio n. 3
0
        public EnterResultViewModel(TournamentEntity tournament, RoundEntity round,
                                    MatchEntity match, MatchRuleEntity matchRule, IList <TeamInRoundEntity> teamInRound,
                                    Axuno.Tools.DateAndTime.TimeZoneConverter timeZoneConverter)
        {
            Tournament = tournament ?? throw new ArgumentNullException(nameof(tournament));
            Round      = round ?? throw new ArgumentNullException(nameof(round));
            Match      = match ?? throw new ArgumentNullException(nameof(match));
            Opponent   = new Opponent(
                teamInRound.FirstOrDefault(o => o.TeamId == match.HomeTeamId)?.TeamNameForRound ?? throw new ArgumentNullException(nameof(teamInRound)),
                teamInRound.FirstOrDefault(o => o.TeamId == match.GuestTeamId)?.TeamNameForRound ?? throw new ArgumentNullException(nameof(teamInRound)));;
            TimeZoneConverter = timeZoneConverter ?? throw new ArgumentNullException(nameof(timeZoneConverter));

            _localizer = CreateModelStringLocalizer();

            _maxNumberOfSets = matchRule.MaxNumOfSets();
            MapEntityToFormFields();
        }