コード例 #1
0
 public void AddWeeklyOutput(int week, int output, string opponent, bool bHome)
 {
     if (week > 0)
     {
         _total += output;
         var so = new SeasonOpposition(opponent, bHome, output);
         _opps[week - 1] = so;
     }
 }
コード例 #2
0
 public void AddPrevWeeklyOutput(int week, SeasonOpposition soIn)
 {
     if (week > 0)
     {
         if (week < 18)
         {
             _prevOpp[week - 1] = soIn;
         }
     }
 }
コード例 #3
0
        private string LinkedCellContent(SeasonOpposition opp, int k, string teamCode)
        {
            if (opp.Opponent.Equals("BYE"))
            {
                return(HtmlLib.TableDataAttr("   ", "ALIGN='CENTER' BGCOLOR='WHITE'"));
            }

            var rawdata    = ProjectionUrl(opp.Metric, opp.Opponent, opp.IsHome(), teamCode, k + 1);
            var formatting = $"ALIGN='CENTER' BGCOLOR='{MetricColour( opp.Metric )}'";

            return(HtmlLib.TableDataAttr(rawdata, formatting));
        }
コード例 #4
0
 public NFLOutputMetric(string metricIn, NFLPlayer playerIn, NflTeam teamIn)
 {
     _metricName  = metricIn;
     _player      = playerIn;
     _team        = teamIn;
     _team.Wins   = 0;
     _team.Losses = 0;
     _prevOpp     = new SeasonOpposition[KOpponents];
     _opps        = new SeasonOpposition[KOpponents];
     for (var i = 0; i < KOpponents; i++)
     {
         _opps[i]    = new SeasonOpposition("BYE", true, 0);
         _prevOpp[i] = new SeasonOpposition("   ", true, 0);
     }
 }
コード例 #5
0
        private string CellContent(SeasonOpposition opp)
        {
            if (string.IsNullOrEmpty(opp.Opponent.Trim()))
            {
                return(HtmlLib.TableDataAttr("BYE", "ALIGN='CENTER' BGCOLOR='WHITE'"));
            }

            if (opp.Metric == 0)
            {
                return(HtmlLib.TableDataAttr("tie", "ALIGN='CENTER' BGCOLOR='TOMATO'"));
            }

            var rawdata    = opp.Metric.ToString(CultureInfo.InvariantCulture);
            var formatting = $"ALIGN='CENTER' BGCOLOR='{MetricColour( opp.Metric )}'";

            return(HtmlLib.TableDataAttr(rawdata, formatting));
        }
コード例 #6
0
ファイル: NFLTeam.cs プロジェクト: Quarterback16/GerardGui
        /// <summary>
        ///   Puts the number of FGs allowed per game into the fgResultlist.
        ///   This balances off the kickers results.
        ///   Need to include 0 games.
        ///   Only go back to last season.
        /// </summary>
        private static ArrayList GetFGallowed(string oppteamCode)
        {
            //  Get the schedule for last season for the opponent

             ArrayList fgAllowed = new ArrayList();

             DataSet ds = Utility.TflWs.TeamSchedDs(Utility.LastSeason(), oppteamCode);
             DataTable dt = ds.Tables["sched"];
             //  For each game on their schedule
             foreach (DataRow dr in dt.Rows)
             {
            string week = dr["WEEK"].ToString();
            string gameNo = dr["GAMENO"].ToString();
            string gameCode = Utility.LastSeason() + week + gameNo;
            string opponentsOpponent = dr["HOMETEAM"].ToString() == oppteamCode
                                          ? dr["AWAYTEAM"].ToString()
                                          : dr["HOMETEAM"].ToString();
            //  How many FGs did their opponents score?
            DataSet scores =
               Utility.TflWs.GetTeamScoresFor("3", opponentsOpponent,
                                              Utility.LastSeason(), week, gameNo);
            int fgsAllowed = scores.Tables[0].Rows.Count;
            SeasonOpposition so = new SeasonOpposition(opponentsOpponent, false, fgsAllowed);

            fgAllowed.Add(new FieldGoalResult(gameCode, so));
             }
             return fgAllowed;
        }
コード例 #7
0
ファイル: NFLTeam.cs プロジェクト: Quarterback16/GerardGui
        public string SeasonProjection(IPrognosticate strategy, string metricName, DateTime projectionDate)
        {
            if (strategy == null) return String.Empty;

             strategy.AuditTrail = true;

             NFLResult result;
             NFLGame game;
             int metric;

             //  Lazy intitialisation of the sched
             if (_sched == null) InitialiseProjections();

             var om = new NFLOutputMetric(metricName, null, this);

             //  Go through the schedule and predict the games
             //  Clear win totals
             var projWins = 0;
             var projLosses = 0;
             var projTies = 0;

             if ((_sched != null) && (_sched.GameList != null))
             {
            //  load the projections
            for (var i = 0; i < _sched.GameList.Count; i++)
            {
               if (i > 15) continue;
               game = (NFLGame)_sched.GameList[i];
               result = strategy.PredictGame(game, new DbfPredictionStorer(), projectionDate);
            #if DEBUG
               Utility.Announce(result.LogResult());
            #endif
               metric = metricName == "Spread"
                           ? Convert.ToInt32(((game.IsHome(TeamCode)) ? result.Spread : 0.0M-(result.Spread)))
                           : (metricName == "Tdp"
                                 ? ((game.IsHome(TeamCode)) ? result.HomeTDp : result.AwayTDp)
                                 : ((game.IsHome(TeamCode)) ? result.HomeTDr : result.AwayTDr));

               if (metric > 0) projWins++;
               if (metric == 0) projTies++;
               if (metric < 0) projLosses++;

               om.AddWeeklyOutput(
                  Int32.Parse(game.Week), metric,
                  game.Opponent(TeamCode), game.IsHome(TeamCode));
            }
             }
             if (metricName == "Spread")
             {
            //  Load up previous results
            if (_prevSched.GameList != null)
            {
               foreach (NFLGame g in _prevSched.GameList)
               {
                  if (Int32.Parse(g.Week) < 18)
                  {
                     result = g.Result;
                     metric = Convert.ToInt32((g.IsHome(TeamCode)) ? result.Spread : 0.0M-(result.Spread));
                     ApplyPrevResult(metric);
                     var so =
                        new SeasonOpposition(g.Opponent(TeamCode), g.IsHome(TeamCode), metric);
                     om.AddPrevWeeklyOutput(Int32.Parse(g.Week), so);
                  }
               }
            }
             }

             if (ProjectionList == null) ProjectionList = new ArrayList();

             ProjectionList.Add(om); //  store it for later

             Wins = projWins;
             Losses = projLosses;
             Ties = projTies;

             return om.RenderAsHtml();
        }
コード例 #8
0
ファイル: NFLTeam.cs プロジェクト: Quarterback16/GerardGui
        public void LoadKicker()
        {
            _fgResultList = new ArrayList();
             var fgCount = 0;
             _kicker = GetPlayerAt("PK", 1, false, false); //  depends on the Kicking unit being loaded
             string gameCode = String.Empty;
             string loWeek = "999999";
             string hiWeek = "000000";

             if (_kicker != null)
             {
            //  Get all the Scores for this kicker
            var ds = Utility.TflWs.GetScoresFor("3", _kicker.PlayerCode);
            var dt = ds.Tables["score"];
            if (dt.Rows.Count > 0)
            {
               string lastGameCode = string.Format("{0}{1}{2}", dt.Rows[0]["SEASON"],
                                                   dt.Rows[0]["WEEK"], dt.Rows[0]["GAMENO"]);

               foreach (DataRow dr in dt.Rows)
               {
                  //  for each score in the game

                  string gameWeek = string.Format("{0}{1}", dr["SEASON"], dr["WEEK"]);

                  gameCode = gameWeek + dr["GAMENO"];

                  if (gameCode != lastGameCode)
                  {
                     //  Add the result to the kickers list
                     SeasonOpposition so = GetLastOpp(lastGameCode, fgCount);
                     _fgResultList.Add(new FieldGoalResult(gameCode, so));
                     fgCount = 0;
                     lastGameCode = gameCode;
                  }
                  fgCount++;
                  if (string.Compare(gameWeek, loWeek) < 0) loWeek = gameWeek;
                  if (string.Compare(gameWeek, hiWeek) > 0) hiWeek = gameWeek;
               }
               _fgResultList.Add(new FieldGoalResult(gameCode, GetLastOpp(lastGameCode, fgCount)));
               //  How many weeks in the range
               _kicker.SetHiWeek(hiWeek);
               _kicker.SetLoWeek(loWeek);

               int nRange = WeekRange(loWeek, hiWeek);

               //  Add goose eggs for the difference
               int diff = nRange - _fgResultList.Count;
               var soDud = new SeasonOpposition("   ", false, 0);
               for (int i = 1; i < diff; i++)
                  _fgResultList.Add(new FieldGoalResult(loWeek, soDud));
            }
             }
        }