示例#1
0
        public void TestRushingUnitIsAce()
        {
            var sut = new RushUnit();

            sut.Load("SF");
            Assert.IsNotNull(sut.AceBack);
            Utility.Announce(string.Format("Ace Back is {0}", sut.AceBack.PlayerName));
        }
示例#2
0
        public void TestRushingUnitIsRBBC()
        {
            var sut = new RushUnit();

            sut.Load("PS");
            Assert.IsNull(sut.AceBack);
            Utility.Announce(string.Format("Back 1 is {0}", sut.R1.PlayerName));
            Utility.Announce(string.Format("Back 2 is {0}", sut.R2.PlayerName));
        }
示例#3
0
 public List<string> LoadRushUnit()
 {
     #if DEBUG
      Utility.Announce( "NFLTeam.LoadRushUnit" );
     #endif
      if (RushUnit == null) RushUnit = new RushUnit();
      return RushUnit.Load(TeamCode);
 }
 private static int AllowForR2BeingTheVulture( int projTDr, string r2Id, RushUnit ru )
 {
     if ( r2Id == ru.GoalLineBack.PlayerCode )
     projTDr++;
      return projTDr;
 }
        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 static bool AllowForVulturing( string runnerId, ref int projTDr, RushUnit ru )
        {
            var isVulture = false;

             if ( projTDr > 0 )
             {
            if ( ru.GoalLineBack != null )
            {
               if ( ru.GoalLineBack.PlayerCode != runnerId )
               {
                  //  Vulture
                  projTDr--;
                  isVulture = true;
               }
            }
             }
             return isVulture;
        }