[longomatch] Account in stats plays with no team but players tagged



commit a3e2aba992b133ecb942b0e5fd239e5672e26ff7
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Sun Mar 9 17:46:05 2014 +0100

    Account in stats plays with no team but players tagged

 LongoMatch.Core/Stats/ProjectStats.cs |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/LongoMatch.Core/Stats/ProjectStats.cs b/LongoMatch.Core/Stats/ProjectStats.cs
index a334c43..27d9252 100644
--- a/LongoMatch.Core/Stats/ProjectStats.cs
+++ b/LongoMatch.Core/Stats/ProjectStats.cs
@@ -143,7 +143,7 @@ namespace LongoMatch.Stats
                        
                        foreach (Category cat in project.Categories) {
                                CategoryStats stats;
-                               List<Play> plays, homePlays, awayPlays;
+                               List<Play> plays, homePlays, awayPlays, untagged;
                                int localTeamCount, visitorTeamCount;
                                
                                plays = project.PlaysInCategory (cat);
@@ -152,7 +152,14 @@ namespace LongoMatch.Stats
                                }
                                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();
+                               
+                               /* Get the plays where the team is not tagged but we have at least one player 
from a team tagged */
+                               untagged = plays.Where (p=> p.Team ==  Team.NONE).ToList();
+                               homePlays.AddRange (untagged.Where (p => p.Players.Tags.Where (pt => 
project.LocalTeamTemplate.Contains(pt.Value)).Count() != 0).ToList());
+                               awayPlays.AddRange (untagged.Where (p => p.Players.Tags.Where (pt => 
project.VisitorTeamTemplate.Contains(pt.Value)).Count() != 0).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();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]