示例#1
0
        public void calculateHighLowTeamStats(String league, String division, Team.CATEGORY cat)
        {
            ReportScope scope = new ReportScope();

            if (league.Length > 0)
            {
                scope.League = league;
            }
            if (division.Length > 0)
            {
                scope.Division = division;
                scope.League   = "X";
            }
            List <Team> teams    = getTeamsByScope(scope);
            Team        leader   = null;
            Team        trailing = null;

            foreach (Team t in teams)
            {
                if (leader == null || trailing == null)
                {
                    leader   = t;
                    trailing = t;
                }
                processCategory(ref leader, ref trailing, t, cat);
            }

            leader.setLeader(cat);
            trailing.setTrailing(cat);
        }
示例#2
0
        public List <Team> getTeamsByName(ReportScope scope)
        {
            List <Team> matches = getTeamsByScope(scope);

            matches.Sort(delegate(Team x, Team y)
            {
                if (scope.OrderAscending)
                {
                    if (x.Name == null && y.Name == null)
                    {
                        return(0);
                    }
                    else if (x.Name == null)
                    {
                        return(-1);
                    }
                    else if (y.Name == null)
                    {
                        return(1);
                    }
                    else
                    {
                        return(x.Name.ToUpper().CompareTo(y.Name.ToUpper()));
                    }
                }
                else
                {
                    if (x.Name == null && y.Name == null)
                    {
                        return(0);
                    }
                    else if (x.Name == null)
                    {
                        return(-1);
                    }
                    else if (y.Name == null)
                    {
                        return(1);
                    }
                    else
                    {
                        return(y.Name.ToUpper().CompareTo(x.Name.ToUpper()));
                    }
                }
            });

            return(matches);
        }
示例#3
0
        private List <Team> getTeamsByScope(ReportScope scope)
        {
            List <Team> matches = new List <Team>();

            foreach (Team team in DATABASE.Teams())
            {
                if (scope.AllTeams)
                {
                    matches.Add(team);
                }
                if (scope.Division.Length > 0 &&
                    (Program.LEAGUES[0].Length > 0 && scope.League.Length > 0))

                {
                    if (team.Division.Equals(scope.Division) &&
                        team.League.Equals(scope.League))
                    {
                        matches.Add(team);
                    }
                }
                else if (scope.Division.Length > 0 &&
                         team.Division.Equals(scope.Division))
                {
                    matches.Add(team);
                }
                else if (scope.League.Length > 0 &&
                         team.League.Equals(scope.League))
                {
                    matches.Add(team);
                }
                else if (scope.League.Equals("X") &&
                         scope.Division.Length == 0 &&
                         Program.LEAGUES[0].Length == 0)
                {
                    matches.Add(team);
                }
            }
            return(matches);
        }
示例#4
0
        public List <Team> getTeamsByWinPercentage(ReportScope scope)
        {
            List <Team> matches = getTeamsByScope(scope);

            //TODO:
            // Tie Breakers: 1.Head to head W - L / 2.H to H run differential / 3.League wide Pythagorean
            matches.Sort(delegate(Team x, Team y)
            {
                if (scope.OrderAscending)
                {
                    int result = x.Wpct.CompareTo(y.Wpct);
                    if (result == 0)
                    {
                        return(x.PythagoreanTheorem.CompareTo(y.PythagoreanTheorem));
                    }
                    else
                    {
                        return(result);
                    }
                }
                else
                {
                    int result = y.Wpct.CompareTo(x.Wpct);
                    if (result == 0)
                    {
                        return(y.PythagoreanTheorem.CompareTo(x.PythagoreanTheorem));
                    }
                    else
                    {
                        return(result);
                    }
                }
            });

            return(matches);
        }