private void CalculateFpts(NflTeam team) { // Process Stats and Scores for the week // save the calculations var ds = Utility.TflWs.GameForTeam(Season, Week, team.TeamCode); if (ds.Tables[0].Rows.Count != 1) { return; } DataRow teamRow = Data.NewRow(); teamRow["TEAM"] = team.NameOut(); teamRow["TOTAL"] = 0; teamRow["SCORE"] = 0; var game = new NFLGame(ds.Tables[0].Rows[0]); teamRow["RESULT"] = game.ResultFor(team.TeamCode, abbreviate: true, barIt: false); teamRow["SCORE"] = game.ScoreFor(team); List <NFLPlayer> playerList = new List <NFLPlayer>(); if (game.IsAway(team.TeamCode)) { playerList = game.LoadAllFantasyAwayPlayers(); } else { playerList = game.LoadAllFantasyHomePlayers(); } var totPts = 0.0M; var qbPts = 0.0M; var rbPts = 0.0M; var wrPts = 0.0M; var tePts = 0.0M; var pkPts = 0.0M; var week = new NFLWeek(Season, Week); TallyPts(playerList, ref totPts, ref qbPts, ref rbPts, ref wrPts, ref tePts, ref pkPts, week); teamRow["TOTAL"] = totPts; teamRow["QB"] = qbPts; teamRow["RB"] = rbPts; teamRow["WR"] = wrPts; teamRow["TE"] = tePts; teamRow["PK"] = pkPts; teamRow["DEF"] = game.DefensiveFantasyPtsFor(team.TeamCode); Data.Rows.Add(teamRow); }
public NFLPlayer TopDog(NflTeam team, string theWeek, DataSet gameDs) { var game = new NFLGame(gameDs.Tables[0].Rows[0]); var week = new NFLWeek(Season, theWeek); var scorer = new YahooXmlScorer(week); List <NFLPlayer> playerList = new List <NFLPlayer>(); if (game.IsAway(team.TeamCode)) { playerList = game.LoadAllFantasyAwayPlayers(null, PositionCategory); } else { playerList = game.LoadAllFantasyHomePlayers(null, PositionCategory); } NFLPlayer topDog = new NFLPlayer() { Points = 0 }; foreach (var p in playerList) { if (PositionAbbr == "TE") { if (!p.IsTe()) { continue; } } if (PositionAbbr == "QB") { if (!p.IsQb()) { continue; } } p.Points = scorer.RatePlayer(p, week); if (p.Points > topDog.Points) { topDog = p; } } return(topDog); }
private decimal CalculateFpts(NflTeam team, string theWeek, DataSet gameDs) { // Process Stats and Scores for the week // save the calculations var game = new NFLGame(gameDs.Tables[0].Rows[0]); List <NFLPlayer> playerList = new List <NFLPlayer>(); if (game.IsAway(team.TeamCode)) { playerList = game.LoadAllFantasyAwayPlayers(null, PositionCategory); } else { playerList = game.LoadAllFantasyHomePlayers(null, PositionCategory); } var pts = 0.0M; var week = new NFLWeek(Season, theWeek); pts = TallyPts(playerList, week, team.TeamCode); return(pts); }
private FptsAllowed CalculateFptsAllowed( NflTeam team, string theWeek, DataSet gameDs) { // Process Stats and Scores for the week // save the calculations var ftpsAllowed = new FptsAllowed(team.TeamCode); var game = new NFLGame(gameDs.Tables[0].Rows[0]); List <NFLPlayer> playerList = new List <NFLPlayer>(); if (game.IsAway(team.TeamCode)) { playerList = game.LoadAllFantasyHomePlayers( (DateTime?)game.GameDate, String.Empty); } else { playerList = game.LoadAllFantasyAwayPlayers( ( DateTime? )game.GameDate, String.Empty); } var week = new NFLWeek(Season, theWeek); var scorer = new YahooXmlScorer(week); foreach (var p in playerList) { var plyrPts = scorer.RatePlayer(p, week); if (p.IsQuarterback()) { ftpsAllowed.ToQbs += plyrPts; AddBreakdownLine(team, theWeek, p, plyrPts, "QB"); } else if (p.IsRb()) { ftpsAllowed.ToRbs += plyrPts; AddBreakdownLine(team, theWeek, p, plyrPts, "RB"); } else if (p.IsWideout()) { ftpsAllowed.ToWrs += plyrPts; AddBreakdownLine(team, theWeek, p, plyrPts, "WR"); } else if (p.IsTe()) { ftpsAllowed.ToTes += plyrPts; AddBreakdownLine(team, theWeek, p, plyrPts, "TE"); } else if (p.IsKicker()) { ftpsAllowed.ToPks += plyrPts; AddBreakdownLine(team, theWeek, p, plyrPts, "PK"); } } return(ftpsAllowed); }