Example #1
0
        private static DriverStandings CloneDriverStandingsForNewRace(DriverStandings prevDs)
        {
            DriverStandings currDs = new DriverStandings();

            currDs.Driver               = prevDs.Driver;
            currDs.BetterStandings      = null;
            currDs.BlackFlagsMean       = prevDs.BlackFlagsMean.Clone();
            currDs.CrashesCount         = prevDs.CrashesCount;
            currDs.FinishesCount        = prevDs.FinishesCount;
            currDs.FinishPositionsMean  = prevDs.FinishPositionsMean.Clone();
            currDs.LapsInLead           = prevDs.LapsInLead;
            currDs.PointsM              = prevDs.PointsM.Clone();
            currDs.Position             = 0;
            currDs.QualifyPositionsMean = prevDs.QualifyPositionsMean.Clone();
            currDs.RacesCount           = prevDs.RacesCount;
            currDs.LapsCount            = prevDs.LapsCount;
            currDs.Top1           = prevDs.Top1;
            currDs.Top10          = prevDs.Top10;
            currDs.Top2           = prevDs.Top2;
            currDs.Top20          = prevDs.Top20;
            currDs.Top3           = prevDs.Top3;
            currDs.Top5           = prevDs.Top5;
            currDs.WorseStandings = null;

            return(currDs);
        }
Example #2
0
 public Item(int index, WeekendInfo raceWeekend, DriverStandings standing)
 {
     // TODO: Complete member initialization
     this.RaceIndex         = index;
     this.RaceName          = raceWeekend.Weekend.Name;
     this.Name              = standing.Driver.NameSurname;
     this.DriverNumber      = standing.Driver.Number;
     this.StandingAfterRace = raceWeekend.Standings[standing.Driver].Position;
     this.RacePosition      = standing.Position;
 }
Example #3
0
            public Item(DriverStandings item, DriverStandings standingOfFirstDriver)
            {
                this.Name             = item.Driver.NameSurname;
                this.Number           = item.Driver.Number;
                this.Points           = (int)item.PointsM.Sum;
                this.Position         = item.Position;
                this.PreviousPosition = item.PreviousPosition;
                if (item == standingOfFirstDriver)
                {
                    this.ToFirst = 0;
                }
                else
                {
                    this.ToFirst = (int)(standingOfFirstDriver.PointsM.Sum - item.PointsM.Sum);
                }
                if (item.BetterStandings == null)
                {
                    this.ToPrevious = 0;
                }
                else
                {
                    this.ToPrevious = (int)(item.BetterStandings.PointsM.Sum - item.PointsM.Sum);
                }

                this.BestPositionEver =
                    item.Agregate(100,
                                  (i, m) => Math.Min(i.Position, m),
                                  i => i.PreviousWeekendStanding);

                this.WorstPositionEver =
                    item.Agregate(1,
                                  (i, m) => Math.Max(i.Position, m),
                                  i => i.PreviousWeekendStanding);

                this.AveragePoints = (int)item.PointsM.Mean;

                this.Races  = new DisplayWithPercentage(item.RacesCount, item.Parent.TotalRacesCount);
                this.Laps   = new DisplayWithPercentage(item.LapsCount, item.Parent.TotalLapsCount);
                this.LapsLL = new DisplayWithPercentage(item.LapsInLead, item.Parent.TotalLapsCount);

                this.Top1  = new DisplayWithPercentage(item.Top1, item.Parent.TotalRacesCount);
                this.Top2  = new DisplayWithPercentage(item.Top2, item.Parent.TotalRacesCount);
                this.Top3  = new DisplayWithPercentage(item.Top3, item.Parent.TotalRacesCount);
                this.Top5  = new DisplayWithPercentage(item.Top5, item.Parent.TotalRacesCount);
                this.Top10 = new DisplayWithPercentage(item.Top10, item.Parent.TotalRacesCount);
                this.Top20 = new DisplayWithPercentage(item.Top20, item.Parent.TotalRacesCount);

                this.Finishes = new DisplayWithPercentage(item.FinishesCount, item.Parent.TotalRacesCount);
                this.Crashes  = new DisplayWithPercentage(item.CrashesCount, item.Parent.TotalRacesCount);

                this.QualifyPositionMean = (int)item.QualifyPositionsMean.Mean;
                this.RacePositionMean    = (int)item.FinishPositionsMean.Mean;

                this.BlackFlagsCount = new DisplaySumWithMean(item.BlackFlagsMean.Sum, item.BlackFlagsMean.Mean);
            }
Example #4
0
        private static void PrepareNewStandings(WeekendInfo previous, WeekendInfo current)
        {
            current.Standings.Clear();

            if (previous == null)
            {
                return;
            }

            foreach (var item in previous.Standings)
            {
                DriverStandings newDs = CloneDriverStandingsForNewRace(item);
                current.Standings.Add(newDs);
            }
        }
Example #5
0
        public WeekendStandingsView(WeekendStandings ws)
        {
            if (ws == null)
            {
                return;
            }

            DriverStandings standingOfFirstDriver =
                ws.FirstOrDefault(i => i.Position == 1);

            foreach (var item in ws)
            {
                Item wsvi = new Item(item, standingOfFirstDriver);

                inner.Add(wsvi);
            }
        }
Example #6
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;
            }
        }