Esempio n. 1
0
        private static void ReEvaluate(WeekendInfo previous, WeekendInfo current, AbstractScoring scoring)
        {
            if (current == null)
            {
                throw new ArgumentNullException();
            }
            if (scoring == null)
            {
                throw new ArgumentNullException();
            }
            if (current.Weekend.Race.IsEmpty())
            {
                throw new ArgumentException();
            }

            Weekend     weekend = current.Weekend;
            RaceSession race    = weekend.Race;

            var poss = race.Positions.GetLastLap();

            weekend.Points.Clear();

            PrepareNewStandings(previous, current);

            Dictionary <Driver, TempData> tmp = CalculateTempData(poss);

            foreach (var item in poss)
            {
                UpdateNewDriverStandingsByNewRace(previous, current, scoring, weekend, race, tmp, item);
            }

            OrderDriverStandingsByPointsAndAssignPosition(current);
        }
Esempio n. 2
0
        private static int GetRacePoints(RaceLap item, AbstractScoring scoring, Dictionary <Driver, TempData> tmp)
        {
            int ret = 0;

            ret = scoring.GetPositionPoints(item.CurrentPosition);

            if (scoring.AtLeastOneLapLeaderPoints > 0)
            {
                if (item.Exists(
                        i => i.CurrentPosition == 1,
                        i => (i.PreviousLap as RaceLap)))
                {
                    ret += scoring.AtLeastOneLapLeaderPoints;
                }
            }

            if (scoring.MostLapLeaderPoints > 0)
            {
                if (tmp[tmp.Keys.First()].LapsInLead == tmp[item.Driver].LapsInLead)
                {
                    ret += scoring.MostLapLeaderPoints;
                }
            }

            if (scoring.QualifyWinnerPoints > 0)
            {
                if (tmp[item.Driver].QualifyPosition == 1)
                {
                    ret += scoring.QualifyWinnerPoints;
                }
            }

            if (scoring.RaceWinnerExtraPoints > 0)
            {
                if (item.CurrentPosition == 1)
                {
                    ret += scoring.RaceWinnerExtraPoints;
                }
            }

            return(ret);
        }
Esempio n. 3
0
        private static void ReEvaluate(WeekendInfo previous, WeekendInfo current, object scoringAsObject)
        {
            AbstractScoring sc = scoringAsObject as AbstractScoring;

            ReEvaluate(previous, current, sc);
        }
Esempio n. 4
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;
            }
        }