public void UpdateForSeason(SeasonType type, int startingYear) { // get all games for the season var teamGameLogs = NBAStats.GetTeamGameLogs(startingYear, type, "0", null, null); // iterate through unique games var uniqueGamesIds = teamGameLogs.Tables[0].AsEnumerable().Select(r => r.Field <String>("GAME_ID")).Distinct(); // Check if the game has been processes Dictionary <string, DataSet> gameResults = new Dictionary <string, DataSet>(); Parallel.ForEach(uniqueGamesIds, new ParallelOptions { MaxDegreeOfParallelism = 1 }, (gameId) => { gameResults.Add(gameId + "_BoxScoreSummary", NBAStats.GetBoxscoreSummary(gameId)); gameResults.Add(gameId + "_BoxScoreWholeGame", NBAStats.GetBoxScoreTraditionalV2(gameId)); //gameResults.Add(gameId + "_PlayByPlayV2", NBAStats.GetPlayByPlayV2(gameId)); //gameResults.Add(gameId + "_PlayByPlay", NBAStats.GetPlayByPlay(gameId)); }); // Insert box scores in sequence foreach (KeyValuePair <string, DataSet> kvp in gameResults) { _db.InsertData(kvp.Value); } // Insert all games _db.InsertData(teamGameLogs); }
private void DeleteSeasonIfExists() { SeasonType seasonType = Database.SeasonTypes.Where(st => st.Name == SourceSeason.Type).First(); League league = Database.Leagues.Where(l => l.Acronym == SourceSeason.LeagueAcronym).First(); var matchedSeasons = Database.Seasons .Where(a => a.Number == SourceSeason.Number) .Where(a => a.SeasonType.Id == seasonType.Id) .Where(a => a.League.Id == league.Id) .ToList(); int seasonCount = matchedSeasons.Count(); foreach (var dbSeason in matchedSeasons) { Database.SkaterSeasonStats.RemoveRange(dbSeason.SkaterSeasonStats); Database.GoalieSeasonStats.RemoveRange(dbSeason.GoalieSeasonStats); dbSeason.Teams.Clear(); Database.Seasons.Remove(dbSeason); } if (seasonCount > 0) { Database.SaveChanges(); } }
public void StoreGamesForWeek(int week, int season, SeasonType seasonType, IEnumerable<Game> games) { var collectionName = Helpers.GetCollectionName(week, season, seasonType); var collection = _database.GetCollection<Game>(collectionName); collection.InsertManyAsync(games); }
void buttonSave_Click(object sender, EventArgs e) { try { Page.Validate(); if (Page.IsValid) { SeasonType team = SeasonTypeBL.GetBy(base.SeasonTypeId, false); if (team == null) { // insert team = new SeasonType(); team.Name = TextName.Text; team.LeagueId = base.LeagueId; team.Description = TextDescription.Text; team = SeasonTypeBL.Insert(team); } else { // update team.Name = TextName.Text; team.Description = TextDescription.Text; team = SeasonTypeBL.Update(team); } if (team == null) { message.Text = "Save failed"; } else { _redirectToListUrl(); } } } catch (Exception ex) { message.Text = ex.Message; } }
/// <summary> /// Gets the Full Game Schedule. /// </summary> /// <param name="league">The league.</param> /// <param name="year">The year.</param> /// <param name="seasonType">Type of the season.</param> /// <param name="requestOptions">The request options.</param> /// <returns></returns> public async Task <FullGameScheduleResponse> Get(int year, SeasonType seasonType, RequestOptions requestOptions = null) { var url = string.Concat(_httpWorker.Version, Url); string requestUrl = UrlBuilder.FormatRestApiUrl(url, year, seasonType, requestOptions); return(await _httpWorker.GetAsync <FullGameScheduleResponse>(requestUrl).ConfigureAwait(false)); }
// note to self // if you want to add additional vegetation & floura, has to be done by unity's Terrain Details, 4 tab on the Terrain component private int GetDensity(SeasonType season, int min, int max) { if (season == SeasonType.kWinter) { return(0); } return(UnityEngine.Random.Range(min, max)); }
public ProcessedSeason(ShowConfiguration theShow, int number, int seasonId, SeasonType t) { Show = theShow; SeasonNumber = number; SeasonId = seasonId; Episodes = new ConcurrentDictionary <int, Episode>(); type = t; }
public Season(ShowItem theShow, int number, int seasonId, SeasonType t) { Show = theShow; SeasonNumber = number; SeasonId = seasonId; Episodes = new ConcurrentDictionary <int, Episode>(); type = t; }
public StatisticCompare SeasonStatistics(SeasonType season) { if (!_seasonStat.ContainsKey(season)) { _seasonStat.Add(season, new StatisticCompare(this, season)); } return(_seasonStat[season]); }
public Statistics SeasonStatistics(SeasonType season) { if (!_seasonStat.ContainsKey(season)) { _seasonStat.Add(season, new Statistics(SeasonTable(season), _col)); } return(_seasonStat[season]); }
public Season(SeriesInfo theSeries, int number, int seasonid, SeasonType t) { TheSeries = theSeries; SeasonNumber = number; SeasonId = seasonid; Episodes = new ConcurrentDictionary <int, Episode>(); type = t; }
public SeasonSummary GetForSeasonAndSeasonType(int season, SeasonType seasonType, DateTime today) { var seasonSummary = _repository.GetForSeasonAndSeasonType(season, seasonType); ProcessForCurrentWeek(seasonSummary, today); return seasonSummary; }
protected Activity(string filePath, Folder folder, Route route) { if (filePath == null) { Name = catalog.GetString("- Explore Route -"); } else if (File.Exists(filePath)) { var showInList = true; try { var actFile = new ActivityFile(filePath); var srvFile = new ServiceFile(System.IO.Path.Combine(System.IO.Path.Combine(route.Path, "SERVICES"), actFile.Tr_Activity.Tr_Activity_File.Player_Service_Definition.Name + ".srv")); // ITR activities are excluded. showInList = actFile.Tr_Activity.Tr_Activity_Header.Mode != ActivityMode.IntroductoryTrainRide; Name = actFile.Tr_Activity.Tr_Activity_Header.Name.Trim(); Description = actFile.Tr_Activity.Tr_Activity_Header.Description; Briefing = actFile.Tr_Activity.Tr_Activity_Header.Briefing; StartTime = actFile.Tr_Activity.Tr_Activity_Header.StartTime; Season = actFile.Tr_Activity.Tr_Activity_Header.Season; Weather = actFile.Tr_Activity.Tr_Activity_Header.Weather; Difficulty = actFile.Tr_Activity.Tr_Activity_Header.Difficulty; Duration = actFile.Tr_Activity.Tr_Activity_Header.Duration; Consist = new Consist(System.IO.Path.Combine(System.IO.Path.Combine(System.IO.Path.Combine(folder.Path, "TRAINS"), "CONSISTS"), srvFile.Train_Config + ".con"), folder); Path = new Path(System.IO.Path.Combine(System.IO.Path.Combine(route.Path, "PATHS"), srvFile.PathID + ".pat")); if (!Path.IsPlayerPath) { // Not nice to throw an error now. Error was originally thrown by new Path(...); throw new InvalidDataException("Not a player path"); } } catch { Name = "<" + catalog.GetString("load error:") + " " + System.IO.Path.GetFileNameWithoutExtension(filePath) + ">"; } if (!showInList) { throw new InvalidDataException(catalog.GetStringFmt("Activity '{0}' is excluded.", filePath)); } if (string.IsNullOrEmpty(Name)) { Name = "<" + catalog.GetString("unnamed:") + " " + System.IO.Path.GetFileNameWithoutExtension(filePath) + ">"; } if (string.IsNullOrEmpty(Description)) { Description = null; } if (string.IsNullOrEmpty(Briefing)) { Briefing = null; } } else { Name = "<" + catalog.GetString("missing:") + " " + System.IO.Path.GetFileNameWithoutExtension(filePath) + ">"; } FilePath = filePath; }
/// <summary> /// Formats the rest API URL. /// </summary> /// <param name="restUrl">The rest URL.</param> /// <param name="league">The league.</param> /// <param name="year">The year.</param> /// <param name="seasonType">Type of the season.</param> /// <param name="requestOptions">The request options.</param> /// <returns></returns> public static string FormatRestApiUrl(string restUrl, int year, SeasonType seasonType, RequestOptions requestOptions = null) { string resultingUrl = String.Format(restUrl, BuildSeasonString(year, seasonType)); if (requestOptions != null) { string partialUrl = ""; bool urlHasQueryParams = restUrl.IndexOf('?') > -1; if (!String.IsNullOrEmpty(requestOptions.ForDate)) { partialUrl += string.IsNullOrWhiteSpace(partialUrl) && !urlHasQueryParams ? "?" : "&"; partialUrl += string.Format("fordate={0}", requestOptions.ForDate); } if (requestOptions.Status != null) { partialUrl += string.IsNullOrWhiteSpace(partialUrl) && !urlHasQueryParams ? "?" : "&"; partialUrl += string.Format("status={0}", BuildStatusString(requestOptions.Status)); } if (requestOptions.Force != null) { partialUrl += string.IsNullOrWhiteSpace(partialUrl) && !urlHasQueryParams ? "?" : "&"; partialUrl += string.Format("force={0}", requestOptions.Force.ToString().ToLower()); } if (requestOptions.Teams != null) { partialUrl += string.IsNullOrWhiteSpace(partialUrl) && !urlHasQueryParams ? "?" : "&"; partialUrl += string.Format("team={0}", BuildTeamNames(requestOptions.Teams)); } // TODO: Make the various filter options generic at the base. if (requestOptions.PlayerStatsMlb != null) { partialUrl += string.IsNullOrWhiteSpace(partialUrl) && !urlHasQueryParams ? "?" : "&"; partialUrl += string.Format("playerstats={0}", BuildTeamNames(requestOptions.PlayerStatsMlb)); } if (requestOptions.TeamStatsMlb != null) { partialUrl += string.IsNullOrWhiteSpace(partialUrl) && !urlHasQueryParams ? "?" : "&"; partialUrl += string.Format("teamstats={0}", BuildTeamNames(requestOptions.TeamStatsMlb)); } if (!String.IsNullOrEmpty(requestOptions.GameId)) { partialUrl += string.IsNullOrWhiteSpace(partialUrl) && !urlHasQueryParams ? "?" : "&"; partialUrl += string.Format("gameid={0}", requestOptions.GameId); } resultingUrl += partialUrl; } return(resultingUrl); }
public List<Game> GetGamesForWeek(int week, int season, SeasonType seasonType) { var collectionName = Helpers.GetCollectionName(week, season, seasonType); var fantasyDataGames = _database.GetCollection<Game>(collectionName); var results = fantasyDataGames.FindAsync(_ => true).Result; return results.ToListAsync().Result; }
protected string getSeasonSQL(SeasonType season) { int startMonth = -1; int endMonth = -1; if (season == SeasonType.SnowMelt) { startMonth = 3; endMonth = 5; } else if (season == SeasonType.GrowingSeason) { startMonth = 5; endMonth = 10; } else if (season == SeasonType.HydrologicalYear) { startMonth = 10; endMonth = 9; } else if (season == SeasonType.WholeYear) { startMonth = 1; endMonth = 12; } if (startMonth == -1 && endMonth == -1) { return(""); } //get season sql string sql = ""; if (Year > 0) { sql = getSeasonSQL(Year, startMonth, endMonth); } else { //get first year and end year if (season != SeasonType.WholeYear && season != SeasonType.HydrologicalYear) { for (int i = FirstDay.Year; i <= LastDay.Year; i++) { if (sql.Length > 0) { sql += " or "; } sql += "(" + getSeasonSQL(i, startMonth, endMonth) + ")"; } } } System.Diagnostics.Debug.WriteLine(sql); return(sql); }
private void ChangeSeason(SeasonType newSeason) { foreach (int floorNumber in _FloorSet.FloorNumbers) { foreach (Room room in _FloorSet[floorNumber].GetRooms()) { room.MyAirConditioner.Season = newSeason; } } }
public string ENVFileName(SeasonType seasonType, WeatherType weatherType) { //int index = (int)seasonType * 3 + (int)weatherType; //return ENVFileNames[index]; var envfilekey = seasonType.ToString() + weatherType.ToString(); var envfile = ENVFileNames[envfilekey]; // Trace.TraceInformation("Selected Environment file is {1}", envfilekey, envfile); return(envfile); }
public SeasonType Insert(SeasonType seasonType) { seasonType.Enabled = true; seasonType.ID = Guid.NewGuid(); seasonType.Created = DateTime.Now; seasonType.Modified = DateTime.Now; DataContextHelper.CurrentContext.SeasonTypes.InsertOnSubmit(seasonType); DataContextHelper.CurrentContext.SubmitChanges(); return seasonType; }
public DataTable SeasonTableForStatistics(SeasonType season) { if (!_seasonTableForStatistics.ContainsKey(season)) { DataView view = new DataView(TableForStatistics); view.RowFilter = getSeasonSQL(season); _seasonTableForStatistics.Add(season, view.ToTable()); } return(_seasonTableForStatistics[season]); }
/// <summary> /// Builds the season string. /// </summary> /// <param name="year">The year.</param> /// <param name="seasonType">Type of the season.</param> /// <returns></returns> private static string BuildSeasonString(int year, SeasonType seasonType) { string seasonTypeString = "regular"; if (seasonType == SeasonType.Playoff) { seasonTypeString = "playoff"; } return(string.Concat(year.ToString(), "-", seasonTypeString)); }
public SeasonSummary GetForSeasonAndSeasonType(int season, SeasonType seasonType) { var summary = new SeasonSummary(); var cmd = new MySqlCommand(GET_BY_SEASON_AND_TYPE); cmd.Parameters.AddWithValue("@season", season); cmd.Parameters.AddWithValue("@type", seasonType); ExecuteReader(cmd, dr => summary.Weeks.Add(MapWeekSummary(dr))); return summary; }
public void UpdateActivity(string startTime, SeasonType season, WeatherType weather, Consist consist, Path path) { if (!TimeSpan.TryParse(startTime, out TimeSpan result)) { result = new TimeSpan(12, 0, 0); } StartTime = result; Season = season; Weather = weather; Consist = consist; Path = path; }
public SeasonType Update(SeasonType seasonType) { SeasonType value = DataContextHelper.CurrentContext.SeasonTypes.FirstOrDefault<SeasonType>(n => n.ID.Equals(seasonType.ID)); if (value != null) { value.Name = seasonType.Name.Trim(); value.Description = seasonType.Description.Trim(); value.Enabled = seasonType.Enabled; value.Modified = DateTime.Now; DataContextHelper.CurrentContext.SubmitChanges(); } return value; }
string SetAllRoomSeason(SeasonType season) { Floor floor; foreach (int j in _FloorSet.FloorNumbers) { floor = _FloorSet[j]; foreach (Room room in ((Floor)floor).GetRooms()) { room.MyAirConditioner.Season = season; } } return("OK"); }
private static void Main(string[] args) { _gamesImportRepository = new MongoDbGamesImportRepository(Settings.Default.MongoDbConnectionString); _gamesRepository = new MongoDbGamesRepository(Settings.Default.MongoDbConnectionString); _gamesImporter = new FantasyDataGamesImportService(Settings.Default.FantasyDataApiKey, _gamesImportRepository, _gamesRepository); _season = Settings.Default.CurrentSeason; _seasonType = Settings.Default.CurrentSeasonType; //_gamesImporter.ImportGamesForSeason(_season, _seasonType).Result; _gamesImporter.ProcessGamesForWeek(_week, _season, SeasonType.Regular); Console.WriteLine("Done"); Console.ReadLine(); }
public ResponseContentActionResult<GamesResponse> GetGamesForSeason(int season, SeasonType? seasonType = null) { IList<Game> games; if (IsAuthenticated) { games = _manager.GetForSeasonForUser(season, seasonType, AuthenticatedUserId); } else { games = _manager.GetForSeason(season, seasonType); } return CreateResponse(games.ToResponse(IsAuthenticated ? Url : null)); }
//public static DataSet GetShotChartDetail(String gameId) //{ // // https://stats.nba.com/stats/shotchartdetail?AheadBehind=&CFID=&CFPARAMS=&ClutchTime=&Conference=&ContextFilter=&ContextMeasure=FGA&DateFrom=05%2F31%2F2018&DateTo=&Division=&EndPeriod=10&EndRange=28800&GROUP_ID=&GameEventID=&GameID=&GameSegment=&GroupID=&GroupMode=&GroupQuantity=5&LastNGames=0&LeagueID=00&Location=&Month=0&OnOff=&OpponentTeamID=0&Outcome=&PORound=0&Period=0&PlayerID=2544&PlayerID1=&PlayerID2=&PlayerID3=&PlayerID4=&PlayerID5=&PlayerPosition=&PointDiff=&Position=&RangeType=0&RookieYear=&Season=2017-18&SeasonSegment=&SeasonType=Playoffs&ShotClockRange=&StartPeriod=1&StartRange=0&StarterBench=&TeamID=1610612739&VsConference=&VsDivision=&VsPlayerID1=&VsPlayerID2=&VsPlayerID3=&VsPlayerID4=&VsPlayerID5=&VsTeamID= // String a = $"https://stats.nba.com/stats/shotchartdetail?AheadBehind=&CFID=&CFPARAMS=&ClutchTime=&Conference=&ContextFilter=&ContextMeasure=FGA&DateFrom=05%2F31%2F2018&DateTo=&Division=&EndPeriod=10&EndRange=28800&GROUP_ID=&GameEventID=&GameID=0011800018&GameSegment=&GroupID=&GroupMode=&GroupQuantity=5&LastNGames=0&LeagueID=00&Location=&Month=0&OnOff=&OpponentTeamID=0&Outcome=&PORound=0&Period=0&PlayerID=2544&PlayerID1=&PlayerID2=&PlayerID3=&PlayerID4=&PlayerID5=&PlayerPosition=&PointDiff=&Position=&RangeType=0&RookieYear=&Season=2017-18&SeasonSegment=&SeasonType=Playoffs&ShotClockRange=&StartPeriod=1&StartRange=0&StarterBench=&TeamID=1610612745&VsConference=&VsDivision=&VsPlayerID1=&VsPlayerID2=&VsPlayerID3=&VsPlayerID4=&VsPlayerID5=&VsTeamID="; //} // Get games for day // https://stats.nba.com/stats/scoreboardV2?DayOffset=0&LeagueID=00&gameDate=10%2F06%2F2018 public static DataSet GetTeamGameLogs(int seasonStartingYear, SeasonType seasonType, string teamId, DateTime?fromDate, DateTime?toDate, String leagueId = "00") { String fromDateFormatted = FormatDateTimeToString(fromDate, ""); String toDateFomatted = FormatDateTimeToString(toDate, ""); String season = FormatSeason(seasonStartingYear); if (String.IsNullOrEmpty(teamId)) { teamId = "0"; } String uri = $"teamgamelogs?DateFrom={fromDate}&DateTo={toDate}&GameSegment=&LastNGames=0&LeagueID={leagueId}&Location=&MeasureType=Base&Month=0&OpponentTeamID={teamId}&Outcome=&PORound=0&PaceAdjust=N&PerMode=Totals&Period=0&PlusMinus=N&Rank=N&Season={season}&SeasonSegment=&SeasonType={FormatSeasonType(seasonType)}&ShotClockRange=&TeamID=&VsConference=&VsDivision="; return(NBAStats.ReadApiResultSet(NBAStats.StatsApiGet(uri), "teamgamelogs")); }
/// <summary> /// The data table for given column and given season in given year /// </summary> /// <param name="type"></param> /// <returns></returns> public DataTable SeasonTable(SeasonType season) { if (Table.Rows.Count == 0) return Table; if (!_seasonTables.ContainsKey(season)) { string sql = getSeasonSQL(season); if (sql.Length == 0) return Table; //get the season data from data view DataView view = new DataView(Table); view.RowFilter = sql; _seasonTables.Add(season, view.ToTable()); } return _seasonTables[season]; }
/// <summary> /// 加载数据 /// </summary> public async void LoadData() { //try //{ if (Loading || !HasNext) { return; } Page += 1; Loading = true; var url = $"https://api.bilibili.com/pgc/app/follow/v2/{ SeasonType.ToString() }?access_key={ ApiHelper.access_key}&appkey={ApiHelper.AndroidKey.Appkey}&build={ApiHelper.build}&platform=android&pn={Page}&ps=20&status={Status}&ts={ApiHelper.GetTimeSpan}"; url += "&sign=" + ApiHelper.GetSign(url); var result = await WebClientClass.GetResults(new Uri(url)); var obj = JObject.Parse(result); if (obj["code"].ToInt32() == 0) { var data = JsonConvert.DeserializeObject <FollowResult>(obj["result"].ToString()); HasNext = data.has_next == 1; Total = data.total; if (data.follow_list != null) { foreach (var item in data.follow_list) { item._status = Status; FollowList.Add(item); } } } else { Utils.ShowMessageToast(obj["message"].ToString()); } //} //catch (Exception ex) //{ // Utils.ShowMessageToast(HandelError(ex).message); //} //finally //{ Loading = false; //} }
public ResponseContentActionResult<SeasonInformationResponse> Get(SeasonType? seasonType = null) { SeasonSummary summary; if (!seasonType.HasValue) { summary = _manager.GetForSeason(ConfigSettings.CurrentNflSeason, DateTime.UtcNow); } else { summary = _manager.GetForSeasonAndSeasonType(ConfigSettings.CurrentNflSeason, seasonType.Value, DateTime.UtcNow); } var response = summary.ToResponse(Url); return CreateResponse(response); }
protected string getSeasonSQL(SeasonType season) { int startMonth = -1; int endMonth = -1; if (season == SeasonType.SnowMelt) { startMonth = 3; endMonth = 5; } else if (season == SeasonType.GrowingSeason) { startMonth = 5; endMonth = 10; } else if (season == SeasonType.HydrologicalYear) { startMonth = 10; endMonth = 9; } else if (season == SeasonType.WholeYear) { startMonth = 1; endMonth = 12; } if (startMonth == -1 && endMonth == -1) return ""; //get season sql string sql = ""; if (Year > 0) sql = getSeasonSQL(Year, startMonth, endMonth); else { //get first year and end year if (season != SeasonType.WholeYear && season != SeasonType.HydrologicalYear) { for (int i = FirstDay.Year; i <= LastDay.Year; i++) { if (sql.Length > 0) sql += " or "; sql += "(" + getSeasonSQL(i, startMonth, endMonth) + ")"; } } } System.Diagnostics.Debug.WriteLine(sql); return sql; }
public static string FormatSeasonType(SeasonType seasonType) { switch (seasonType) { case SeasonType.Preseason: return("Pre Season"); case SeasonType.RegularSeason: return("Regular Season"); case SeasonType.Playoffs: return("Playoffs"); default: throw new NotImplementedException(); } }
private void SetupSeasons() { print("Setting up Seasons."); // Selects correct current season and implements its specific season actions. _currentSeason = _seasons[_currentSeasonNum]; switch (_currentSeasonNum) { case 0: _currentSeasonType = SeasonType.SUMMER; break; case 1: _currentSeasonType = SeasonType.AUTUMN; break; case 2: _currentSeasonType = SeasonType.WINTER; break; case 3: _currentSeasonType = SeasonType.SPRING; break; default: break; } _currentSeason.StartSeason(); // Resets elements. _elementManager.ResetElementOrder(_currentSeason._elementSpawnOrder); // Applying global aesthetic changes. ChangeTrees(); print("Made it to fade"); // Fade in. var fader = ScreenFader.Instance; fader.FadeTo(Color.clear, _fadeInDuration); print("Fading"); }
// hierarchy for trees /* * ParentPlaceableObject -> Biome -> Tree -> First child * */ private static void UpdateBiomeContent(TerrainInfo info, SeasonType seasonType) { // go trough all biomes foreach (var kvp in info.ContentManager.BiomeParentGameObjects) { var biomeIdx = kvp.Key; var biomeParent = kvp.Value; // go trough biome content for (int i = 0; i < biomeParent.transform.childCount; i++) { var child = biomeParent.transform.GetChild(i); if (child.name.Contains("Broadleaf_Hero_Field")) { var meshRenderer = child.GetChild(0).GetComponent <MeshRenderer>(); if (meshRenderer != null) { if (meshRenderer.materials.Length > 1) { switch (info.CurrentSeason) { case SeasonType.kSpring: meshRenderer.materials[2].SetColor("_Color", Color.yellow); break; case SeasonType.kSummer: meshRenderer.materials[2].SetColor("_Color", Color.green); break; case SeasonType.kAutumn: meshRenderer.materials[2].SetColor("_Color", new Color(139.0f / 255.0f, 69.0f / 255.0f, 19.0f / 255.0f, 1.0f)); break; case SeasonType.kWinter: meshRenderer.materials[2].SetColor("_Color", new Color(1, 1, 1, 0.0f)); break; } } } } } } }
public static SeasonType NextSeasonType(this SeasonType currentSeasonType) { switch (currentSeasonType) { case SeasonType.Fall: return(SeasonType.Winter); case SeasonType.Winter: return(SeasonType.Spring); case SeasonType.Spring: return(SeasonType.Summer); case SeasonType.Summer: return(SeasonType.Fall); default: throw new ArgumentOutOfRangeException(nameof(currentSeasonType), currentSeasonType, null); } }
public string GetBoxscoreByQuarter(string season, SeasonType seasonType, string gameId, int quarter) { // https://stats.nba.com/stats/boxscoretraditionalv2?EndPeriod=10&EndRange=7200&GameID=0011800076&RangeType=2&Season=2018-19&SeasonType=Pre+Season&StartPeriod=1&StartRange=0 // "GAME_ID","TEAM_ID","TEAM_ABBREVIATION","TEAM_CITY","PLAYER_ID","PLAYER_NAME","START_POSITION","COMMENT","MIN","FGM","FGA","FG_PCT","FG3M","FG3A","FG3_PCT","FTM","FTA","FT_PCT","OREB","DREB","REB","AST","STL","BLK","TO","PF","PTS","PLUS_MINUS" /* * Q1: https://stats.nba.com/stats/boxscoretraditionalv2?EndPeriod=10&EndRange=7200&GameID=0011800076&RangeType=2&Season=2018-19&SeasonType=Pre+Season&StartPeriod=1&StartRange=0 * Q2: https://stats.nba.com/stats/boxscoretraditionalv2?EndPeriod=10&EndRange=14400&GameID=0011800076&RangeType=2&Season=2018-19&SeasonType=Pre+Season&StartPeriod=1&StartRange=7200 * Q3: https://stats.nba.com/stats/boxscoretraditionalv2?EndPeriod=10&EndRange=21600&GameID=0011800076&RangeType=2&Season=2018-19&SeasonType=Pre+Season&StartPeriod=1&StartRange=14400 * Q4: https://stats.nba.com/stats/boxscoretraditionalv2?EndPeriod=10&EndRange=28800&GameID=0011800076&RangeType=2&Season=2018-19&SeasonType=Pre+Season&StartPeriod=1&StartRange=21600 * OT1: https://stats.nba.com/stats/boxscoretraditionalv2?EndPeriod=10&EndRange=31800&GameID=0011800041&RangeType=2&Season=2018-19&SeasonType=Pre+Season&StartPeriod=1&StartRange=28800 * */ // Advanced // https://stats.nba.com/stats/boxscoreadvancedv2?EndPeriod=10&EndRange=28800&GameID=0011800076&RangeType=0&Season=2018-19&SeasonType=Pre+Season&StartPeriod=1&StartRange=0 // "GAME_ID","TEAM_ID","TEAM_ABBREVIATION","TEAM_CITY","PLAYER_ID","PLAYER_NAME","START_POSITION","COMMENT","MIN","E_OFF_RATING","OFF_RATING","E_DEF_RATING","DEF_RATING","E_NET_RATING","NET_RATING","AST_PCT","AST_TOV","AST_RATIO","OREB_PCT","DREB_PCT","REB_PCT","TM_TOV_PCT","EFG_PCT","TS_PCT","USG_PCT","E_USG_PCT","E_PACE","PACE","PIE" return("boxscoretraditionalv2?EndPeriod=10&EndRange=7200&GameID=0&RangeType=2&Season=2018-19&SeasonType=Pre+Season&StartPeriod=1&StartRange=0"); }
public void Change(SeasonType type, bool isForce = false) { if (!isForce) { if (type == SeasonType) return; } SeasonType = type; CurData = RandUtil.RandArray(Data[type]); if (sunTween != null) DOTween.Kill(sunTween); if (snowTween != null) DOTween.Kill(snowTween); sunTween = DOTween.To(() => SunObj.Obj.intensity, x => SunObj.Obj.intensity = x, CurData.SunIntensity, 1.0f); ChangeWindPower(CurData.WindzonePower); if (IsShowSnow) { snowTween = DOTween.To(() => ActiveTerrainMat.GetFloat("_SnowAmount"), x => ActiveTerrainMat.SetFloat("_SnowAmount", x), CurData.AccumulatedSnow, 1.0f); } Callback_OnSeasonChanged?.Invoke(type, CurData.Type); OnSeasonChanged(type, CurData.Type); }
public void UpdateActivity(string startTime, SeasonType season, WeatherType weather, Consist consist, Path path) { var time = startTime.Split(':'); if (!int.TryParse(time[0], out int hour)) { hour = 12; } if (time.Length < 2 || !int.TryParse(time[1], out int minute)) { minute = 0; } if (time.Length < 3 || !int.TryParse(time[2], out int second)) { second = 0; } StartTime = new StartTime(hour, minute, second); Season = season; Weather = weather; Consist = consist; Path = path; }
/// <summary> /// The data table for given column and given season in given year /// </summary> /// <param name="type"></param> /// <returns></returns> public DataTable SeasonTable(SeasonType season) { if (Table.Rows.Count == 0) { return(Table); } if (!_seasonTables.ContainsKey(season)) { string sql = getSeasonSQL(season); if (sql.Length == 0) { return(Table); } //get the season data from data view DataView view = new DataView(Table); view.RowFilter = sql; _seasonTables.Add(season, view.ToTable()); } return(_seasonTables[season]); }
public void Change(SeasonType type, bool isForce = false) { if (!isForce) { if (type == SeasonType) { return; } } SeasonType = type; CurData = BaseMathUtils.RandArray(Data[type]); if (sunTween != null) { DOTween.Kill(sunTween); } if (snowTween != null) { DOTween.Kill(snowTween); } sunTween = DOTween.To(() => Sun.intensity, x => Sun.intensity = x, CurData.SunIntensity, 1.0f); Wind.windMain = CurData.WindzonePower; snowTween = DOTween.To(() => ActiveTerrainMat.GetFloat("_SnowAmount"), x => ActiveTerrainMat.SetFloat("_SnowAmount", x), CurData.AccumulatedSnow, 1.0f); Callback_OnSeasonChanged?.Invoke(type, CurData.Type); }
public StatisticCompare SeasonStatistics(SeasonType season) { if (!_seasonStat.ContainsKey(season)) _seasonStat.Add(season, new StatisticCompare(this,season)); return _seasonStat[season]; }
public void UpdateGameOptionForWeek(int season, SeasonType seasonType, int week) { var games = GetForWeek(seasonType, season, week); UpdateGameOutcomes(games); }
private IList<Option<Team>> GetOptionsForWeek(SeasonType seasonType, int season, int week) { var options = _optionRepository.GetForWeek(seasonType, season, week); PopulateTeamsForOptions(options); return options; }
public IList<Game> GetForSeason(int season, SeasonType? seasonType) { var games = _gameRepository.GetForSeason(season, seasonType); var options = BuildDictionary(GetOptionsForSeason(season)); foreach (var game in games) { PopulateTeamsForGame(game); if (options.ContainsKey(game.Id)) { game.Options = options[game.Id]; } } return games; }
private static void AssertWeeklyRecords(int season, SeasonType seasonType, int week, int wins, int losses, int ties, IEnumerable<UserRecord> records) { var record = records.FirstOrDefault(r => r.Season == season && r.SeasonType == seasonType && r.Week == week && r.RecordType == RecordType.Week); Assert.True(wins == record.Wins, String.Format("Expected {0} wins but observed {1} wins for {2} {3} week {4}.", wins, record.Wins, season, seasonType, week)); Assert.True(losses == record.Losses, String.Format("Expected {0} losses but observed {1} losses for {2} {3} week {4}.", losses, record.Losses, season, seasonType, week)); Assert.True(ties == record.Ties, String.Format("Expected {0} ties but observed {1} ties for {2} {3} week {4}.", ties, record.Ties, season, seasonType, week)); }
private static UserRecord CreateRecord(int id, int userId, RecordType recordType, int wins, int losses, int ties, int? season = null, SeasonType? seasonType = null, int? week = null) { var record = new UserRecord { Id = id, Losses = losses, RecordType = recordType, Season = 2013, Ties = ties, UserId = userId, Wins = wins }; if (recordType == RecordType.Season) { record.Season = season; } else if (recordType == RecordType.SeasonType) { record.Season = season; record.SeasonType = seasonType; } else if (recordType == RecordType.Week) { record.Season = season; record.SeasonType = seasonType; record.Week = week; } return record; }
public ResponseContentActionResult<GamesResponse> GetGetGamesForSeasonAndWeek(int season, SeasonType seasonType, int week) { IList<Game> games; if (IsAuthenticated) { games = _manager.GetForWeekForUser(season, seasonType, week, AuthenticatedUserId); } else { games = _manager.GetForWeek(seasonType, season, week); } return CreateResponse(games.ToResponse(IsAuthenticated ? Url : null)); }
public IList<Option<Team>> GetForWeek(SeasonType seasonType, int season, int week) { var options = new List<Option<Team>>(); var cmd = new MySqlCommand(GET_FOR_WEEK); cmd.Parameters.AddWithValue("@season", season); cmd.Parameters.AddWithValue("@week", week); cmd.Parameters.AddWithValue("@type", seasonType); ExecuteReader(cmd, dr => options.Add(MapOption(dr))); return options; }
public void Post(SeasonType seasonType, int season, int week) { _gameManager.UpdateGameOptionForWeek(season, seasonType, week); }
public DataTable SeasonTableForStatistics(SeasonType season) { if (!_seasonTableForStatistics.ContainsKey(season)) { DataView view = new DataView(TableForStatistics); view.RowFilter = getSeasonSQL(season); _seasonTableForStatistics.Add(season,view.ToTable()); } return _seasonTableForStatistics[season]; }
public IList<Game> GetForWeekForUser(int season, SeasonType seasonType, int week, long userId) { var games = GetForWeek(seasonType, season, week); var picks = _pickManager.GetForWeek(userId, seasonType, season, week); MatchOptionsAndPicks(games.SelectMany(game => game.Options), picks); return games; }
public static string GetCollectionName(int week, int season, SeasonType seasonType) { return $"s_{season}_w_{week.ToString("D2")}_{seasonType.GetAbbreviation()}"; }
/// <summary> /// Gets the Player Injuries. /// </summary> /// <param name="league">The league.</param> /// <param name="year">The year.</param> /// <param name="seasonType">Type of the season.</param> /// <param name="requestOptions">The request options.</param> /// <returns></returns> public async Task <PlayerInjuriesResponse> Get(int year, SeasonType seasonType, RequestOptions requestOptions = null) { string requestUrl = UrlBuilder.FormatRestApiUrl(Url, year, seasonType, requestOptions); return(await _httpWorker.GetAsync <PlayerInjuriesResponse>(requestUrl).ConfigureAwait(false)); }
public IList<UserRecord> GetUserWeeklyRecords(long userId, int season, SeasonType seasonType, int week) { var records = new List<UserRecord>(); var cmd = new MySqlCommand(GET_WEEKLY_FOR_USER); cmd.Parameters.AddWithValue("@season", season); cmd.Parameters.AddWithValue("@seasonType", seasonType); cmd.Parameters.AddWithValue("@week", week); cmd.Parameters.AddWithValue("@type", RecordType.Week); cmd.Parameters.AddWithValue("@userId", userId); ExecuteReader(cmd, dr => records.Add(MapUserRecord(dr))); return records; }
public IList<UserPick> GetForWeek(long userId, SeasonType seasonType, int season, int week) { var picks = new List<UserPick>(); var cmd = new MySqlCommand(GET_PICKS_FOR_SEASON_AND_WEEK); cmd.Parameters.AddWithValue("@userId", userId); cmd.Parameters.AddWithValue("@season", season); cmd.Parameters.AddWithValue("@week", week); cmd.Parameters.AddWithValue("@type", seasonType); ExecuteReader(cmd, dr => picks.Add(MapUserPick(dr))); return picks; }
public IList<Game> GetForWeek(SeasonType seasonType, int season, int week) { var games = new List<Game>(); var cmd = new MySqlCommand(GET_GAMES_FOR_WEEK); cmd.Parameters.AddWithValue("@season", season); cmd.Parameters.AddWithValue("@week", week); cmd.Parameters.AddWithValue("@type", seasonType); ExecuteReader(cmd, dr => games.Add(MapGame(dr))); return games; }
public StatisticCompare(SWATUnitColumnYearCompareResult result,SeasonType season) { _result = result; _season = season; }
public IList<UserPick> GetForWeek(long userId, SeasonType seasonType, int season, int week) { return _pickRepository.GetForWeek(userId, seasonType, season, week); }
public IList<Game> GetForSeasonForUser(int season, SeasonType? seasonType, long userId) { var games = GetForSeason(season, seasonType); var picks = _pickManager.GetForSeason(userId, season); MatchOptionsAndPicks(games.SelectMany(game => game.Options), picks); return games; }