예제 #1
0
        public RegularShot(string text, HtmlNodeCollection urlNodes, bool made, int points) : base(urlNodes, made, points)
        {
            Regex pattern = new Regex(ShotPattern);

            System.Text.RegularExpressions.Match match = pattern.Match(text);
            if (match.Success)
            {
                string distanceString = match.Groups["distance"].Value;
                Distance = int.Parse(distanceString);
            }

            if (urlNodes.Count == 1)
            {
                return;
            }
            if (text.Contains("assist"))
            {
                AssistingPlayer = EventFactory.GetLinkFromUrlNode(urlNodes[1]);
            }
            else if (text.Contains("block"))
            {
                BlockingPlayer = EventFactory.GetLinkFromUrlNode(urlNodes[1]);
            }
            else
            {
                throw new Exception($"unknown 2nd player role in shooting event");
            }
        }
예제 #2
0
        public ScoringEvent(HtmlNodeCollection urlNodes, bool made, int points)
        {
            Made   = made;
            Points = points;

            if (urlNodes.Count == 0)
            {
                throw new Exception($"no player nodes in scoring event");
            }
            ShootingPlayer = EventFactory.GetLinkFromUrlNode(urlNodes[0]);
        }
예제 #3
0
        private static Match ParseMatch(HtmlNode node, bool playoffs)
        {
            Regex pattern = new Regex(UrlRegex);

            System.Text.RegularExpressions.Match regexMatch = pattern.Match(EventFactory.GetLinkFromUrlNode(node.ChildNodes[6].SelectSingleNode("a")));
            if (!regexMatch.Success)
            {
                throw new Exception($"unable to parse match id {node.ChildNodes[6].InnerHtml}");
            }

            string id = regexMatch.Groups["id"].Value;

            if (CachedMatchExists(id))
            {
                return(null);
            }

            Match match = MatchParser.ParseMatch(id, ParseDateTime(node.ChildNodes[0].InnerText, node.ChildNodes[1].InnerText), playoffs);

            CacheMatch(match, id);
            return(match);
        }
예제 #4
0
        private static List <Player> ParseMatchBoxScore(HtmlNode tableNode)
        {
            List <Player> players = new List <Player>();

            foreach (HtmlNode node in tableNode.ChildNodes)
            {
                if (node.ChildNodes.Count == 0 || node.HasClass("thead"))
                {
                    continue;
                }

                Player player = new Player(node.ChildNodes[0].InnerText);
                player.Id = EventFactory.GetLinkFromUrlNode(node.ChildNodes[0].SelectSingleNode("a"));
                players.Add(player);

                if (node.ChildNodes.Count == 2)
                {
                    switch (node.ChildNodes[1].InnerText)
                    {
                    case "Did Not Play":
                    case "Did Not Dress":
                    case "Player Suspended":
                    case "Not With Team":
                        player.DidNotPlay = true;
                        continue;

                    default:
                        throw new Exception($"could not parse inactive player {node.ChildNodes[1].InnerText}");
                    }
                }

                player.Points = int.Parse(node.ChildNodes[19].InnerText);
            }

            return(players);
        }