private Time GetMeanTime(Lap item)
            {
                Meaner m = new Meaner();
                Lap    l = item;

                while (l != null)
                {
                    m.Add(l.Time.TotalMiliseconds);
                    l = l.WorserLap;
                }

                Time ret = new Time((int)m.Mean);

                return(ret);
            }
示例#2
0
        public override string[] Evaluate(Weekend weekend)
        {
            List <string> ret = new List <string>();

            if (weekend.Race.IsEmpty())
            {
                ret.Add("This hint is evaluated only for if race has been taken.");
            }
            else
            {
                Driver user = AbstractHint.TryGetUserDriver(weekend);
                if (user == null)
                {
                    ret.Add("Cannot recognize user driver.");
                }
                else
                {
                    Meaner mD = new Meaner();
                    Meaner mA = new Meaner();

                    foreach (Driver d in weekend.Drivers.Values)
                    {
                        foreach (RacePit rp in weekend.Race.PitLaps.Get(d))
                        {
                            if (weekend.Race.Yellows.IsInYellow(rp.Time))
                            {
                                continue;
                            }

                            if (d == user)
                            {
                                mD.Add(rp.Time.TotalMiliseconds);
                            }
                            else
                            {
                                mA.Add(rp.Time.TotalMiliseconds);
                            }
                        }
                    }

                    ret.Add("Your medium pit time is : " + new Time((int)mD.Mean));
                    ret.Add("AI medium pit time is : " + new Time((int)mA.Mean));
                    ret.Add("\t* pit times are taken without yellow laps");
                }
            }

            return(ret.ToArray());;
        }
            private DisplayItemWithLap <Time> GetMeanPitTime(RacePit[] pits)
            {
                Meaner m = new Meaner();

                foreach (var item in pits)
                {
                    m.Add(item.Time.TotalMiliseconds);
                }

                Time ret = Time.Empty;

                if (double.IsNaN(m.Mean) == false)
                {
                    ret = new Time((int)m.Mean);
                }

                return(ret);
            }
示例#4
0
        public override string[] Evaluate(Weekend weekend)
        {
            List <string> ret = new List <string>();

            if (weekend.Qualify.IsEmpty())
            {
                ret.Add("This hint can be calculated only for qualify is taken.");
            }
            else
            {
                Driver user = TryGetUserDriver(weekend);
                if (user == null)
                {
                    ret.Add("User driver not found.");
                }
                else
                {
                    Meaner dm = new Meaner();
                    Meaner am = new Meaner();

                    foreach (var item in weekend.Qualify.Laps.GetAll())
                    {
                        if (item.Driver == user)
                        {
                            dm.Add(item.Time.TotalMiliseconds);
                        }
                        else
                        {
                            am.Add(item.Time.TotalMiliseconds);
                        }
                    }

                    ret.Add("Your mean qualify time is: " + new Time((int)dm.Mean));
                    ret.Add("AI mean qualify time is: " + new Time((int)am.Mean));
                    ret.Add("");
                    ret.Add("Your best time is: " + weekend.Qualify.Positions[user].Time);
                    ret.Add("AI best time is: " + weekend.Qualify.Positions[0].Time);
                }
            }

            return(ret.ToArray());
        }
            private DisplayItemWithLap <Time> GetMeanTimePY(Lap item)
            {
                Meaner m = new Meaner();
                Lap    l = item;

                while (l != null)
                {
                    if (l.IsPitted == false && (l.Session as RaceSession).Yellows.IsInYellow(l.CrossedAtTime) == false)
                    {
                        m.Add(l.Time.TotalMiliseconds);
                    }
                    l = l.WorserLap;
                }

                Time ret = Time.Empty;

                if (double.IsNaN(m.Mean) == false)
                {
                    ret = new Time((int)m.Mean);
                }

                return(ret);
            }
            private DisplayItemWithLap <Time> GetMeanTime(Lap item)
            {
                Meaner m = new Meaner();
                Lap    l = item;

                while (l != null)
                {
                    //if (l.IsPitted == false)
                    //{
                    m.Add(l.Time.TotalMiliseconds);
                    //}
                    l = l.WorserLap;
                }

                Time ret = Time.Empty;

                if (double.IsNaN(m.Mean) == false)
                {
                    ret = new Time((int)m.Mean);
                }

                return(ret);
            }