Ejemplo n.º 1
0
        public bool Equals(GameDetail p)
        {
            // If parameter is null, return false.
            if (Object.ReferenceEquals(p, null))
            {
                return(false);
            }

            // Optimization for a common success case.
            if (Object.ReferenceEquals(this, p))
            {
                return(true);
            }

            // If run-time types are not exactly the same, return false.
            if (this.GetType() != p.GetType())
            {
                return(false);
            }

            // Return true if the fields match.
            // Note that the base class is not invoked because it is
            // System.Object, which defines Equals as reference equality.
            return(JsonConvert.SerializeObject(this) == JsonConvert.SerializeObject(p));
        }
Ejemplo n.º 2
0
        private static IEnumerable <String> GetScoringPlaysForPeriod(NHLApi.GameDetail gameDetail, int start, int end)
        {
            List <String> result = new List <String>();

            foreach (var play in gameDetail.LiveData.Plays.ScoringPlays)
            {
                if (play >= start && play <= end)
                {
                    result.Add(gameDetail.LiveData.Plays.AllPlays[play].Result.Description);
                }
            }

            return(result);
        }
Ejemplo n.º 3
0
        public static string PeriodSummary(LineScorePeriod lineScorePeriod, TeamDetail home, TeamDetail away, NHLApi.GameDetail gameDetail)
        {
            /*
             *  Period X:
             *  Shots: <HomeTeam> X, <AwayTeam> Y
             *  Goals: <HomeTeam> X, <AwayTeam> Y
             *  Scoring Plays:
             *  .
             *  .
             *  .
             */
            var playIndexStart = gameDetail.LiveData.Plays.PlaysByPeriod[lineScorePeriod.Num - 1].StartIndex;
            var playIndexEnd   = gameDetail.LiveData.Plays.PlaysByPeriod[lineScorePeriod.Num - 1].EndIndex;

            var builder = new StringBuilder();

            builder.AppendLine(String.Format("**Period {0}:**", lineScorePeriod.Num));
            builder.AppendLine(String.Format("__Shots:__ {0} {1}, {2} {3}", home.Abbreviation, lineScorePeriod.Home.ShotsOnGoal, away.Abbreviation, lineScorePeriod.Away.ShotsOnGoal));
            builder.AppendLine(String.Format("__Goals:__ {0} {1}, {2} {3}", home.Abbreviation, lineScorePeriod.Home.Goals, away.Abbreviation, lineScorePeriod.Away.Goals));



            var scoringPlays = GetScoringPlaysForPeriod(gameDetail, playIndexStart, playIndexEnd);

            if (scoringPlays.Count() > 0)
            {
                builder.AppendLine("__Scoring Plays:__");

                foreach (var play in scoringPlays)
                {
                    builder.AppendLine(" - " + play);
                }
            }
            else
            {
                builder.AppendLine(" - No Goals were scored this period.");
            }

            return(builder.ToString());
        }