예제 #1
0
        public ObservableCollection <ResultRowGeneric> GenerateYearsOverGames()
        {
            Dictionary <string, Dictionary <string, int> > v_YearsOverGamesDict = new Dictionary <string, Dictionary <string, int> >();
            String v_KeyTotalPlayed = "Total Played";
            int    v_YearLowest     = int.MaxValue;
            int    v_YearHighest    = int.MinValue;

            foreach (Result i_Result in ResultsOrdered)
            {
                if (i_Result.Date.Year > v_YearHighest)
                {
                    v_YearHighest = i_Result.Date.Year;
                }
                else if (i_Result.Date.Year < v_YearLowest)
                {
                    v_YearLowest = i_Result.Date.Year;
                }
            }

            foreach (Game i_Game in GamesSorted)
            {
                v_YearsOverGamesDict.Add(i_Game.Name, new Dictionary <string, int>());
                v_YearsOverGamesDict[i_Game.Name].Add(v_KeyTotalPlayed, 0);

                for (int i = v_YearLowest; i <= v_YearHighest; i++)
                {
                    v_YearsOverGamesDict[i_Game.Name].Add(i.ToString(), 0);
                }
            }

            foreach (Result i_Result in ResultsOrdered)
            {
                string v_ActualYear = i_Result.Date.Year.ToString();
                String v_GameName   = GamesById[i_Result.IdGame].Name;

                v_YearsOverGamesDict[v_GameName][v_ActualYear]++;
                v_YearsOverGamesDict[v_GameName][v_KeyTotalPlayed]++;
            }

            var v_ResultRows = new ObservableCollection <ResultRowGeneric>();

            foreach (KeyValuePair <string, Dictionary <string, int> > i_Outer in v_YearsOverGamesDict)
            {
                ResultRowGeneric v_ActualRow = new ResultRowGeneric();
                v_ActualRow.Properties.Add(new GenericProperty("GameName", i_Outer.Key));

                foreach (KeyValuePair <string, int> i_Inner in i_Outer.Value)
                {
                    v_ActualRow.Properties.Add(new GenericProperty(i_Inner.Key, i_Inner.Value));
                }

                v_ResultRows.Add(v_ActualRow);
            }

            return(v_ResultRows);
        }
예제 #2
0
        public ObservableCollection <ResultRowGeneric> GeneratePlayersOverGames()
        {
            String v_KeyTotalPlayed = "Total Played";
            Dictionary <string, Dictionary <string, int> > v_PlayerOverGamesDict = new Dictionary <string, Dictionary <string, int> >();

            foreach (Game i_Game in GamesSorted)
            {
                v_PlayerOverGamesDict.Add(i_Game.Name, new Dictionary <string, int>());
                v_PlayerOverGamesDict[i_Game.Name].Add(v_KeyTotalPlayed, 0);

                foreach (Player i_Player in PlayersSorted)
                {
                    v_PlayerOverGamesDict[i_Game.Name].Add(i_Player.Name, 0);
                }
            }

            foreach (Result i_Result in Results)
            {
                v_PlayerOverGamesDict[GamesById[i_Result.IdGame].Name][v_KeyTotalPlayed]++;

                foreach (Score i_Score in i_Result.Scores)
                {
                    v_PlayerOverGamesDict[GamesById[i_Result.IdGame].Name][PlayersById[i_Score.IdPlayer].Name]++;
                }
            }

            var v_ResultRows = new ObservableCollection <ResultRowGeneric>();

            foreach (KeyValuePair <string, Dictionary <string, int> > i_Outer in v_PlayerOverGamesDict)
            {
                ResultRowGeneric v_ActualRow = new ResultRowGeneric();
                v_ActualRow.Properties.Add(new GenericProperty("GameName", i_Outer.Key));

                foreach (KeyValuePair <string, int> i_Inner in i_Outer.Value)
                {
                    v_ActualRow.Properties.Add(new GenericProperty(i_Inner.Key, i_Inner.Value));
                }

                v_ResultRows.Add(v_ActualRow);
            }

            return(v_ResultRows);
        }
예제 #3
0
        public ObservableCollection <ResultRowGeneric> GeneratePlayersOverPlayers()
        {
            Dictionary <Guid, Dictionary <Guid, Standing> > v_PlayersOverPlayersDict = new Dictionary <Guid, Dictionary <Guid, Standing> >();

            foreach (Player i_PlayerOuter in PlayersSorted)
            {
                v_PlayersOverPlayersDict.Add(i_PlayerOuter.Id, new Dictionary <Guid, Standing>());

                foreach (Player i_PlayerInner in PlayersSorted)
                {
                    v_PlayersOverPlayersDict[i_PlayerOuter.Id].Add(i_PlayerInner.Id, new Standing());

                    if (i_PlayerInner.Name == i_PlayerOuter.Name)
                    {
                        // No scores against yourself
                        v_PlayersOverPlayersDict[i_PlayerOuter.Id][i_PlayerInner.Id].IsInvalid = true;
                    }
                }
            }

            foreach (Result i_Result in Results)
            {
                foreach (Score i_Score in i_Result.Scores)
                {
                    Dictionary <Modifier, List <Guid> > v_Standings = i_Result.CalculateStandings(i_Score.IdPlayer, GamesById[i_Result.IdGame].Type);

                    foreach (KeyValuePair <Modifier, List <Guid> > i_Kvp in v_Standings)
                    {
                        foreach (Guid v_Id in i_Kvp.Value)
                        {
                            if (i_Kvp.Key == Modifier.Lose)
                            {
                                v_PlayersOverPlayersDict[i_Score.IdPlayer][v_Id].Lost++;
                            }
                            else if (i_Kvp.Key == Modifier.Win)
                            {
                                v_PlayersOverPlayersDict[i_Score.IdPlayer][v_Id].Won++;
                            }
                            else if (i_Kvp.Key == Modifier.Stalemate)
                            {
                                v_PlayersOverPlayersDict[i_Score.IdPlayer][v_Id].Stalemate++;
                            }
                        }
                    }
                }
            }

            var v_ResultRows = new ObservableCollection <ResultRowGeneric>();

            foreach (KeyValuePair <Guid, Dictionary <Guid, Standing> > i_Outer in v_PlayersOverPlayersDict)
            {
                ResultRowGeneric v_ActualRow = new ResultRowGeneric();
                v_ActualRow.Properties.Add(new GenericProperty("Against", PlayersById[i_Outer.Key].Name));

                foreach (KeyValuePair <Guid, Standing> i_Inner in i_Outer.Value)
                {
                    v_ActualRow.Properties.Add(new GenericProperty(PlayersById[i_Inner.Key].Name, i_Inner.Value));
                }

                v_ResultRows.Add(v_ActualRow);
            }

            return(v_ResultRows);
        }