Пример #1
0
            public void AddComponent(Discipline discipline, IRules rules, double coeficient)
            {
                var component = new ResultsListColumnComponent(discipline, rules, coeficient);

                this.components.Add(component);
                isSingleDiscipline   = coeficient == 1.0f && this.components.Count == 1;
                hasFinalPoints       = components.All(c => c.Rules.HasPoints); // all disciplines support points
                primaryComponent     = components.Select(c => c.Rules.PrimaryComponent).FirstOrDefault();
                hasSecondaryDuration = components.Select(c => c.Rules.HasDuration && c.Rules.PrimaryComponent == PerformanceComponent.Duration).FirstOrDefault();
                bool hasPerformance = components.Select(c => c.Rules.Name).Distinct().Count() == 1;  // all disciplines have same rules

                if (!hasPerformance)
                {
                    primaryComponent     = PerformanceComponent.None;
                    hasSecondaryDuration = false;
                }
                if (!discipline.AnnouncementsPublic)
                {
                    allowAnnouncements = allowPrivateData;
                }
                if (!discipline.ResultsPublic)
                {
                    allowResults = allowPrivateData;
                }
            }
Пример #2
0
        private static void CalculateFinalPerformance(ActualResult result, PerformanceComponent component, PerformanceComponent penalizationTarget)
        {
            double?realized = component.Get(result.Performance);

            if (realized == null)
            {
                component.Modify(result.FinalPerformance, null);
            }
            else
            {
                double final = realized.Value;
                foreach (var penalization in result.Penalizations)
                {
                    double?minus = component.Get(penalization.Performance);
                    if (minus != null)
                    {
                        final -= minus.Value;
                    }
                }
                if (final < 0)
                {
                    final = 0;
                }
                if (component == penalizationTarget && result.CardResult == CardResult.Red)
                {
                    final = 0;
                }
                component.Modify(result.FinalPerformance, final);
            }
        }
Пример #3
0
 public static string Performance(PerformanceComponent component, PerformanceDto performance)
 {
     if (component == PerformanceComponent.Duration)
     {
         return(PerformanceDuration(performance));
     }
     if (component == PerformanceComponent.Distance)
     {
         return(PerformanceDistance(performance));
     }
     if (component == PerformanceComponent.Depth)
     {
         return(PerformanceDepth(performance));
     }
     if (component == PerformanceComponent.Points)
     {
         return(PerformancePoints(performance));
     }
     return("");
 }