Example #1
0
 public AggRoundScore(AggRoundScore baseScore, RoundScore score, int roundIndex)
     : base(baseScore.RiderId, 0, baseScore.Points + score.Points)
 {
     if (baseScore.RiderId != score.RiderId)
     {
         throw new ArgumentException($"RiderId should be same as initial ({RiderId}), but was ({score.RiderId})", nameof(score));
     }
     if (score.Points > 0) // Ignore positions with 0 points
     {
         var scores = baseScore.OriginalScores.ToList();
         scores.Add(score);
         OriginalScores = new ReadOnlyCollection <RoundScore>(scores);
         var histogram = baseScore.PositionHistogram.ToDictionary(x => x.Key, x => x.Value);
         histogram.UpdateOrAdd(score.Position, v => v + 1);
         PositionHistogram = new ReadOnlyDictionary <int, int>(histogram);
     }
     else
     {
         OriginalScores    = baseScore.OriginalScores;
         PositionHistogram = baseScore.PositionHistogram;
     }
     if (MaxRoundIndex <= roundIndex)
     {
         MaxRoundIndex       = roundIndex;
         PointsInLastRound   = score.Points;
         PositionInLastRound = score.Position;
     }
 }
Example #2
0
 public AggRoundScore AddScore(RoundScore score, int roundIndex)
 {
     return(new AggRoundScore(this, score, roundIndex));
 }
Example #3
0
 private AggRoundScore(RoundScore score)
     : base(score.RiderId, 0, score.Points)
 {
 }