Exemple #1
0
        void UpdateStats(Project project)
        {
            catStats.Clear();

            Field     = project.Categories.FieldBackground;
            HalfField = project.Categories.HalfFieldBackground;
            Goal      = project.Categories.GoalBackground;

            foreach (Category cat in project.Categories)
            {
                CategoryStats stats;
                List <Play>   plays, homePlays, awayPlays;
                int           localTeamCount, visitorTeamCount;

                plays     = project.PlaysInCategory(cat);
                homePlays = plays.Where(p => p.Team == Team.LOCAL || p.Team == Team.BOTH).ToList();
                awayPlays = plays.Where(p => p.Team == Team.VISITOR || p.Team == Team.BOTH).ToList();
                stats     = new CategoryStats(cat, plays.Count, homePlays.Count(), awayPlays.Count());
                /* Fill zonal tagging stats */
                stats.FieldCoordinates         = plays.Select(p => p.FieldPosition).Where(p => p != null).ToList();
                stats.HalfFieldCoordinates     = plays.Select(p => p.HalfFieldPosition).Where(p => p != null).ToList();
                stats.GoalCoordinates          = plays.Select(p => p.GoalPosition).Where(p => p != null).ToList();
                stats.HomeFieldCoordinates     = homePlays.Select(p => p.FieldPosition).Where(p => p != null).ToList();
                stats.HomeHalfFieldCoordinates = homePlays.Select(p => p.HalfFieldPosition).Where(p => p != null).ToList();
                stats.HomeGoalCoordinates      = homePlays.Select(p => p.GoalPosition).Where(p => p != null).ToList();
                stats.AwayFieldCoordinates     = awayPlays.Select(p => p.FieldPosition).Where(p => p != null).ToList();
                stats.AwayHalfFieldCoordinates = awayPlays.Select(p => p.HalfFieldPosition).Where(p => p != null).ToList();
                stats.AwayGoalCoordinates      = awayPlays.Select(p => p.GoalPosition).Where(p => p != null).ToList();
                catStats.Add(stats);

                foreach (ISubCategory subcat in cat.SubCategories)
                {
                    SubCategoryStat subcatStat;

                    if (subcat is PlayerSubCategory)
                    {
                        continue;
                    }

                    subcatStat = new SubCategoryStat(subcat);
                    stats.AddSubcatStat(subcatStat);

                    if (subcat is TagSubCategory)
                    {
                        foreach (string option in subcat.ElementsDesc())
                        {
                            List <Play> subcatPlays;
                            StringTag   tag;

                            tag = new StringTag {
                                SubCategory = subcat, Value = option
                            };
                            subcatPlays = plays.Where(p => p.Tags.Tags.Contains(tag)).ToList();
                            GetSubcategoryStats(subcatPlays, subcatStat, option,
                                                stats.TotalCount, out localTeamCount, out visitorTeamCount);
                            GetPlayersStats(project, subcatPlays, option, subcatStat, cat);
                        }
                    }

                    if (subcat is TeamSubCategory)
                    {
                        List <Team> teams = new List <Team>();
                        teams.Add(Team.LOCAL);
                        teams.Add(Team.VISITOR);

                        foreach (Team team in teams)
                        {
                            List <Play> subcatPlays;
                            TeamTag     tag;

                            tag = new TeamTag {
                                SubCategory = subcat, Value = team
                            };
                            subcatPlays = plays.Where(p => p.Teams.Tags.Contains(tag)).ToList();
                            GetSubcategoryStats(subcatPlays, subcatStat, team.ToString(),
                                                stats.TotalCount, out localTeamCount, out visitorTeamCount);
                        }
                    }
                }
            }
        }
        void UpdateStats(Project project)
        {
            catStats.Clear();

            foreach (Category cat in project.Categories) {
                CategoryStats stats;
                List<Play> plays;
                int localTeamCount, visitorTeamCount;

                plays = project.PlaysInCategory (cat);
                CountPlaysInTeam(plays, out localTeamCount, out visitorTeamCount);
                stats = new CategoryStats(cat.Name, plays.Count, localTeamCount, visitorTeamCount);
                catStats.Add (stats);

                foreach (ISubCategory subcat in cat.SubCategories) {
                    SubCategoryStat subcatStat;

                    if (subcat is PlayerSubCategory)
                        continue;

                    subcatStat = new SubCategoryStat(subcat.Name);
                    stats.AddSubcatStat(subcatStat);

                     if (subcat is TagSubCategory) {
                        foreach (string option in subcat.ElementsDesc()) {
                            List<Play> subcatPlays;
                            StringTag tag;

                            tag = new StringTag{SubCategory=subcat, Value=option};
                            subcatPlays = plays.Where(p => p.Tags.Tags.Contains(tag)).ToList();
                            GetSubcategoryStats(subcatPlays, subcatStat, option,
                                stats.TotalCount, out localTeamCount, out visitorTeamCount);
                            GetPlayersStats(project, subcatPlays, option, subcatStat, cat);
                        }
                     }

                     if (subcat is TeamSubCategory) {
                        List<Team> teams = new List<Team>();
                        teams.Add(Team.LOCAL);
                        teams.Add(Team.VISITOR);

                        foreach (Team team in teams) {
                            List<Play> subcatPlays;
                            TeamTag tag;

                            tag = new TeamTag{SubCategory=subcat, Value=team};
                            subcatPlays = plays.Where(p => p.Teams.Tags.Contains(tag)).ToList();
                            GetSubcategoryStats(subcatPlays, subcatStat, team.ToString(),
                                stats.TotalCount, out localTeamCount, out visitorTeamCount);
                        }
                     }
                }
            }
        }