示例#1
0
        internal static double AverageNetScoreForYear(this team team, year year)
        {
            var results = team.AllResultsForYear(year);

            if (results == null || results.Count() == 0)
            {
                return(0.0);
            }
            double totalScore = 0;
            int    roundCount = 0;
            int    value      = 0;

            foreach (var result in results)
            {
                value = result.NetScoreDifference().Value;
                if (value < 60)
                {
                    totalScore += value;
                    roundCount++;
                }
            }

            if (roundCount == 0)
            {
                return(0.0);
            }

            return(totalScore / roundCount);
        }
示例#2
0
        public static double AverageOpponentScoreForYear(this team team, year year)
        {
            var results = team.AllResultsForYear(year);

            if (results == null || results.Count() == 0)
            {
                return(0);
            }

            double totalScore    = 0;
            double opponentCount = 0;

            foreach (var result in results)
            {
                int val = result.OpponentResult().ScoreDifference().Value;

                if (val < 60)
                {
                    totalScore += val;
                    opponentCount++;
                }
            }

            if (opponentCount == 0)
            {
                return(0.0);
            }

            return(totalScore / opponentCount);
        }
示例#3
0
        internal static double AverageMarginOfNetVictoryForYear(this team team, year year)
        {
            var results = team.AllResultsForYear(year);

            if (results == null || results.Count() == 0)
            {
                return(0.0);
            }

            double totalMargin = 0;
            int    roundCount = 0;
            int    playerValue = 0, oppValue = 0;

            foreach (var result in results)
            {
                playerValue = result.NetScoreDifference().Value;
                oppValue    = result.OpponentResult().NetScoreDifference().Value;
                if (oppValue < 60)
                {
                    totalMargin += oppValue - playerValue;
                    roundCount++;
                }
            }

            if (roundCount == 0)
            {
                return(0.0);
            }

            return(totalMargin / roundCount);
        }
示例#4
0
        public static double AverageHandicapForYear(this team team, year year)
        {
            // Get all results for year
            var resultsForYear = team.AllResultsForYear(year);

            // Get all players for these results
            var playersWhichPlayedForYear = resultsForYear.Select(x => x.player).Where(x => x.validPlayer).GroupBy(x => x.id).Select(x => x.First());

            // get year data for all players
            List <playeryeardata> yds = new List <playeryeardata>();

            foreach (var player in playersWhichPlayedForYear)
            {
                var yd = player.playeryeardatas.FirstOrDefault(y => y.year.id == year.id);

                if (yd == null)
                {
                    continue;
                }

                yds.Add(yd);
            }

            var handicapSum = yds.Sum(x => x.finishingHandicap);

            if (playersWhichPlayedForYear.Count() == 0)
            {
                return(0.0);
            }

            return((double)handicapSum / (double)playersWhichPlayedForYear.Count());
        }
示例#5
0
        public static int TotalPointsForYear(this team team, year year)
        {
            var allResults = team.AllResultsForYear(year);

            int total = 0;

            foreach (var result in allResults)
            {
                total += result.points.Value;
            }

            return(total);
        }
示例#6
0
        internal static int MostPointsInWeekForYear(this team team, year year)
        {
            var results = team.AllResultsForYear(year);

            // group results by week
            var groupedResults = results.GroupBy(x => x.match.teammatchup.week.seasonIndex, x => x, (key, elements) => new { WeekId = key, Results = elements });

            int max = 0;

            foreach (var r in groupedResults)
            {
                int total = r.Results.Select(x => x.points.Value).Sum();

                if (total >= max)
                {
                    max = total;
                }
            }

            return(max);
        }
示例#7
0
        public static double[] IndividualRecordForYear(this team team, year year)
        {
            var results = team.AllResultsForYear(year);
            int wins = 0, losses = 0, ties = 0;

            foreach (var result in results)
            {
                if (result.WasWin())
                {
                    wins++;
                }
                else if (result.WasLoss())
                {
                    losses++;
                }
                else
                {
                    ties++;
                }
            }

            return(new double[] { wins, losses, ties });
        }
示例#8
0
        public static int[] RecordForYear(this team team, year year)
        {
            var allResults = team.AllResultsForYear(year);
            int wins = 0, losses = 0, ties = 0;

            int[] pointsForWeek = Enumerable.Repeat(0, 30).ToArray();

            foreach (var result in allResults)
            {
                int seasonIndex = result.match.teammatchup.week.seasonIndex;

                pointsForWeek[seasonIndex] = pointsForWeek[seasonIndex] + result.points.Value;
            }

            foreach (int p in pointsForWeek)
            {
                if (p == 0)
                {
                    continue;
                }

                if (p > 48)
                {
                    wins++;
                }
                else if (p == 48)
                {
                    ties++;
                }
                else if (p < 48)
                {
                    losses++;
                }
            }

            return(new int[] { wins, losses, ties });
        }
        public double CalculateBoardValueForTeam(TeamLeaderBoard tlb, team t, year y)
        {
            var value = tlb.DoCalculation(t, y, t.AllResultsForYear(y));

            return(value.HasValue ? value.Value : 0.0);
        }