Exemple #1
0
        private void SelectedSeasonsClubs(object sender, RoutedEventArgs e)
        {
            Dictionary <Club, int> clubs = new Dictionary <Club, int>();

            spRanking.Children.Clear();
            foreach (KeyValuePair <int, Tournament> t in _competition.previousEditions)
            {
                if (t.Value.isChampionship)
                {
                    foreach (Club c in t.Value.rounds[0].clubs)
                    {
                        if (!clubs.ContainsKey(c))
                        {
                            clubs.Add(c, 0);
                        }
                        clubs[c]++;
                    }
                }
                else
                {
                    List <Club> clubsList = new List <Club>();
                    foreach (Round r in t.Value.rounds)
                    {
                        foreach (Club c in r.clubs)
                        {
                            if (!clubsList.Contains(c))
                            {
                                clubsList.Add(c);
                            }
                        }
                    }
                    foreach (Club c in clubsList)
                    {
                        if (!clubs.ContainsKey(c))
                        {
                            clubs.Add(c, 0);
                        }
                        clubs[c]++;
                    }
                }
            }
            List <KeyValuePair <Club, int> > list = clubs.ToList();

            list.Sort((pair1, pair2) => pair2.Value.CompareTo(pair1.Value));
            foreach (KeyValuePair <Club, int> club in list)
            {
                StackPanel spClub = new StackPanel();
                spClub.Orientation = Orientation.Horizontal;
                spClub.Children.Add(ViewUtils.CreateLogo(club.Key, 25, 25));
                spClub.Children.Add(ViewUtils.CreateLabel(club.Key.name, "StyleLabel2", 12, 200));
                spClub.Children.Add(ViewUtils.CreateLabel(club.Value.ToString(), "StyleLabel2", 12, 50, null, null, true));
                spRanking.Children.Add(spClub);
            }
        }
Exemple #2
0
        private void SelectedStatShot(object sender, RoutedEventArgs e)
        {
            spRanking.Children.Clear();

            Dictionary <Club, float> tirs        = new Dictionary <Club, float>();
            Dictionary <Club, int>   playedGames = new Dictionary <Club, int>();

            foreach (Round r in _competition.rounds)
            {
                foreach (Match m in r.matches)
                {
                    if (!tirs.ContainsKey(m.home))
                    {
                        tirs.Add(m.home, 0);
                        playedGames.Add(m.home, 0);
                    }
                    if (!tirs.ContainsKey(m.away))
                    {
                        tirs.Add(m.away, 0);
                        playedGames.Add(m.away, 0);
                    }
                    tirs[m.home] += m.statistics.HomeShoots;
                    tirs[m.away] += m.statistics.AwayShoots;
                    playedGames[m.home]++;
                    playedGames[m.away]++;
                }
            }
            List <KeyValuePair <Club, float> > list = tirs.ToList();

            list.Sort((pair1, pair2) => pair2.Value.CompareTo(pair1.Value));

            foreach (KeyValuePair <Club, float> kvp in list)
            {
                StackPanel sp = new StackPanel();
                sp.Orientation = Orientation.Horizontal;
                sp.Children.Add(ViewUtils.CreateLogo(kvp.Key, 25, 25));
                sp.Children.Add(ViewUtils.CreateLabel(kvp.Key.name, "StyleLabel2", 12, 250));
                sp.Children.Add(ViewUtils.CreateLabel(kvp.Value.ToString(), "StyleLabel2", 12, 100));
                sp.Children.Add(ViewUtils.CreateLabel((kvp.Value / playedGames[kvp.Key]).ToString("0.00") + "/m", "StyleLabel2", 12, 100));
                sp.Children.Add(ViewUtils.CreateLabel(playedGames[kvp.Key].ToString(), "StyleLabel2", 12, 100));
                spRanking.Children.Add(sp);
            }
        }
Exemple #3
0
        private void SelectedPotential(object sender, RoutedEventArgs e)
        {
            spRanking.Children.Clear();
            List <Club> clubs = new List <Club>(_competition.rounds[_indexTour].clubs);

            clubs.Sort(new ClubComparator(ClubAttribute.POTENTIEL, false));
            int i = 0;

            foreach (Club c in clubs)
            {
                i++;
                StackPanel sp = new StackPanel();
                sp.Orientation = Orientation.Horizontal;
                sp.Children.Add(ViewUtils.CreateLabel(i.ToString(), "StyleLabel2", 12, 30));
                sp.Children.Add(ViewUtils.CreateLogo(c, 25, 25));
                sp.Children.Add(ViewUtils.CreateLabel(c.name, "StyleLabel2", 12, 200));
                sp.Children.Add(ViewUtils.CreateLabel(c.Potential().ToString("0.0"), "StyleLabel2", 12, 50));
                spRanking.Children.Add(sp);
            }
        }
Exemple #4
0
        private void SelectedGoalscorers(object sender, RoutedEventArgs e)
        {
            spRanking.Children.Clear();

            foreach (KeyValuePair <Player, int> goalscorer in _competition.Goalscorers())
            {
                StackPanel sp = new StackPanel();
                sp.Orientation = Orientation.Horizontal;
                if (goalscorer.Key.Club != null)
                {
                    sp.Children.Add(ViewUtils.CreateLogo(goalscorer.Key.Club, 25, 25));
                }
                else
                {
                    sp.Children.Add(ViewUtils.CreateFlag(goalscorer.Key.nationality, 25, 18));
                }
                sp.Children.Add(ViewUtils.CreateLabel(goalscorer.Key.Name, "StyleLabel2", 12, 200));
                sp.Children.Add(ViewUtils.CreateLabel(goalscorer.Value.ToString(), "StyleLabel2", 12, 50));
                spRanking.Children.Add(sp);
            }
        }
Exemple #5
0
        private void SelectedAttendance(object sender, RoutedEventArgs e)
        {
            spRanking.Children.Clear();

            Dictionary <Club, int> attendances = new Dictionary <Club, int>();

            Round r = _competition.rounds[_indexTour];

            foreach (Club c in r.clubs)
            {
                attendances.Add(c, 0);
                int count = 0;
                foreach (Match m in r.matches)
                {
                    if (m.home == c)
                    {
                        count++;
                        attendances[c] += m.attendance;
                    }
                }
                if (count > 0)
                {
                    attendances[c] /= count;
                }
            }

            List <KeyValuePair <Club, int> > list = attendances.ToList();

            list.Sort((pair1, pair2) => pair2.Value.CompareTo(pair1.Value));

            foreach (KeyValuePair <Club, int> club in list)
            {
                StackPanel sp = new StackPanel();
                sp.Orientation = Orientation.Horizontal;
                sp.Children.Add(ViewUtils.CreateLogo(club.Key, 25, 25));
                sp.Children.Add(ViewUtils.CreateLabel(club.Key.name, "StyleLabel2", 12, 200));
                sp.Children.Add(ViewUtils.CreateLabel(club.Value.ToString(), "StyleLabel2", 12, 75, null, null, true));
                spRanking.Children.Add(sp);
            }
        }
Exemple #6
0
        private void SelectedPalmaresClubs(object sender, RoutedEventArgs e)
        {
            spRanking.Children.Clear();

            Dictionary <Club, List <int> > palmares = new Dictionary <Club, List <int> >();

            foreach (KeyValuePair <int, Tournament> arc in _competition.previousEditions)
            {
                Club winner = arc.Value.Winner();
                if (winner != null)
                {
                    if (!palmares.ContainsKey(winner))
                    {
                        palmares.Add(winner, new List <int>());
                    }
                    palmares[winner].Add(arc.Key);
                }
            }

            List <KeyValuePair <Club, List <int> > > list = palmares.ToList();

            list.Sort((pair1, pair2) => pair2.Value.Count.CompareTo(pair1.Value.Count));

            foreach (KeyValuePair <Club, List <int> > club in list)
            {
                StackPanel sp = new StackPanel();
                sp.Orientation = Orientation.Horizontal;
                sp.Children.Add(ViewUtils.CreateLogo(club.Key, 25, 25));
                sp.Children.Add(ViewUtils.CreateLabel(club.Key.name, "StyleLabel2", 12, 200));
                sp.Children.Add(ViewUtils.CreateLabel(club.Value.Count.ToString(), "StyleLabel2", 12, 50, null, null, true));
                StringBuilder bld = new StringBuilder();
                foreach (float years in club.Value)
                {
                    bld.Append(years + ", ");
                }
                string yearList = bld.ToString();
                sp.Children.Add(ViewUtils.CreateLabel(yearList, "StyleLabel2", 12, 250));
                spRanking.Children.Add(sp);
            }
        }
Exemple #7
0
        private void SelectedPalmaresYears(object sender, RoutedEventArgs e)
        {
            spRanking.Children.Clear();

            foreach (KeyValuePair <int, Tournament> arc in _competition.previousEditions)
            {
                Club winner = arc.Value.Winner();

                Round t = arc.Value.rounds[arc.Value.rounds.Count - 1];
                //If the final round was not inactive, we can make the palmares
                if (t.matches.Count > 0)
                {
                    int        year = arc.Key;
                    StackPanel sp   = new StackPanel();
                    sp.Orientation = Orientation.Horizontal;
                    sp.Children.Add(ViewUtils.CreateLabel(year.ToString(), "StyleLabel2", 12, 100));
                    sp.Children.Add(ViewUtils.CreateLogo(winner, 25, 25));
                    sp.Children.Add(ViewUtils.CreateLabel(winner.name, "StyleLabel2", 12, 200));
                    spRanking.Children.Add(sp);
                }
            }
        }
Exemple #8
0
        private void SelectedBudget(object sender, RoutedEventArgs e)
        {
            spRanking.Children.Clear();
            List <Club> clubs = new List <Club>(_competition.rounds[_indexTour].clubs);

            clubs.Sort(new ClubComparator(ClubAttribute.BUDGET, false));
            int i = 0;

            foreach (Club c in clubs)
            {
                if (c as CityClub != null)
                {
                    i++;
                    StackPanel sp = new StackPanel();
                    sp.Orientation = Orientation.Horizontal;
                    sp.Children.Add(ViewUtils.CreateLabel(i.ToString(), "StyleLabel2", 12, 30));
                    sp.Children.Add(ViewUtils.CreateLogo(c, 25, 25));
                    sp.Children.Add(ViewUtils.CreateLabel(c.name, "StyleLabel2", 12, 200));
                    sp.Children.Add(ViewUtils.CreateLabel(Utils.FormatMoney((c as CityClub).budget), "StyleLabel2", 12, 100));
                    spRanking.Children.Add(sp);
                }
            }
        }
        private void FillNextMatchPanel()
        {
            spNextMatch.Children.Clear();

            Match next = Session.Instance.Game.club.NextGame;

            if (next != null)
            {
                //Create the 3 stacks panels
                StackPanel spHomeTeam = new StackPanel();
                spHomeTeam.Orientation         = Orientation.Vertical;
                spHomeTeam.HorizontalAlignment = HorizontalAlignment.Center;
                StackPanel spAwayTeam = new StackPanel();
                spAwayTeam.Orientation         = Orientation.Vertical;
                spAwayTeam.HorizontalAlignment = HorizontalAlignment.Center;
                StackPanel spInfos = new StackPanel();
                spInfos.Orientation         = Orientation.Vertical;
                spInfos.HorizontalAlignment = HorizontalAlignment.Center;
                spInfos.Width = 150;

                //Infos stack panel
                Round      r   = next.Round;
                Tournament trn = r.Tournament;

                TextBox tbTournament = new TextBox();
                tbTournament.Text                = next.Round.Tournament.name;
                tbTournament.Style               = FindResource("StyleTextBox") as Style;
                tbTournament.IsEnabled           = false;
                tbTournament.FontSize            = 16;
                tbTournament.HorizontalAlignment = HorizontalAlignment.Center;
                tbTournament.Background          = (SolidColorBrush)(new BrushConverter().ConvertFrom(trn.color.ToHexa()));
                tbTournament.Foreground          = Brushes.AntiqueWhite;

                spInfos.Children.Add(tbTournament);
                spInfos.Children.Add(ViewUtils.CreateLabel(r.name, "StyleLabel2Center", -1, -1));
                spInfos.Children.Add(ViewUtils.CreateLabel(next.day.ToShortTimeString(), "StyleLabel2Center", -1, -1));
                spInfos.Children.Add(ViewUtils.CreateLabel(next.home.stadium.name, "StyleLabel2Center", -1, -1));

                //Home team stack panel
                spHomeTeam.Children.Add(ViewUtils.CreateLogo(next.home, 125, 125));
                Label homeLabel = ViewUtils.CreateLabel(next.home.shortName, "StyleLabel2Center", 16, -1);
                homeLabel.HorizontalAlignment = HorizontalAlignment.Center;
                spHomeTeam.Children.Add(homeLabel);
                StackPanel homeStars = ViewUtils.CreateStarNotation(next.home.Stars, 25);
                homeStars.HorizontalAlignment = HorizontalAlignment.Center;
                spHomeTeam.Children.Add(homeStars);

                //Away team stack panel
                spAwayTeam.Children.Add(ViewUtils.CreateLogo(next.away, 125, 125));
                Label awayLabel = ViewUtils.CreateLabel(next.away.shortName, "StyleLabel2Center", 16, -1);
                awayLabel.HorizontalAlignment = HorizontalAlignment.Center;
                spAwayTeam.Children.Add(awayLabel);
                StackPanel awayStars = ViewUtils.CreateStarNotation(next.away.Stars, 25);
                awayStars.HorizontalAlignment = HorizontalAlignment.Center;
                spAwayTeam.Children.Add(awayStars);

                spNextMatch.Children.Add(spHomeTeam);
                spNextMatch.Children.Add(spInfos);
                spNextMatch.Children.Add(spAwayTeam);
            }
        }