public Item(List <RaceLap> laps, int i, RacePit [] pits, RaceSession rs)
            {
                RaceLap lap = laps[i];

                pits = pits.Where(k => k.LapNumber <= lap.LapNumber).ToArray();

                this.Driver   = lap.Driver.NameSurname;
                this.Number   = lap.Driver.Number;
                this.Position = lap.CurrentPosition;
                if (i == 0)
                {
                    this.GapToFirst    = RaceGap.Empty;
                    this.GapToPrevious = RaceGap.Empty;
                }
                else
                {
                    RaceLap prev = laps[i - 1];
                    this.GapToFirst    = new RaceGap(laps[0], lap);
                    this.GapToPrevious = new RaceGap(laps[i - 1], lap);
                }
                this.LapCount       = lap.LapNumber;
                this.State          = rs.Positions.GetDriverFinalStatus(lap.Driver).ToString();
                this.LapsInLead     = GetLapsInLead(lap);
                this.PitCount       = pits.Length;
                this.BestTime       = GetBestTime(lap);
                this.MeanTime       = GetMeanTime(lap);
                this.MeanTimePY     = GetMeanTimePY(lap);
                this.WorstTime      = GetWorstTime(lap);
                this.BestPitTime    = GetBestPitTime(pits);
                this.MeanPitTime    = GetMeanPitTime(pits);
                this.WorstPitTime   = GetWorstPitTime(pits);
                this.BestPosition   = GetBestPositionSoFar(lap);
                this.WorstPosition  = GetWorstPositionSoFar(lap);
                this.PitInLaps      = GetPitLapsAsString(pits);
                this.MaxGainPerLap  = GetMaxGainPerLap(lap);
                this.MaxLoosePerLap = GetMaxLoosePerLap(lap);

                this.BlackFlags =
                    lap.Sum(k => k.IsBlackFlagged ? 1 : 0, k => k.PreviousLapAsRaceLap);
            }
Esempio n. 2
0
        private static void UpdateNewDriverStandingsByNewRace(WeekendInfo previous, WeekendInfo current, AbstractScoring scoring, Weekend weekend, RaceSession race, Dictionary <Driver, TempData> tmp, RaceLap item)
        {
            DriverStandings prevDs = null;

            if (previous != null)
            {
                prevDs = previous.Standings[item.Driver];
            }
            if (current.Standings[item.Driver] == null)
            {
                current.Standings.Add(new DriverStandings()
                {
                    Driver = item.Driver
                });
            }
            DriverStandings newDs = current.Standings[item.Driver];

            int racePoints = GetRacePoints(item, scoring, tmp);

            weekend.Points.Add(item.Driver, racePoints);

            newDs.PointsM.Add(racePoints);

            newDs.BlackFlagsMean.Add(item.Sum(
                                         i => i.IsBlackFlagged ? 1 : 0,
                                         i => i.PreviousLapAsRaceLap
                                         ));

            if (race.Positions.GetDriverFinalStatus(item.Driver) == RacePositionCollection.eStatus.Accident ||
                race.Positions.GetDriverFinalStatus(item.Driver) == RacePositionCollection.eStatus.Retired)
            {
                newDs.CrashesCount++;
            }

            if (race.Positions.GetDriverFinalStatus(item.Driver) == RacePositionCollection.eStatus.Running)
            {
                newDs.FinishesCount++;
            }

            newDs.FinishPositionsMean.Add(item.CurrentPosition);

            newDs.LapsInLead +=
                tmp[item.Driver].LapsInLead;

            newDs.QualifyPositionsMean.Add(
                tmp[item.Driver].QualifyPosition);

            newDs.RacesCount++;
            newDs.LapsCount += item.LapNumber;

            int pos = item.CurrentPosition;

            if (pos < 2)
            {
                newDs.Top1++;
            }
            if (pos < 3)
            {
                newDs.Top2++;
            }
            if (pos < 4)
            {
                newDs.Top3++;
            }
            if (pos < 6)
            {
                newDs.Top5++;
            }
            if (pos < 11)
            {
                newDs.Top10++;
            }
            if (pos < 21)
            {
                newDs.Top20++;
            }

            newDs.PreviousWeekendStanding = prevDs;
            if (prevDs != null)
            {
                prevDs.NextWeeendStanding = newDs;
            }
        }