/// <summary> /// Gets information for all games played by a specified NFL team /// </summary> /// <param name="team">Contains specific team abbreviation (i.e. NYG for New York Giants)</param> /// <returns>List string[] Containing information for all games played by specified NFL team</returns> public List <Game> GetGames() { List <Team> teams = new TeamRequest(new Season(season.year, season.playoffs)).GetTeams(); List <Game> games = new List <Game>(); foreach (Team team in teams) { Thread.Sleep(10000); string TeamGames = "/team_gamelogs.json?team=" + team.abbr; JArray allGames = (JArray)JObject.Parse(Submit(TeamGames))["teamgamelogs"]["gamelogs"]; Game game; foreach (JToken gameInfo in allGames) { game = new Game(); game.homeTeam = new Team(); game.awayTeam = new Team(); game.gameid = (string)gameInfo["game"]["id"]; game.date = (string)gameInfo["game"]["date"]; game.time = (string)gameInfo["game"]["time"]; game.awayTeam.abbr = (string)gameInfo["game"]["awayTeam"]["Abbreviation"]; game.homeTeam.abbr = (string)gameInfo["game"]["homeTeam"]["Abbreviation"]; games.Add(game); } } Thread.Sleep(10000); return(games); }
/// <summary> /// Gets defensive game statistics of a specified NFL team /// </summary> /// <param name="team">Contains specific team abbreviation (i.e. NYG for New York Giants)</param> /// <returns></returns> public List <Defense> GetGameStats() { List <Team> teams = new TeamRequest(new Season(season.year, season.playoffs)).GetTeams(); List <Defense> defenses = new List <Defense>(); foreach (Team team in teams) { Thread.Sleep(10000); string DefGames = "/team_gamelogs.json?team=" + team.abbr; JArray allGames = (JArray)JObject.Parse(Submit(DefGames))["teamgamelogs"]["gamelogs"]; Team currentTeam = team; Game currentGame; DefenseStats currentStats; DefenseGameStats currentGameStats; Defense currentDefense = new Defense(currentTeam.abbr, new List <DefenseGameStats>()); foreach (JToken game in allGames) { currentGame = new Game((string)game["game"]["id"]); currentStats = new DefenseStats(); currentStats.pa = (string)game["stats"]["PointsAgainst"]["#text"]; currentStats.sck = (string)game["stats"]["Sacks"]["#text"]; currentStats.fum = (string)game["stats"]["FumForced"]["#text"]; currentStats.intc = (string)game["stats"]["Interceptions"]["#text"]; currentStats.intTd = (string)game["stats"]["IntTD"]["#text"]; currentStats.fumTd = (string)game["stats"]["FumTD"]["#text"]; currentStats.sfty = (string)game["stats"]["Safeties"]["#text"]; currentStats.krTd = (string)game["stats"]["KrTD"]["#text"]; currentStats.prTd = (string)game["stats"]["PrTD"]["#text"]; currentStats.fgBlk = (string)game["stats"]["FgBlk"]["#text"]; currentStats.xpBlk = (string)game["stats"]["XpBlk"]["#text"]; currentGameStats = new DefenseGameStats(currentGame, currentStats); currentDefense.gameLogs.Add(currentGameStats); } defenses.Add(currentDefense); } Thread.Sleep(10000); return(defenses); }