private void DoPassingUnit(PlayerGameProjectionMessage input, string teamCode, bool isHome)
        {
            var unit = new PassUnit();

            unit.Load(teamCode);

            // give it to the QB
            var projYDp = (int)(((isHome) ? input.Prediction.HomeYDp : input.Prediction.AwayYDp));
            var projTDp = (int)(((isHome) ? input.Prediction.HomeTDp : input.Prediction.AwayTDp));

            AddPassinglayerGameMetric(input, unit.Q1.PlayerCode, projYDp, projTDp);
            // Receivers
            var projYDc = (int)(.4 * ((isHome) ? input.Prediction.HomeYDp : input.Prediction.AwayYDp));
            var projTDc = W1TdsFrom((isHome) ? input.Prediction.HomeTDp : input.Prediction.AwayTDp);

            projYDc = AllowForInjuryRisk(unit.W1, projYDc);
            AddCatchingPlayerGameMetric(input, unit.W1.PlayerCode, projYDc, projTDc);
            projYDc = (int)(.25 * ((isHome) ? input.Prediction.HomeYDp : input.Prediction.AwayYDp));
            projTDc = W2TdsFrom((isHome) ? input.Prediction.HomeTDp : input.Prediction.AwayTDp);
            projYDc = AllowForInjuryRisk(unit.W2, projYDc);
            AddCatchingPlayerGameMetric(input, unit.W2.PlayerCode, projYDc, projTDc);
            if (unit.W3 != null)
            {
                projYDc = (int)(.1 * ((isHome) ? input.Prediction.HomeYDp : input.Prediction.AwayYDp));
                projTDc = 0;
                projYDc = AllowForInjuryRisk(unit.W3, projYDc);
                AddCatchingPlayerGameMetric(input, unit.W3.PlayerCode, projYDc, projTDc);
            }
            projYDc = (int)(.25 * ((isHome) ? input.Prediction.HomeYDp : input.Prediction.AwayYDp));
            projTDc = TETdsFrom((isHome) ? input.Prediction.HomeTDp : input.Prediction.AwayTDp);
            projYDc = AllowForInjuryRisk(unit.TE, projYDc);
            AddCatchingPlayerGameMetric(input, unit.TE.PlayerCode, projYDc, projTDc);
        }
        private void AddCatchingPlayerGameMetric(
            PlayerGameProjectionMessage input,
            string playerId,
            int projYDc,
            int projTDc)
        {
            if (input == null || playerId == null)
            {
                return;
            }
            if (string.IsNullOrEmpty(playerId) ||
                input.Game == null)
            {
                return;
            }
            var pgm = new PlayerGameMetrics
            {
                PlayerId = playerId,
                GameKey  = input.Game.GameKey(),
                ProjYDc  = projYDc,
                ProjTDc  = projTDc
            };

#if DEBUG
            Utility.Announce(pgm.ToString());
#endif
            input.Game.PlayerGameMetrics.Add(pgm);
        }
 public void TestGettingGamePrediction()
 {
     var msg = new PlayerGameProjectionMessage {Game = new NFLGame( "2014:01-A" )};
        var sut = new GetGamePrediction( msg );
     Assert.IsNotNull( msg.Prediction );
     Utility.Announce( msg.Prediction.PredictedScore() );
 }
        public void Execute( NFLGame game )
        {
            if ( pipeline == null ) InitialiseThePipeLine();

             var msg = new PlayerGameProjectionMessage {Game = game, PlayerCache = PlayerCache};
             msg.Game.PlayerGameMetrics = new List<PlayerGameMetrics>();
             if (pipeline != null) pipeline.Execute( msg );
        }
        private void DoRushingUnit(
            PlayerGameProjectionMessage input,
            string teamCode,
            bool isHome)
        {
            RushUnit ru;

            if (isHome)
            {
                ru = input.Game.HomeNflTeam.RunUnit;
            }
            else
            {
                ru = input.Game.AwayNflTeam.RunUnit;
            }

            if (ru == null)
            {
                ru = new RushUnit();
            }

            if (!ru.IsLoaded())
            {
                ru.Load(teamCode);
            }

            var pgms = new PlayerGameMetricsCollection(
                input.Game);
            var projTDr = isHome  ? input.Prediction.HomeTDr : input.Prediction.AwayTDr;

            projTDr = AllowForVultures(
                ru,
                projTDr,
                pgms);
            AllocateTDr(
                ru,
                projTDr,
                pgms);
            input.Game.PlayerGameMetrics = pgms.Pgms;

            var projYDr = isHome  ? input.Prediction.HomeYDr : input.Prediction.AwayYDr;

            AllocateYDr(
                ru,
                projYDr,
                pgms);

            if (ru.ThirdDownBack != null)
            {
                var projYDc = ( int )(.05 * (isHome  ? input.Prediction.HomeYDp : input.Prediction.AwayYDp));
                var pgm     = pgms.GetPgmFor(
                    ru.ThirdDownBack.PlayerCode);
                pgm.ProjYDc += projYDc;
                pgms.Update(pgm);
            }
        }
 public void TestAllocationToAce()
 {
     var msg = new PlayerGameProjectionMessage {Game = new NFLGame( "2013:01-B" )};
     var sut = new GetGamePrediction( msg );
     Assert.IsNotNull( msg.Prediction );
     Utility.Announce( msg.Prediction.PredictedScore() );
     var sut2 = new PullMetricsFromPrediction( msg );
     Assert.IsNotNull( msg.Game.PlayerGameMetrics );
     Assert.AreEqual( 1, msg.Game.PlayerGameMetrics.Count );
 }
        private void AddKickingPlayerGameMetric(PlayerGameProjectionMessage input,
                                                string playerId, int projFg, int projPat)
        {
            var pgm = new PlayerGameMetrics();

            pgm.PlayerId = playerId;
            pgm.GameKey  = input.Game.GameKey();
            pgm.ProjFG   = projFg;
            pgm.ProjPat  = projPat;
            input.Game.PlayerGameMetrics.Add(pgm);
        }
 public void TestASavingMetrics()
 {
     var msg = new PlayerGameProjectionMessage {Game = new NFLGame( "2013:01-B" )};
     var sut = new GetGamePrediction( msg );
     var sut2 = new PullMetricsFromPrediction( msg );
     var sut3 = new SavePlayerGameMetrics( msg );
     var dpgmDoa = new DbfPlayerGameMetricsDao();
     var pgmList = msg.Game.PlayerGameMetrics;
     var expectedPgm = pgmList.FirstOrDefault();
     var pgm = dpgmDoa.Get( expectedPgm.PlayerId, expectedPgm.GameKey );
     Assert.IsNotNull( pgm );
 }
 public void TestJayCutler()
 {
     var g = new NFLGame( "2016:01-I" );
      var msg = new PlayerGameProjectionMessage();
      msg.Player = new NFLPlayer( "CUTLJA01" );
      msg.Game = g;
      msg.Prediction = g.GetPrediction( "unit" );
      var cut = new PullMetricsFromPrediction( msg );
      Assert.IsNotNull( msg.Game.PlayerGameMetrics.Count > 12 );
      msg.Dao = new DbfPlayerGameMetricsDao();
      var saveStep = new SavePlayerGameMetrics( msg );
 }
 private void Process(PlayerGameProjectionMessage input)
 {
     DoRushingUnit(input, input.Game.HomeNflTeam.TeamCode, isHome: true);
     DoRushingUnit(input, input.Game.AwayNflTeam.TeamCode, isHome: false);
     DoPassingUnit(input, input.Game.HomeNflTeam.TeamCode, isHome: true);
     DoPassingUnit(input, input.Game.AwayNflTeam.TeamCode, isHome: false);
     DoKickingUnit(input, input.Game.HomeNflTeam.TeamCode, isHome: true);
     DoKickingUnit(input, input.Game.AwayNflTeam.TeamCode, isHome: false);
     if (input.Game.PlayerGameMetrics.Count < 12)
     {
         Utility.Announce(string.Format("Missing metrics from {0}", input.Game.ToString()));
     }
 }
 private static void AddKickingPlayerGameMetric(PlayerGameProjectionMessage input,
               string playerId, int projFg, int projPat)
 {
     if (input == null || playerId == null) return;
      var pgm = new PlayerGameMetrics
     {
        PlayerId = playerId,
        GameKey = input.Game.GameKey(),
        ProjFG = projFg,
        ProjPat = projPat
     };
      input.Game.PlayerGameMetrics.Add(pgm);
 }
        private void AddPassinglayerGameMetric(PlayerGameProjectionMessage input, string playerId, int projYDp, int projTDp)
        {
            var pgm = new PlayerGameMetrics();

            pgm.PlayerId = playerId;
            pgm.GameKey  = input.Game.GameKey();
            pgm.ProjYDp  = projYDp;
            pgm.ProjTDp  = projTDp;
#if DEBUG
            Utility.Announce(pgm.ToString());
#endif
            input.Game.PlayerGameMetrics.Add(pgm);
        }
예제 #13
0
        private void Process(PlayerGameProjectionMessage input)
        {
            var nMetrics = 0;

            foreach (var pgm in input.Game.PlayerGameMetrics)
            {
                pgm.Save(input.Dao);
                nMetrics++;
            }
#if DEBUG
            //Utility.Announce( string.Format( "Metrics saved {0} for {1}", nMetrics, input.Game.ToString() ) );
#endif
        }
        public void Execute(NFLGame game)
        {
            if (pipeline == null)
            {
                InitialiseThePipeLine();
            }

            var msg = new PlayerGameProjectionMessage();

            msg.Game = game;
            msg.Game.PlayerGameMetrics = new List <PlayerGameMetrics>();
            pipeline.Execute(msg);
        }
        private void AddCatchingPlayerGameMetric(PlayerGameProjectionMessage input,
                                                 string playerId, int projYDc, int projTDc)
        {
            var pgm = new PlayerGameMetrics();

            pgm.PlayerId = playerId;
            pgm.GameKey  = input.Game.GameKey();
            pgm.ProjYDc  = projYDc;
            pgm.ProjTDc  = projTDc;
#if DEBUG
            //Utility.Announce( pgm.ToString() );
#endif
            input.Game.PlayerGameMetrics.Add(pgm);
        }
 private static void AddPassinglayerGameMetric( PlayerGameProjectionMessage input, string playerId, int projYDp, int projTDp )
 {
     if (input == null || playerId == null) return;
      var pgm = new PlayerGameMetrics
     {
        PlayerId = playerId,
        GameKey = input.Game.GameKey(),
        ProjYDp = projYDp,
        ProjTDp = projTDp
     };
     #if DEBUG
      Utility.Announce(pgm.ToString());
     #endif
      input.Game.PlayerGameMetrics.Add(pgm);
 }
        private void DoKickingUnit(PlayerGameProjectionMessage input, string teamCode, bool isHome)
        {
            var kicker = GetKicker(teamCode);

            if (kicker != null)
            {
                var projFG  = (isHome) ? input.Prediction.HomeFg : input.Prediction.AwayFg;
                var projPat = (isHome) ? input.Prediction.TotalHomeTDs() : input.Prediction.TotalAwayTDs();
                AddKickingPlayerGameMetric(input, kicker.PlayerCode, projFG, projPat);
            }
            else
            {
                Utility.Announce(string.Format("No kicker found for {0}", teamCode));
            }
        }
 private static void AddPlayerGameMetric( PlayerGameProjectionMessage input, string playerId, int projYDr, decimal projTDr )
 {
     var pgm = new PlayerGameMetrics
     {
        PlayerId = playerId,
        GameKey = input.Game.GameKey(),
        ProjYDr = projYDr,
        ProjTDr = projTDr
     };
     #if DEBUG
      Utility.Announce( pgm.ToString() );
     #endif
      if (input.Game.PlayerGameMetrics == null) input.Game.PlayerGameMetrics = new List<PlayerGameMetrics>();
      input.Game.PlayerGameMetrics.Add( pgm );
 }
        private void DoRushingUnit(PlayerGameProjectionMessage input, string teamCode, bool isHome)
        {
            var ru = new RushUnit();

            ru.Load(teamCode);

            if (ru.IsAceBack)
            {
                //  R1
                var percentageOfAction = 0.7M;
                if (ru.R2 == null)
                {
                    percentageOfAction = 0.9M;
                }
                var projYDr = (int)(percentageOfAction * ((isHome) ? input.Prediction.HomeYDr : input.Prediction.AwayYDr));
                //  Injury penalty
                projYDr = AllowForInjuryRisk(ru.AceBack, projYDr);
                var projTDrAce = R1TdsFrom((isHome) ? input.Prediction.HomeTDr : input.Prediction.AwayTDr);
                var isVulture  = AllowForVulturing(ru.AceBack.PlayerCode, ref projTDrAce, ru);
                AddPlayerGameMetric(input, ru.AceBack.PlayerCode, projYDr, projTDrAce);
                //  R2 optional
                if (ru.R2 != null)
                {
                    projYDr = (int)(.2 * ((isHome) ? input.Prediction.HomeYDr : input.Prediction.AwayYDr));
                    projYDr = AllowForInjuryRisk(ru.AceBack, projYDr);
                    int projTDr = R2TdsFrom((isHome) ? input.Prediction.HomeTDr : input.Prediction.AwayTDr);
                    if (isVulture)
                    {
                        projTDr = AllowForR2BeingTheVulture(projTDr, ru.R2.PlayerCode, ru);
                    }
                    AddPlayerGameMetric(input, ru.R2.PlayerCode, projYDr, projTDr);
                }
            }
            else
            {
                //  Comittee
                var percentageOfAction = 0.5M;
                foreach (var runner in ru.Starters)
                {
                    var projYDr = (int)(percentageOfAction * ((isHome) ? input.Prediction.HomeYDr : input.Prediction.AwayYDr));
                    projYDr = AllowForInjuryRisk(runner, projYDr);
                    var projTDr = R1TdsFrom((isHome) ? input.Prediction.HomeTDr : input.Prediction.AwayTDr);

                    AddPlayerGameMetric(input, runner.PlayerCode, projYDr, projTDr);
                }
            }
        }
예제 #20
0
 public PullMetricsFromPrediction(PlayerGameProjectionMessage input)
 {
     Logger = LogManager.GetCurrentClassLogger();
     tdrAllocationStrategies = new Dictionary <RunApproach, IAllocateTDrStrategy>
     {
         { RunApproach.Ace, new AceAllocateTDrStrategy() },
         { RunApproach.Standard, new StandardAllocateTDrStrategy() },
         { RunApproach.Committee, new CommitteeAllocateTDrStrategy() }
     };
     ydrAllocationStrategies = new Dictionary <RunApproach, IAllocateYDrStrategy>
     {
         { RunApproach.Ace, new AceAllocateYDrStrategy() },
         { RunApproach.Standard, new StandardAllocateYDrStrategy() },
         { RunApproach.Committee, new CommitteeAllocateYDrStrategy() }
     };
     Process(input);
 }
        private static void AddKickingPlayerGameMetric(PlayerGameProjectionMessage input,
                                                       string playerId, int projFg, int projPat)
        {
            if (input == null || playerId == null)
            {
                return;
            }
            var pgm = new PlayerGameMetrics
            {
                PlayerId = playerId,
                GameKey  = input.Game.GameKey(),
                ProjFG   = projFg,
                ProjPat  = projPat
            };

            input.Game.PlayerGameMetrics.Add(pgm);
        }
        private static void AddPlayerGameMetric(PlayerGameProjectionMessage input, string playerId, int projYDr, int projTDr)
        {
            var pgm = new PlayerGameMetrics();

            pgm.PlayerId = playerId;
            pgm.GameKey  = input.Game.GameKey();
            pgm.ProjYDr  = projYDr;
            pgm.ProjTDr  = projTDr;
#if DEBUG
            Utility.Announce(pgm.ToString());
#endif
            if (input.Game.PlayerGameMetrics == null)
            {
                input.Game.PlayerGameMetrics = new List <PlayerGameMetrics>();
            }
            input.Game.PlayerGameMetrics.Add(pgm);
        }
예제 #23
0
        private static void AddPassinglayerGameMetric(PlayerGameProjectionMessage input, string playerId, int projYDp, int projTDp)
        {
            if (input == null || playerId == null)
            {
                return;
            }
            var pgm = new PlayerGameMetrics
            {
                PlayerId = playerId,
                GameKey  = input.Game.GameKey(),
                ProjYDp  = projYDp,
                ProjTDp  = projTDp
            };

#if DEBUG
            Utility.Announce(pgm.ToString());
#endif
            input.Game.PlayerGameMetrics.Add(pgm);
        }
예제 #24
0
        private void Process(PlayerGameProjectionMessage input)
        {
            if (input.Game == null)
            {
                return;
            }

            Logger.Trace($"Processing {input.Game.GameCodeOut()}:{input.Game.GameName()}");
            DoRushingUnit(input, input.Game.HomeNflTeam.TeamCode, isHome: true);
            DoRushingUnit(input, input.Game.AwayNflTeam.TeamCode, isHome: false);

            DoPassingUnit(input, input.Game.HomeNflTeam.TeamCode, isHome: true);
            DoPassingUnit(input, input.Game.AwayNflTeam.TeamCode, isHome: false);

            DoKickingUnit(input, input.Game.HomeNflTeam.TeamCode, isHome: true);
            DoKickingUnit(input, input.Game.AwayNflTeam.TeamCode, isHome: false);
            if (input.Game.PlayerGameMetrics.Count < 12)
            {
                Utility.Announce(string.Format("Missing metrics from {0}", input.Game));
            }
        }
 public void TestVulture()
 {
     var msg = new PlayerGameProjectionMessage {Game = new NFLGame( "2013:04-I" ) {PlayerGameMetrics = new List<PlayerGameMetrics>()}};
     var sut = new GetGamePrediction( msg );
     Assert.IsNotNull( msg.Prediction );
     Utility.Announce( msg.Prediction.PredictedScore() );
     var sut2 = new PullMetricsFromPrediction( msg );
     Assert.IsNotNull( msg.Game.PlayerGameMetrics );
     Assert.IsTrue( msg.Game.PlayerGameMetrics.Count > 0 );
 }
        private static void DoRushingUnit( PlayerGameProjectionMessage input, string teamCode, bool isHome )
        {
            var ru = new RushUnit();
             ru.Load( teamCode );

             if (ru.IsAceBack)
             {
            //  R1
            var percentageOfAction = 0.7M;
            if (ru.R2 == null) percentageOfAction = 0.9M;
            var projYDr = (int)(percentageOfAction * ((isHome) ? input.Prediction.HomeYDr : input.Prediction.AwayYDr));
            //  Injury penalty
            projYDr = AllowForInjuryRisk(ru.AceBack, projYDr);
            var projTDrAce = R1TdsFrom((isHome) ? input.Prediction.HomeTDr : input.Prediction.AwayTDr);
            var isVulture = AllowForVulturing(ru.AceBack.PlayerCode, ref projTDrAce, ru);
            AddPlayerGameMetric(input, ru.AceBack.PlayerCode, projYDr, projTDrAce);
            //  R2 optional
            if (ru.R2 != null)
            {
               projYDr = (int)(.2 * ((isHome) ? input.Prediction.HomeYDr : input.Prediction.AwayYDr));
               projYDr = AllowForInjuryRisk(ru.AceBack, projYDr);
               var projTDr = R2TdsFrom((isHome) ? input.Prediction.HomeTDr : input.Prediction.AwayTDr);
               if (isVulture)
                  projTDr = AllowForR2BeingTheVulture(projTDr, ru.R2.PlayerCode, ru);
               AddPlayerGameMetric(input, ru.R2.PlayerCode, projYDr, projTDr);
            }
             }
             else
             {
            //  Comittee
            const decimal percentageOfAction = 0.5M;
            foreach (var runner in ru.Starters)
            {
               var projYDr = (int)(percentageOfAction * ((isHome) ? input.Prediction.HomeYDr : input.Prediction.AwayYDr));
               projYDr = AllowForInjuryRisk(runner, projYDr);
               var projTDr = 0M;
               var tds = 0;
               if ( isHome )
               {
                  tds = R1TdsFrom( input.Prediction.HomeTDr );
                  projTDr = decimal.Divide( ( decimal ) tds, 2M );
               }
               else
               {
                  tds = R1TdsFrom( input.Prediction.AwayTDr );
                  projTDr = decimal.Divide( ( decimal ) tds, 2M );
               }

               AddPlayerGameMetric( input, runner.PlayerCode, projYDr, projTDr);
            }
             }
        }
        private void Process( PlayerGameProjectionMessage input )
        {
            if (input.Game == null) return;

             Logger.Trace( string.Format( "Processing {0}:{1}", input.Game.GameCodeOut(), input.Game.GameName() ) );
             DoRushingUnit( input, input.Game.HomeNflTeam.TeamCode, isHome: true );
             DoRushingUnit( input, input.Game.AwayNflTeam.TeamCode, isHome: false );
             DoPassingUnit( input, input.Game.HomeNflTeam.TeamCode, isHome: true );
             DoPassingUnit( input, input.Game.AwayNflTeam.TeamCode, isHome: false );
             DoKickingUnit( input, input.Game.HomeNflTeam.TeamCode, isHome: true );
             DoKickingUnit( input, input.Game.AwayNflTeam.TeamCode, isHome: false );
             if ( input.Game.PlayerGameMetrics.Count < 12 )
            Utility.Announce( string.Format( "Missing metrics from {0}", input.Game ) );
        }
예제 #28
0
 public GetGamePrediction(PlayerGameProjectionMessage input)
 {
     Process(input);
 }
 public PullMetricsFromPrediction(PlayerGameProjectionMessage input)
 {
     Process(input);
 }
예제 #30
0
 public SavePlayerGameMetrics(PlayerGameProjectionMessage input)
 {
     Process(input);
 }
 private void AddCatchingPlayerGameMetric(PlayerGameProjectionMessage input, 
  string playerId, int projYDc, int projTDc)
 {
     if (input == null || playerId == null) return;
      if (string.IsNullOrEmpty( playerId ) || input.Game == null) return;
      var pgm = new PlayerGameMetrics
     {
        PlayerId = playerId,
        GameKey = input.Game.GameKey(),
        ProjYDc = projYDc,
        ProjTDc = projTDc
     };
     #if DEBUG
      Utility.Announce(pgm.ToString());
     #endif
      input.Game.PlayerGameMetrics.Add(pgm);
 }
        private void DoPassingUnit( PlayerGameProjectionMessage input, string teamCode, bool isHome )
        {
            var unit = new PassUnit();
             unit.Load( teamCode );

             // give it to the QB
             if ( unit.Q1 != null )
             {
            var projYDp = ( isHome ) ? input.Prediction.HomeYDp : input.Prediction.AwayYDp;
            var projTDp = ( isHome ) ? input.Prediction.HomeTDp : input.Prediction.AwayTDp;
            AddPassinglayerGameMetric( input, unit.Q1.PlayerCode, projYDp, projTDp );
             }
             // Receivers
             int projYDc, projTDc;
             if (unit.W1 != null)
             {
            projYDc = (int)(.4 * ((isHome) ? input.Prediction.HomeYDp : input.Prediction.AwayYDp));
            projTDc = W1TdsFrom((isHome) ? input.Prediction.HomeTDp : input.Prediction.AwayTDp);
            projYDc = AllowForInjuryRisk(unit.W1, projYDc);
            AddCatchingPlayerGameMetric(input, unit.W1.PlayerCode, projYDc, projTDc);
             }
             if (unit.W2 != null)
             {
            projYDc = (int)(.25 * ((isHome) ? input.Prediction.HomeYDp : input.Prediction.AwayYDp));
            projTDc = W2TdsFrom((isHome) ? input.Prediction.HomeTDp : input.Prediction.AwayTDp);
            projYDc = AllowForInjuryRisk(unit.W2, projYDc);
            AddCatchingPlayerGameMetric(input, unit.W2.PlayerCode, projYDc, projTDc);
             }
             if (unit.W3 != null)
             {
            projYDc = (int)(.1 * ((isHome) ? input.Prediction.HomeYDp : input.Prediction.AwayYDp));
            projTDc = 0;
            projYDc = AllowForInjuryRisk( unit.W3, projYDc );
            AddCatchingPlayerGameMetric(input, unit.W3.PlayerCode, projYDc, projTDc);
             }
             if (unit.TE != null)
             {
            projYDc = (int)(.25 * ((isHome) ? input.Prediction.HomeYDp : input.Prediction.AwayYDp));
            projTDc = TETdsFrom((isHome) ? input.Prediction.HomeTDp : input.Prediction.AwayTDp);
            projYDc = AllowForInjuryRisk(unit.TE, projYDc);
            AddCatchingPlayerGameMetric(input, unit.TE.PlayerCode, projYDc, projTDc);
             }
        }
        private void DoPassingUnit(
            PlayerGameProjectionMessage input,
            string teamCode,
            bool isHome)
        {
            PassUnit unit;
            RushUnit rushUnit;

            if (isHome)
            {
                unit     = input.Game.HomeNflTeam.PassUnit;
                rushUnit = input.Game.HomeNflTeam.RunUnit;
            }
            else
            {
                unit     = input.Game.AwayNflTeam.PassUnit;
                rushUnit = input.Game.AwayNflTeam.RunUnit;
            }

            if (unit == null)
            {
                unit = new PassUnit();
            }
            if (!unit.IsLoaded())
            {
                unit.Load(teamCode);
            }
            if (rushUnit == null)
            {
                rushUnit = new RushUnit();
            }
            if (!rushUnit.IsLoaded())
            {
                rushUnit.Load(teamCode);
            }

            // give it to the QB
            if (unit.Q1 != null)
            {
                var projYDp = isHome  ? input.Prediction.HomeYDp : input.Prediction.AwayYDp;
                var projTDp = isHome  ? input.Prediction.HomeTDp : input.Prediction.AwayTDp;
                AddPassinglayerGameMetric(
                    input,
                    unit.Q1.PlayerCode,
                    projYDp,
                    projTDp);
            }
            // Receivers  W1 35%, W2 25%, W3 10%, TE 20% (todo 3D 5%)
            int projYDc, projTDc;

            if (unit.W1 != null)
            {
                projYDc = ( int )(.35 * (isHome  ? input.Prediction.HomeYDp : input.Prediction.AwayYDp));
                projTDc = W1TdsFrom(
                    isHome  ? input.Prediction.HomeTDp : input.Prediction.AwayTDp);
                projYDc = AllowForInjuryRisk(
                    unit.W1,
                    projYDc);
                AddCatchingPlayerGameMetric(
                    input,
                    unit.W1.PlayerCode,
                    projYDc,
                    projTDc);
            }
            if (unit.W2 != null)
            {
                projYDc = ( int )(.25 * (isHome  ? input.Prediction.HomeYDp : input.Prediction.AwayYDp));
                projTDc = W2TdsFrom(isHome  ? input.Prediction.HomeTDp : input.Prediction.AwayTDp);
                projYDc = AllowForInjuryRisk(
                    unit.W2,
                    projYDc);
                AddCatchingPlayerGameMetric(
                    input,
                    unit.W2.PlayerCode,
                    projYDc,
                    projTDc);
            }
            if (unit.W3 != null)
            {
                projYDc = ( int )(.15 * (isHome  ? input.Prediction.HomeYDp : input.Prediction.AwayYDp));
                projTDc = W3TdsFrom(isHome ? input.Prediction.HomeTDp : input.Prediction.AwayTDp);

                projYDc = AllowForInjuryRisk(
                    unit.W3,
                    projYDc);
                AddCatchingPlayerGameMetric(
                    input,
                    unit.W3.PlayerCode,
                    projYDc,
                    projTDc);
            }
            if (unit.TE != null)
            {
                projYDc = ( int )(.20 * (isHome  ? input.Prediction.HomeYDp : input.Prediction.AwayYDp));
                projTDc = TETdsFrom(isHome  ? input.Prediction.HomeTDp : input.Prediction.AwayTDp);
                projYDc = AllowForInjuryRisk(unit.TE, projYDc);
                AddCatchingPlayerGameMetric(input, unit.TE.PlayerCode, projYDc, projTDc);
            }
        }
 private void DoKickingUnit(PlayerGameProjectionMessage input, string teamCode, bool isHome)
 {
     var kicker = GetKicker(teamCode);
      if ( kicker != null )
      {
     var projFG = ( isHome ) ? input.Prediction.HomeFg : input.Prediction.AwayFg;
     var projPat = ( isHome ) ? input.Prediction.TotalHomeTDs() : input.Prediction.TotalAwayTDs();
     AddKickingPlayerGameMetric( input, kicker.PlayerCode, projFG, projPat );
      }
      else
     Utility.Announce( string.Format( "No kicker found for {0}", teamCode ) );
 }
 public PullMetricsFromPrediction( PlayerGameProjectionMessage input )
 {
     Logger = LogManager.GetCurrentClassLogger();
      Process( input );
 }
예제 #36
0
 private void Process(PlayerGameProjectionMessage input)
 {
     input.Dao = new DbfPlayerGameMetricsDao();
     input.Dao.ClearGame(input.Game.GameKey());
 }
예제 #37
0
 private void Process(PlayerGameProjectionMessage input)
 {
     input.Prediction = input.Game.GetPrediction("unit");
 }
 public void TestPullMetrics()
 {
     var msg = new PlayerGameProjectionMessage {Game = new NFLGame( "2016:01-N" )};
     var sut = new GetGamePrediction(msg);
     var sut2 = new PullMetricsFromPrediction(msg);
     Assert.IsNotNull(sut2);
 }