public async Task <Image> GetBadge(string filename, DriverStats driver)
        {
            var signature = await GetImageOrDefault(filename, 250, 40);

            using (var g = Graphics.FromImage(signature))
            {
                string fontName = "Verdana";

                var          font = new Font(fontName, 10, FontStyle.Bold);
                StringFormat sf   = new StringFormat()
                {
                    LineAlignment = StringAlignment.Center,
                    Alignment     = StringAlignment.Center
                };

                g.SmoothingMode     = SmoothingMode.AntiAlias;
                g.InterpolationMode = InterpolationMode.HighQualityBicubic;
                g.PixelOffsetMode   = PixelOffsetMode.HighQuality;

                g.DrawString(driver.iRatingText, font, Brushes.Black, new RectangleF(140, 0, 65, 20), sf);

                var licenseBrush     = new SolidBrush(ColorTranslator.FromHtml($"#{driver.LicenseColor}"));
                var licenseBrushText = new SolidBrush(ColorTranslator.FromHtml($"#{driver.LicenseColorForeground}"));

                g.FillRectangle(licenseBrush, new RectangleF(140, 20, 65, 20));
                g.DrawString($"{driver.Class}", font, licenseBrushText, new RectangleF(140, 20, 65, 20), sf);

                g.Flush();
            }

            return(signature);
        }
Exemplo n.º 2
0
        public Image GetBadge(string filename, DriverStats driver)
        {
            var badgeBaseImage = Image.FromFile(_serverUtility.MapPath($"~/img/{filename}"));

            using (var g = Graphics.FromImage((Image)badgeBaseImage))
            {
                string fontName = "Verdana";

                var          font = new Font(fontName, 10, FontStyle.Bold);
                StringFormat sf   = new StringFormat()
                {
                    LineAlignment = StringAlignment.Center,
                    Alignment     = StringAlignment.Center
                };

                g.SmoothingMode     = SmoothingMode.AntiAlias;
                g.InterpolationMode = InterpolationMode.HighQualityBicubic;
                g.PixelOffsetMode   = PixelOffsetMode.HighQuality;

                g.DrawString(driver.iRatingText, font, Brushes.Black, new RectangleF(140, 0, 65, 20), sf);

                var licenseBrush     = new SolidBrush(ColorTranslator.FromHtml($"#{driver.LicenseColor}"));
                var licenseBrushText = new SolidBrush(ColorTranslator.FromHtml($"#{driver.LicenseColorForeground}"));

                g.FillRectangle(licenseBrush, new RectangleF(140, 20, 65, 20));
                g.DrawString($"{driver.Class}", font, licenseBrushText, new RectangleF(140, 20, 65, 20), sf);

                g.Flush();
            }

            return(badgeBaseImage);
        }
Exemplo n.º 3
0
        public Image GetRoadMiniSignature(DriverStats driver, string signatureImagepng = "minisig.png", string hexColour = "#00A900")
        {
            var signature = Image.FromFile(_serverUtility.MapPath($"~/img/{signatureImagepng}"));

            using (var g = Graphics.FromImage((Image)signature))
            {
                string fontName = "Verdana";

                var font = new Font(fontName, 8, FontStyle.Bold);

                g.SmoothingMode     = SmoothingMode.AntiAlias;
                g.InterpolationMode = InterpolationMode.HighQualityBicubic;
                g.PixelOffsetMode   = PixelOffsetMode.HighQuality;

                // Draw License Colour & Name
                var boxBrush = new SolidBrush(ColorTranslator.FromHtml(hexColour));
                g.DrawString(driver.Driver, font, Brushes.Black, new RectangleF(85, 3, 150, 14));

                //font = new Font(fontName, 8);

                g.FillRectangle(boxBrush, new RectangleF(228, 0, 23, 20));
                g.DrawString("iR", font, Brushes.White, new RectangleF(232, 3, 20, 14));
                g.DrawString(driver.iRatingText, font, Brushes.Black, new RectangleF(255, 3, 60, 14));
                var licenseBrush     = new SolidBrush(ColorTranslator.FromHtml($"#{driver.LicenseColor}"));
                var licenseBrushText = new SolidBrush(ColorTranslator.FromHtml($"#{driver.LicenseColorForeground}"));
                g.FillRectangle(licenseBrush, new RectangleF(300, 0, 51, 20));
                g.DrawString($"{driver.Class}", font, licenseBrushText, new RectangleF(305, 3, 45, 14));

                g.Flush();
            }

            return(signature);
        }
Exemplo n.º 4
0
 public PersonalityTraitController_v2(PersonalityTraitController inOldController)
 {
     this.permanentPersonalityTraits = inOldController.permanentPersonalityTraits;
     this.temporaryPersonalityTraits = inOldController.temporaryPersonalityTraits;
     this.mTraitHistory               = inOldController.mTraitHistory;
     this.mMaxCooldownDaysRange       = inOldController.mMaxCooldownDaysRange;
     this.cooldownPeriodEnd           = inOldController.cooldownPeriodEnd;
     this.mLastRandomCooldownDayValue = inOldController.mLastRandomCooldownDayValue;
     this.mDriver      = inOldController.mDriver;
     this.mDriverStats = inOldController.mDriverStats;
     this.allTraits    = new List <PersonalityTrait>();
 }
Exemplo n.º 5
0
 public void Add(DriverStats inAdd)
 {
     this.braking      += inAdd.braking;
     this.cornering    += inAdd.cornering;
     this.smoothness   += inAdd.smoothness;
     this.overtaking   += inAdd.overtaking;
     this.consistency  += inAdd.consistency;
     this.adaptability += inAdd.adaptability;
     this.fitness      += inAdd.fitness;
     this.feedback     += inAdd.feedback;
     this.focus        += inAdd.focus;
     this.balance      += inAdd.balance;
 }
Exemplo n.º 6
0
    public DriverStats GetDriverStatsModifier()
    {
        this.mDriverStats.Clear();
        int count = this.allTraits.Count;

        for (int index = 0; index < count; ++index)
        {
            if (this.allTraits[index].CanApplyTrait())
            {
                DriverStats driverStatsModifier = this.allTraits[index].GetDriverStatsModifier();
                this.mDriverStats.Add(driverStatsModifier);
                this.mDriverStats.marketability += driverStatsModifier.marketability;
            }
        }
        return(this.mDriverStats);
    }
Exemplo n.º 7
0
        private Dictionary <string, DriverStats> GetSingleDriverStatsByType(Dictionary <string, List <DriverStats> > driverStatsByType, CarMappingMethod mappingMethod, string carNumber, Driver driver)
        {
            Dictionary <string, DriverStats> statsByType = new Dictionary <string, DriverStats>();

            foreach (TrackType tt in trackTypes)
            {
                var q = from s in driverStatsByType[tt.Id]
                        select s;

                switch (mappingMethod)
                {
                case CarMappingMethod.NAME:
                    q = from s in q
                        where s.Driver == driver
                        select s;
                    break;

                case CarMappingMethod.NUMBER:
                    q = from s in q
                        where s.CarNumber == carNumber
                        select s;
                    break;

                case CarMappingMethod.NUMBER_AND_NAME:
                    q = from s in q
                        where s.Driver == driver &&
                        s.CarNumber == carNumber
                        select s;
                    break;
                }


                DriverStats stats = q.FirstOrDefault();

                //IF NO STATS WERE FOUND FOR THIS DRIVER FOR THIS TRACKTYPE, INITIALIZE AN EMPTY DRIVERSTATS
                if (stats == null)
                {
                    stats = new DriverStats();
                }

                statsByType.Add(tt.Id, stats);
            }

            return(statsByType);
        }
        public async Task <List <DriverStats> > BuildDriversSeasonStats(int season)
        {
            List <DriverStats> driverStats = new List <DriverStats>();

            var raceData = await _driverReader.GetDriversSeasonRaceResults(season);

            var driverData = raceData.GroupBy(x => x.DriverId);

            foreach (var driver in driverData)
            {
                var result   = driver.Select(x => RaceResults.MapFromDb(x)).ToList();
                var calcData = CalculateDriverData(result);

                driverStats.Add(DriverStats.Mapper(driver.Key, calcData));
            }

            return(driverStats);
        }
Exemplo n.º 9
0
        public Image GetRoadSignature(DriverStats driver)
        {
            string signatureTemplate = driver.GetSignatureTemplate();

            var signature = Image.FromFile(_serverUtility.MapPath($"~/img/{signatureTemplate}"));

            using (var g = Graphics.FromImage((Image)signature))
            {
                string fontName = "Verdana";

                var font = new Font(fontName, 15, FontStyle.Bold);

                g.SmoothingMode     = SmoothingMode.AntiAlias;
                g.InterpolationMode = InterpolationMode.HighQualityBicubic;
                g.PixelOffsetMode   = PixelOffsetMode.HighQuality;

                // Draw License Colour & Name
                var greenBrush = new SolidBrush(ColorTranslator.FromHtml($"#00A900"));
                g.FillRectangle(greenBrush, 0, 0, 588, 1);
                g.FillRectangle(greenBrush, 0, 49, 588, 1);
                g.FillRectangle(greenBrush, 0, 0, 1, 50);
                g.DrawString(driver.Driver, font, Brushes.Black, new RectangleF(8, 8, 185, 20));

                var fontBoxHeading = new Font(fontName, 10);
                g.DrawString("iRating", fontBoxHeading, Brushes.White, new RectangleF(205, 6, 45, 12));

                font = new Font(fontName, 13);
                var smallFont = new Font(fontName, 10);
                g.DrawString(driver.iRatingText, font, Brushes.Black, new RectangleF(205, 22, 60, 25));
                //g.DrawString(cardData.License.Replace("Class", "").Trim(), font, Brushes.Black, new RectangleF(267, 22, 15, 25));
                var licenseBrush     = new SolidBrush(ColorTranslator.FromHtml($"#{driver.LicenseColor}"));
                var licenseBrushText = new SolidBrush(ColorTranslator.FromHtml($"#{driver.LicenseColorForeground}"));
                var urlBrushText     = new SolidBrush(ColorTranslator.FromHtml("#949494"));
                g.FillRectangle(licenseBrush, new RectangleF(263, 18, 50, 23));
                g.DrawString($"{driver.Class}", font, licenseBrushText, new RectangleF(264, 22, 80, 25));

                g.DrawString("atomicsimracing.net", smallFont, urlBrushText, new RectangleF(8, 35, 200, 20));

                g.Flush();
            }

            return(signature);
        }
Exemplo n.º 10
0
 public Image GetDirtOvalBadge(DriverStats driver)
 {
     return(GetBadge("asr-badge-oval-dirt.png", driver));
 }
Exemplo n.º 11
0
 public Image GetDirtRoadBadge(DriverStats driver)
 {
     return(GetBadge("asr-badge-road-dirt.png", driver));
 }
Exemplo n.º 12
0
 public Image GetRoadMiniSrrSignature(DriverStats driver)
 {
     return(GetRoadMiniSignature(driver, "minisig-srr.png", "#234A70"));
 }
Exemplo n.º 13
0
        public void ComputeDriverStatsForEachTrackType()
        {
            try
            {
                this.selectedRacesInfo.Clear();
                this.driverStatsByType.Clear();

                RatingsFormula formula = this.selectedFormula;

                if (formula != null)
                {
                    List <RaceInfo> racesInfo = (from r in this.selectedRaces
                                                 select new RaceInfo
                    {
                        Race = r,
                        WinnerLaps = (from drd in driverRaceDataList
                                      where drd.Race.Id == r.Id &&
                                      drd.RaceResult != null &&
                                      drd.RaceResult.FinishPosition == 1
                                      select drd.RaceResult.Laps).FirstOrDefault(),
                        NumberOfStarters = (from drd in driverRaceDataList
                                            where drd.Race.Id == r.Id &&
                                            drd.RaceResult != null
                                            select drd.RaceResult).Count()
                    }).ToList();

                    this.selectedRacesInfo.Add("ALL", racesInfo);


                    List <DriverStats> statsAll = this.ComputeDriverStats(this.driverRaceDataList, racesInfo, formula.Options.MappingMethod);

                    this.driverStatsByType.Add("ALL", statsAll);

                    foreach (TrackType tt in trackTypes)
                    {
                        int countSelected;

                        List <DriverRaceData> driverRaceDataForSpecificType;
                        List <RaceInfo>       racesInfoForSpecificType;

                        if (formula.Options.UseNr2003TrackTypes == false)
                        {
                            driverRaceDataForSpecificType = (from drd in driverRaceDataList
                                                             where String.Equals(drd.Race.TrackTypeId, tt.Id)
                                                             select drd).ToList();

                            racesInfoForSpecificType = (from ri in racesInfo
                                                        where String.Equals(ri.Race.TrackTypeId, tt.Id)
                                                        select ri).ToList();

                            countSelected = racesInfoForSpecificType.Count;
                        }
                        else
                        {
                            driverRaceDataForSpecificType = (from drd in driverRaceDataList
                                                             where String.Equals(drd.Race.NR2003TrackTypeId, tt.Id)
                                                             select drd).ToList();

                            racesInfoForSpecificType = (from ri in racesInfo
                                                        where String.Equals(ri.Race.NR2003TrackTypeId, tt.Id)
                                                        select ri).ToList();

                            countSelected = racesInfoForSpecificType.Count;
                        }

                        this.selectedRacesInfo.Add(tt.Id, racesInfoForSpecificType);


                        List <DriverStats> stats = this.ComputeDriverStats(driverRaceDataForSpecificType, racesInfoForSpecificType, formula.Options.MappingMethod);

                        var nonFoundDriversForThisTrackType = from s in statsAll
                                                              where stats.Contains(s, new DriverStatsComparerByNumberAndName()) == false
                                                              select s;

                        foreach (DriverStats ds in nonFoundDriversForThisTrackType)
                        {
                            DriverStats nonFoundDriver = new DriverStats();
                            nonFoundDriver.CarNumber = ds.CarNumber;
                            nonFoundDriver.Driver    = ds.Driver;

                            stats.Add(nonFoundDriver);
                        }

                        this.driverStatsByType.Add(tt.Id, stats);
                    }
                }
            }
            catch (Exception ex)
            {
                DataProcessingException dpEx = new DataProcessingException(ex.Message, this.selectedRaces, this.selectedFormula);
                this.dataProcessingException = dpEx;
            }
        }
 public async Task <Image> GetDirtOvalBadge(DriverStats driver)
 {
     return(await GetBadge("asr-badge-oval-dirt.png", driver));
 }
 public async Task <Image> GetDirtRoadBadge(DriverStats driver)
 {
     return(await GetBadge("asr-badge-road-dirt.png", driver));
 }
 public async Task <Image> GetRoadMiniSrrSignature(DriverStats driver)
 {
     return(await GetRoadMiniSignature(driver, "minisig-srr.png", "#234A70"));
 }