public Scorekeeper(IEnumerable <Bet> fakeBets, IEnumerable <Prediction> fakePredictions, Scoreboard scoreboard) { Scoreboard = scoreboard; Schedule = Schedule.GetOnlineSchedule(); Bets = fakeBets.ToList(); Predictions = fakePredictions.ToList(); MatchRecord = new MatchRecord(); }
public Scorekeeper() { Scoreboard = new Scoreboard(); MatchRecord = MatchRecord.GetOnlineMatchRecord(); Schedule = Schedule.GetOnlineSchedule(); Bets = new List <Bet>(); Predictions = new List <Prediction>(); }
/// <summary> /// Downloads the list of occurred LCS matches from lol.gamepedia.com /// </summary> /// <returns>A MatchRecord object containing the list of occurred LCS matches</returns> public static MatchRecord GetOnlineMatchRecord() { // Get HTML document string page_content; using (WebClient client = new WebClient()) { page_content = client.DownloadString(URL_RECORD); } HtmlDocument html = new HtmlDocument(); html.LoadHtml(page_content); HtmlNodeCollection raw_matches = html.DocumentNode.SelectNodes("//tr[contains(@class, 'mdv-allweeks mdv-week')]"); // Get occurred mathes from HTML document MatchRecord record = new MatchRecord(); foreach (HtmlNode node in raw_matches) { if (node.InnerLength > 1000) // Match has occurred { HtmlNodeCollection teams = node.SelectNodes(".//span[@class='teamname']"); LCSTeam team1 = LCSTeam.ParseTeam(teams[0].InnerText); LCSTeam team2 = LCSTeam.ParseTeam(teams[1].InnerText); if (!string.IsNullOrEmpty(team1.Name) && !string.IsNullOrEmpty(team2.Name)) // Both teams in Match detected { HtmlNode win = node.SelectSingleNode(".//td[@class='md-winner']"); if (win != null) // Winner was found for this match { LCSTeam winner = LCSTeam.ParseTeam(win.InnerText); if (winner.Equals(team1) || winner.Equals(team2)) // Make sure we detected the winning team correctly { LCSTeam other; if (winner.Equals(team1)) { other = team2; } else { other = team1; } record.Add(new MatchResult(winner, other)); } } } } } return(record); }
public Scorekeeper(string path) { SavePath = path; if (File.Exists(SavePath)) { Scoreboard = Scoreboard.FromFile(SavePath); } else { Scoreboard = new Scoreboard(); Scoreboard.SaveToFile(SavePath); } MatchRecord = MatchRecord.GetOnlineMatchRecord(); Schedule = Schedule.GetOnlineSchedule(); Bets = new List <Bet>(); Predictions = new List <Prediction>(); }