public int Compare(Match x, Match y) { List <Club> ranking = _round.Ranking(); int nivMatchX = ranking.IndexOf(x.home) + ranking.IndexOf(x.away); int nivMatchY = ranking.IndexOf(y.home) + ranking.IndexOf(y.away); return(nivMatchX - nivMatchY); }
private void BandeauActualites() { tbActu.Text = ""; if (_partie.club != null && _partie.club.Championship != null) { //Choix de la compétition à afficher dans le bandeau : compétition du dernier match joué par l'équipe List <Match> matchs = _partie.club.Games; bool trouve = false; Tournament comp = null; int i = 0; if (matchs.Count == 0) { trouve = true; } while (!trouve) { if (!matchs[i].Played) { comp = matchs[i].Tournament; trouve = true; } i++; if (i + 1 == matchs.Count) { trouve = true; } } if (comp != null) { Round t = null; if (comp.isChampionship) { t = comp.rounds[0]; tbActu.Text = comp.name + " : "; i = 1; ChampionshipRound tc = t as ChampionshipRound; if (tc != null) { foreach (Club c in tc.Ranking()) { tbActu.Text += i + " " + c.shortName + " " + t.Points(c) + ", " + t.Difference(c) + " / "; i++; } } } else { t = comp.rounds[comp.currentRound]; tbActu.Text += comp.name + ", " + t.name + " : "; foreach (Match m in t.matches) { tbActu.Text += m.home.shortName + " " + m.score1 + "-" + m.score2 + " " + m.away.shortName + ", "; } } } } }
public override void Full(StackPanel spRanking) { spRanking.Children.Clear(); int i = 0; List <Club> clubs = _round.Ranking(_rankingType); //If we choose to focus on a team, we center the ranking on the team and +-2 other teams around int indexTeam = -1; if (_focusOnTeam && _team != null) { clubs = new List <Club>(); List <Club> ranking = _round.Ranking(); int index = ranking.IndexOf(Session.Instance.Game.club); index = index - 2; if (index < 0) { index = 0; } if (index > ranking.Count - 5) { index = ranking.Count - 5; } i = index; for (int j = index; j < index + 5; j++) { Club c = ranking[j]; clubs.Add(c); if (c == Session.Instance.Game.club) { indexTeam = j - index; } } } double fontSize = (double)Application.Current.FindResource("TailleMoyenne"); double regularCellWidth = 36 * _sizeMultiplier; StackPanel spTitle = new StackPanel(); spTitle.Orientation = Orientation.Horizontal; spTitle.Children.Add(ViewUtils.CreateLabel("", "StyleLabel2", fontSize * _sizeMultiplier, regularCellWidth / 1.25 + regularCellWidth / 1.5 + regularCellWidth * 3.5)); spTitle.Children.Add(ViewUtils.CreateLabel("Pts", "StyleLabel2Center", fontSize * _sizeMultiplier, regularCellWidth)); spTitle.Children.Add(ViewUtils.CreateLabel("J", "StyleLabel2Center", fontSize * _sizeMultiplier, regularCellWidth)); if (!_reduced) { spTitle.Children.Add(ViewUtils.CreateLabel("G", "StyleLabel2Center", fontSize * _sizeMultiplier, regularCellWidth)); spTitle.Children.Add(ViewUtils.CreateLabel("N", "StyleLabel2Center", fontSize * _sizeMultiplier, regularCellWidth)); spTitle.Children.Add(ViewUtils.CreateLabel("P", "StyleLabel2Center", fontSize * _sizeMultiplier, regularCellWidth)); spTitle.Children.Add(ViewUtils.CreateLabel("p.", "StyleLabel2Center", fontSize * _sizeMultiplier, regularCellWidth)); spTitle.Children.Add(ViewUtils.CreateLabel("c.", "StyleLabel2Center", fontSize * _sizeMultiplier, regularCellWidth)); } spTitle.Children.Add(ViewUtils.CreateLabel("Diff", "StyleLabel2Center", fontSize * _sizeMultiplier, regularCellWidth * 1.25)); spRanking.Children.Add(spTitle); foreach (Club c in clubs) { i++; StackPanel sp = new StackPanel(); sp.Orientation = Orientation.Horizontal; sp.Children.Add(ViewUtils.CreateLabel(i.ToString(), "StyleLabel2", fontSize * _sizeMultiplier, regularCellWidth / 1.25)); if (_round.Tournament.IsInternational() && (c as CityClub) != null) { sp.Children.Add(ViewUtils.CreateFlag((c as CityClub).city.Country(), regularCellWidth / 1.5, regularCellWidth / 1.5)); } else if (_round.Tournament.IsInternational() && (c as ReserveClub) != null) { sp.Children.Add(ViewUtils.CreateFlag((c as ReserveClub).FannionClub.city.Country(), regularCellWidth / 1.5, regularCellWidth / 1.5)); } else { sp.Children.Add(ViewUtils.CreateLogo(c, regularCellWidth / 1.5, regularCellWidth / 1.5)); } sp.Children.Add(ViewUtils.CreateLabelOpenWindow <Club>(c, OpenClub, _round.Tournament.isChampionship ? c.extendedName : c.shortName, "StyleLabel2", fontSize * _sizeMultiplier, regularCellWidth * 3.5)); sp.Children.Add(ViewUtils.CreateLabel(_round.Points(c, _rankingType).ToString(), "StyleLabel2", fontSize * _sizeMultiplier, regularCellWidth, null, null, true)); sp.Children.Add(ViewUtils.CreateLabel(_round.Played(c, _rankingType).ToString(), "StyleLabel2", fontSize * _sizeMultiplier, regularCellWidth)); if (!_reduced) { sp.Children.Add(ViewUtils.CreateLabel(_round.Wins(c, _rankingType).ToString(), "StyleLabel2", fontSize * _sizeMultiplier, regularCellWidth)); sp.Children.Add(ViewUtils.CreateLabel(_round.Draws(c, _rankingType).ToString(), "StyleLabel2", fontSize * _sizeMultiplier, regularCellWidth)); sp.Children.Add(ViewUtils.CreateLabel(_round.Loses(c, _rankingType).ToString(), "StyleLabel2", fontSize * _sizeMultiplier, regularCellWidth)); sp.Children.Add(ViewUtils.CreateLabel(_round.GoalsFor(c, _rankingType).ToString(), "StyleLabel2", fontSize * _sizeMultiplier, regularCellWidth)); sp.Children.Add(ViewUtils.CreateLabel(_round.GoalsAgainst(c, _rankingType).ToString(), "StyleLabel2", fontSize * _sizeMultiplier, regularCellWidth)); } sp.Children.Add(ViewUtils.CreateLabel(_round.Difference(c, _rankingType).ToString(), "StyleLabel2", fontSize * _sizeMultiplier, regularCellWidth * 1.25)); spRanking.Children.Add(sp); } //Only show colors when the ranking is not focused on a team if (!_focusOnTeam) { Club cupWinner = (Session.Instance.Game.kernel.LocalisationTournament(_round.Tournament) as Country)?.Cup(1)?.Winner(); int roundLevel = _round.Tournament.level; ILocalisation localisation = Session.Instance.Game.kernel.LocalisationTournament(_round.Tournament); Country country = localisation as Country; List <Club> registeredClubs = new List <Club>(); if (country != null && roundLevel == 1) { Continent continent = country.Continent; int nationIndex = continent.associationRanking.IndexOf(country) + 1; int currentRanking = 0; int totalQualificationsFromLeague = (from qualification in continent.continentalQualifications where (qualification.ranking == nationIndex && !qualification.isNextYear) select qualification.qualifies).Sum(); foreach (Qualification q in continent.continentalQualifications) { //q.isNextYear refeer to cup winner qualification for continental competition if (q.ranking == nationIndex && (!q.isNextYear || registeredClubs.Contains(cupWinner))) { for (int j = 0; j < q.qualifies; j++) { registeredClubs.Add(clubs[currentRanking]); string color = QualificationColor(q); SolidColorBrush lineColor = Application.Current.TryFindResource(color) as SolidColorBrush; (spRanking.Children[currentRanking + 1] as StackPanel).Background = lineColor; currentRanking++; } } else if (q.ranking == nationIndex && q.isNextYear && clubs.Contains(cupWinner)) { string color = QualificationColor(q); SolidColorBrush lineColor = Application.Current.TryFindResource(color) as SolidColorBrush; (spRanking.Children[clubs.IndexOf(cupWinner) + 1] as StackPanel).Background = lineColor; } } } foreach (Qualification q in _round.qualifications) { string color = "backgroundColor"; if (q.tournament.isChampionship) { if (q.tournament.level < roundLevel) { color = "promotionColor"; } else if (q.tournament.level > roundLevel) { color = "relegationColor"; } else if (q.tournament.level == roundLevel && q.roundId > _round.Tournament.rounds.IndexOf(_round)) { color = "barrageColor"; } } else if (q.tournament.IsInternational()) { if (q.tournament.level == 1 && q.tournament.rounds[q.roundId] as GroupsRound != null) { color = "cl1Color"; } else if (q.tournament.level == 1) { color = "cl2Color"; } else if (q.tournament.level == 2 && q.tournament.rounds[q.roundId] as GroupsRound != null) { color = "el1Color"; } else if (q.tournament.level == 2) { color = "el2Color"; } else if (q.tournament.level == 3) { color = "el3Color"; } } int index = q.ranking; if (color != "backgroundColor" && clubs.Count > 0) { SolidColorBrush lineColor = Application.Current.TryFindResource(color) as SolidColorBrush; (spRanking.Children[index] as StackPanel).Background = lineColor; } } } else { SolidColorBrush color = new SolidColorBrush((System.Windows.Media.Color)Application.Current.TryFindResource("ColorDate")); color.Opacity = 0.6; (spRanking.Children[indexTeam + 1] as StackPanel).Background = color; } }
public static void Exporter(Tournament c) { ExporterClubs(); StringBuilder dir = new StringBuilder(); dir.Append("Output\\").Append(c.name).Append(" ").Append(Session.Instance.Game.date.Year); StringBuilder dir2 = new StringBuilder(); dir2.Append("Output\\").Append(c.shortName).Append(" ").Append(Session.Instance.Game.date.Year); if (!Directory.Exists(dir.ToString())) { Directory.CreateDirectory(dir.ToString()); } if (!Directory.Exists(dir2.ToString())) { Directory.CreateDirectory(dir2.ToString()); } foreach (Round t in c.rounds) { if (!Directory.Exists(dir + "\\" + t.name)) { Directory.CreateDirectory(dir + "\\" + t.name); } if (!Directory.Exists(dir2 + "\\" + t.name)) { Directory.CreateDirectory(dir2 + "\\" + t.name); } StringBuilder output = new StringBuilder(); output.Append("<p>").Append(t.name).Append("</p><p>"); foreach (Club cl in t.clubs) { CityClub cv = cl as CityClub; if (cv != null) { output.Append("").Append(cl.name).Append(" - ").Append(cl.formationFacilities).Append(" - ") .Append(cv.budget).Append(" €<br>"); } } output.Append("</p>"); if (t as ChampionshipRound != null) { ChampionshipRound tc = t as ChampionshipRound; output.Append("<table>"); foreach (Club club in tc.Ranking()) { output.Append("<tr><td>").Append(club.name).Append("</td><td>").Append(tc.Points(club)) .Append("</td><td>").Append(tc.Played(club)).Append("</td><td>").Append(tc.Wins(club)) .Append("</td><td>").Append(tc.Draws(club)).Append("</td><td>").Append(tc.Loses(club)) .Append("</td><td>").Append(tc.GoalsFor(club)).Append("</td><td>") .Append(tc.GoalsAgainst(club)).Append("</td><td>").Append(tc.Difference(club)) .Append("</td></tr>"); } output.Append("</table>"); int matchsJournee = (tc.clubs.Count % 2 == 1) ? tc.clubs.Count / 2 + 1 : tc.clubs.Count / 2; int nbJournees = (tc.matches.Count / tc.clubs.Count) * 2; int k = 0; Exporteurs2.ExporterClassementL(tc, "Output\\" + c.shortName + Session.Instance.Game.date.Year + "\\" + t.name + "\\Matchs\\"); for (int i = 0; i < nbJournees; i++) { List <Match> journee = new List <Match>(); for (int j = 0; j < matchsJournee; j++) { journee.Add(tc.matches[i * matchsJournee + j]); } journee.Sort(new MatchDateComparator()); Exporteurs2.ExporterL(journee, "Output\\" + c.shortName + Session.Instance.Game.date.Year + "\\" + t.name, i + 1); output.Append("<p>Journée ").Append((i + 1)).Append("</p><table>"); DateTime last = new DateTime(2000, 1, 1); foreach (Match m in journee) { if (m.day.Date != last.Date) { output.Append("<tr><td colspan=\"3\">").Append(m.day.Date.ToShortDateString()) .Append("</td></tr>"); } last = m.day; output.Append("<tr><td>").Append(m.day.ToShortTimeString()).Append("</td><td>") .Append(m.home.name).Append("</td><td><a href=\"").Append(tc.name).Append("\\") .Append(k).Append(".html\">").Append(m.score1).Append("-").Append(m.score2) .Append("</a></td><td>").Append(m.away.name).Append("</td></tr>"); EcrireMatch(m, dir + "\\" + tc.name + "\\" + k + ".html"); k++; } output.Append("</table>"); } } if (t as KnockoutRound != null) { KnockoutRound te = t as KnockoutRound; output.Append("<table>"); int k = 0; List <Match> matchs = new List <Match>(te.matches); matchs.Sort(new MatchDateComparator()); DateTime last = new DateTime(2000, 1, 1); Exporteurs2.ExporterD(matchs, dir + "\\" + te.name + "\\"); foreach (Match m in matchs) { if (m.day.Date != last.Date) { output.Append("<tr><td colspan=\"3\">").Append(m.day.Date.ToShortDateString()) .Append("</td></tr>"); } last = m.day; Tournament compDom = m.home.Championship; Tournament compExt = m.away.Championship; string sCompDom = ""; string sCompExt = ""; if (compDom != null) { sCompDom = " (" + compDom.shortName + ")"; } if (compExt != null) { sCompExt = " (" + compExt.shortName + ")"; } string score = m.score1 + " - " + m.score2; if (m.prolongations) { score += " ap"; } if (m.PenaltyShootout) { score += " (" + m.penaltyShootout1 + "-" + m.penaltyShootout2 + " tab)"; } output.Append("<tr><td>").Append(m.day.ToShortTimeString()).Append("</td><td>") .Append(m.home.name).Append(sCompDom).Append("</td><td><a href=\"").Append(te.name) .Append("\\").Append(k).Append(".html\">").Append(score).Append("</a></td><td>") .Append(m.away.name).Append(sCompExt).Append("</td></tr>"); EcrireMatch(m, dir + "\\" + te.name + "\\" + k + ".html"); k++; } } if (t as InactiveRound != null) { InactiveRound ti = t as InactiveRound; output.Append("<p><b>Clubs participants</b></p>"); List <Club> clubs = new List <Club>(ti.clubs); foreach (Club club in clubs) { output.Append("<p>").Append(club.name).Append("</p>"); } } if (t as GroupsRound != null) { GroupsRound tp = t as GroupsRound; int nbEquipesParPoules = 0; foreach (List <Club> poules in tp.groups) { if (nbEquipesParPoules < poules.Count) { nbEquipesParPoules = poules.Count; } List <Club> classement = new List <Club>(poules); classement.Sort(new ClubRankingComparator(t.matches)); output.Append("<p>Groupe</p><table>"); foreach (Club club in classement) { output.Append("<tr><td>").Append(club.name).Append("</td><td>").Append(t.Points(club)) .Append("</td><td>").Append(t.Played(club)).Append("</td><td>").Append(t.Wins(club)) .Append("</td><td>").Append(t.Draws(club)).Append("</td><td>").Append(t.Loses(club)) .Append("</td><td>").Append(t.GoalsFor(club)).Append("</td><td>") .Append(t.GoalsAgainst(club)).Append("</td><td>").Append(t.Difference(club)) .Append("</td></tr>"); } output.Append("</table>"); } int nbJournees = nbEquipesParPoules - 1; if (t.twoLegs) { nbJournees *= 2; } int matchsJournee = t.matches.Count / nbJournees; int k = 0; for (int i = 0; i < nbJournees; i++) { List <Match> journee = new List <Match>(); for (int j = 0; j < matchsJournee; j++) { journee.Add(t.matches[i * matchsJournee + j]); } journee.Sort(new MatchDateComparator()); output.Append("<p>Journée ").Append((int)(i + 1)).Append("</p><table>"); foreach (Match m in journee) { output.Append("<tr><td>").Append(m.day.ToString()).Append("</td><td>").Append(m.home.name) .Append("</td><td><a href=\"").Append(t.name).Append("\\").Append(k).Append(".html\">") .Append(m.score1).Append("-").Append(m.score2).Append("</a></td><td>") .Append(m.away.name).Append("</td></tr>"); EcrireMatch(m, dir + "\\" + t.name + "\\" + k + ".html"); k++; } output.Append("</table>"); } } output.Append("<p>Moyenne de buts : ").Append(t.GoalsAverage()).Append("</p><p>Buteurs</p><table>"); foreach (KeyValuePair <Player, int> j in t.GoalScorers()) { output.Append("<tr><td>").Append(j.Key.firstName).Append(" ").Append(j.Key.lastName) .Append("</td><td>").Append(j.Value).Append("</td></tr>"); } output.Append("</table>"); File.WriteAllText(dir + "\\" + t.name + ".html", output.ToString()); } }