Ejemplo n.º 1
0
 private void CopyPlayerDataIfPlayerExists(BattingPost battingPost, BattingPostStats battingPostStats)
 {
     if (battingPost.Player != null)
     {
         battingPostStats.NameFirst = battingPost.Player.NameFirst;
         battingPostStats.NameLast  = battingPost.Player.NameLast;
         battingPostStats.NameGiven = battingPost.Player.NameGiven;
     }
 }
Ejemplo n.º 2
0
        public BattingPostStats Map(BattingPost battingPost)
        {
            var battingPostStats = new BattingPostStats()
            {
                PlayerId = battingPost.PlayerId,
                YearId   = battingPost.YearId,
                Round    = battingPost.Round,
                TeamId   = battingPost.TeamId,
                LgId     = battingPost.LgId
            };

            CopyPlayerDataIfPlayerExists(battingPost, battingPostStats);
            CopyNullableStats(battingPost, battingPostStats);

            _calculator.CalculateStats(battingPostStats);

            return(battingPostStats);
        }
Ejemplo n.º 3
0
 private void CopyNullableStats(BattingPost batting, BattingPostStats battingStats)
 {
     battingStats.G    = batting.G;
     battingStats.Ab   = batting.Ab;
     battingStats.R    = batting.R;
     battingStats.H    = batting.H;
     battingStats.X2b  = batting.X2b;
     battingStats.X3b  = batting.X3b;
     battingStats.Hr   = batting.Hr;
     battingStats.Rbi  = batting.Rbi;
     battingStats.Sb   = batting.Sb;
     battingStats.Cs   = batting.Cs;
     battingStats.Bb   = batting.Bb;
     battingStats.So   = batting.So;
     battingStats.Ibb  = batting.Ibb;
     battingStats.Hbp  = batting.Hbp;
     battingStats.Sh   = batting.Sh;
     battingStats.Sf   = batting.Sf;
     battingStats.Gidp = batting.Gidp;
 }
Ejemplo n.º 4
0
        private CalculatorStats ConvertOptionalParamsToNonNullable(BattingPostStats battingStats)
        {
            var calculatorStats = new CalculatorStats
            {
                Ab = battingStats.Ab ?? 0,

                H = battingStats.H ?? 0,

                X2b = battingStats.X2b ?? 0,

                X3b = battingStats.X3b ?? 0,

                Hr = battingStats.Hr ?? 0,

                Bb = battingStats.Bb ?? 0,

                So = battingStats.So ?? 0,


                Ibb = battingStats.Ibb ?? 0,

                Hbp = battingStats.Hbp ?? 0,

                Sh = battingStats.Sh ?? 0,

                Sf = battingStats.Sf ?? 0
            };

            calculatorStats.Pa      = CalulatePa(calculatorStats);
            calculatorStats.Singles = CalculateSingles(calculatorStats);
            calculatorStats.Obp     = CalculateObp(calculatorStats);
            calculatorStats.Slg     = CalculateSlg(calculatorStats);
            calculatorStats.KRate   = CalculateKRate(calculatorStats);
            calculatorStats.BbRate  = CalculateBbRate(calculatorStats);

            return(calculatorStats);
        }
Ejemplo n.º 5
0
        public void CalculateStats(BattingPostStats battingPostStats)
        {
            var calculatorStats = ConvertOptionalParamsToNonNullable(battingPostStats);

            battingPostStats.Pa = calculatorStats.Pa;

            battingPostStats.Singles = calculatorStats.Singles;

            battingPostStats.Obp = calculatorStats.Obp;

            battingPostStats.Slg = calculatorStats.Slg;

            battingPostStats.BbRate = calculatorStats.BbRate;

            battingPostStats.KRate = calculatorStats.KRate;

            battingPostStats.Avg = CalculateAvg(calculatorStats);

            battingPostStats.Ops = CalculateOps(calculatorStats);

            battingPostStats.Iso = CalculateIso(calculatorStats);

            battingPostStats.Babip = CalculateBabip(calculatorStats);
        }