Ejemplo n.º 1
0
        public string GenerateArticle(ContractOffer co, CityClub to)
        {
            string res      = "";
            string priceStr = "";

            if (co.TransferIndemnity > 0)
            {
                priceStr = "Pour " + co.TransferIndemnity + " €";
            }

            switch (co.Result)
            {
            case ContractOfferResult.Successful:
                res = co.Player.lastName + " rejoint " + to.shortName + " " + priceStr + ".";
                if (co.Origin == null)
                {
                    res += " Le joueur était libre.";
                }
                break;

            case ContractOfferResult.NoAgreementWithPlayer:
            default:
                res = to.shortName + " n'arrive pas à s'entendre avec " + co.Player.lastName + ".";
                break;
            }
            return(res);
        }
Ejemplo n.º 2
0
        public void FillBudget()
        {
            DateTime beginSeason = (Session.Instance.Game.date.Month <= 6 || (Session.Instance.Game.date.Month == 6 && Session.Instance.Game.date.Day < 15)) ? new DateTime(Session.Instance.Game.date.Year - 1, 6, 15) : new DateTime(Session.Instance.Game.date.Year, 6, 15);
            CityClub cc          = _club as CityClub;

            if (cc != null)
            {
                Dictionary <BudgetModificationReason, double> depenses = new Dictionary <BudgetModificationReason, double>();
                Dictionary <BudgetModificationReason, double> incomes  = new Dictionary <BudgetModificationReason, double>();

                foreach (BudgetEntry be in cc.budgetHistory)
                {
                    StackPanel spEntry = new StackPanel();
                    spEntry.Orientation = Orientation.Horizontal;
                    spEntry.Children.Add(ViewUtils.CreateLabel(be.Date.ToShortDateString(), "StyleLabel2", 12, 90));
                    spEntry.Children.Add(ViewUtils.CreateLabel(Utils.FormatMoney(be.Amount), "StyleLabel2", 12, 100, be.Amount < 0 ? Brushes.Red : null));
                    spEntry.Children.Add(ViewUtils.CreateLabel(Utils.GetDescription(be.Reason), "StyleLabel2", 12, 125));
                    spBudget.Children.Add(spEntry);

                    if (Utils.IsBefore(beginSeason, be.Date))
                    {
                        AddValueToDictionnary(be.Amount < 0 ? depenses : incomes, be.Reason, be.Amount);
                    }
                }

                CreatePieChart(depenses);
                CreatePieChart(incomes);
            }
        }
Ejemplo n.º 3
0
        private void RefreshTransferListPanel()
        {
            spTransferList.Children.Clear();
            foreach (Club c in Session.Instance.Game.club.Championship.rounds[0].clubs)
            {
                CityClub cc = c as CityClub;
                if (cc != null)
                {
                    foreach (ContractOffer co in cc.clubTransfersManagement.offersHistory)
                    {
                        StackPanel spT = new StackPanel();
                        spT.Orientation = Orientation.Horizontal;
                        Label lbPlayer = ViewUtils.CreateLabel(co.Player.lastName, "StyleLabel2", 8, 40);
                        lbPlayer.MouseLeftButtonUp += (object sender, System.Windows.Input.MouseButtonEventArgs e) =>
                        { Windows_Joueur wj = new Windows_Joueur(co.Player); wj.Show(); };
                        spT.Children.Add(lbPlayer);
                        string from = "Libre";
                        if (co.Origin != null)
                        {
                            from = co.Origin.shortName;
                        }
                        spT.Children.Add(ViewUtils.CreateLabel(from, "StyleLabel2", 8, 55));
                        Label labelClub = ViewUtils.CreateLabel(cc.shortName, "StyleLabel2", 8, 55);
                        labelClub.MouseLeftButtonUp += (object sender, System.Windows.Input.MouseButtonEventArgs e) =>
                        { Windows_Club wc = new Windows_Club(cc); wc.Show(); };
                        spT.Children.Add(labelClub);
                        spT.Children.Add(ViewUtils.CreateLabel(co.TransferIndemnity + "€", "StyleLabel2", 8, 60));


                        spT.Children.Add(ViewUtils.CreateLabel(co.Result.ToString(), "StyleLabel2", 8, 60));
                        spTransferList.Children.Add(spT);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public override void QualifyClubs()
        {
            List <Club> ranking = Ranking();
            //Simuler des gains d'argent de matchs pour les clubs (affluence)

            DateTime fin = DateEndRound();
            DateTime dateInitialisationRound = DateInitialisationRound();

            if (fin.Month < dateInitialisationRound.Month)
            {
                fin = fin.AddYears(1);
            }
            else if (fin.Month == dateInitialisationRound.Month && fin.Day < dateInitialisationRound.Day)
            {
                fin = fin.AddYears(1);
            }
            int matchesCount = (int)((fin - dateInitialisationRound).TotalDays) / 14;

            foreach (Club c in ranking)
            {
                CityClub cv = c as CityClub;
                if (cv != null)
                {
                    cv.ModifyBudget(matchesCount * cv.supporters * cv.ticketPrice, BudgetModificationReason.TournamentGrant);
                }
            }

            List <Qualification> adjustedQualifications = new List <Qualification>(_qualifications);

            adjustedQualifications.Sort(new QualificationComparator());

            if (_rules.Contains(Rule.ReservesAreNotPromoted))
            {
                adjustedQualifications = Utils.AdjustQualificationsToNotPromoteReserves(_qualifications, ranking, Tournament);
            }

            foreach (Qualification q in adjustedQualifications)
            {
                Club c = ranking[q.ranking - 1];
                if (!q.isNextYear)
                {
                    q.tournament.rounds[q.roundId].clubs.Add(c);
                }
                else
                {
                    q.tournament.AddClubForNextYear(c, q.roundId);
                }
                if (q.tournament.isChampionship && c.Championship != null)
                {
                    if (q.tournament.level > c.Championship.level)
                    {
                        c.supporters = (int)(c.supporters * 1.4f);
                    }
                    else if (q.tournament.level < c.Championship.level)
                    {
                        c.supporters = (int)(c.supporters / 1.4f);
                    }
                }
            }
        }
Ejemplo n.º 5
0
 public PlayerHistory(int level, int year, int goals, int playedGames, CityClub club)
 {
     Level       = level;
     Year        = year;
     Goals       = goals;
     GamesPlayed = playedGames;
     Club        = club;
 }
Ejemplo n.º 6
0
 public ContractOffer(Player player, int wage, int contractDuration, int transferIndemnity, CityClub origin)
 {
     Player            = player;
     Wage              = wage;
     ContractDuration  = contractDuration;
     TransferIndemnity = transferIndemnity;
     Result            = ContractOfferResult.Waiting;
     Origin            = origin;
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Get the potential of attendance for a club in function of its level, the size of the city and its championship
        /// </summary>
        /// <param name="club"></param>
        /// <returns></returns>
        public int GetPotentialSupporters(CityClub club, int tournamentLevel)
        {
            int   cityPopulation = club.city.Population;
            float clubLevel      = club.Level();

            double lowerSigmoid      = 1 / (1 + Math.Exp(-0.0002 * (cityPopulation - 17500)));
            double upperSigmoid      = 1 - (1 / (1 + Math.Exp(-0.00000205 * (cityPopulation - 1900000))));
            double populationDivider = upperSigmoid * lowerSigmoid * (7 + (1 * Math.Pow(1.7, 0.000004 * cityPopulation)));

            return((int)((cityPopulation / populationDivider) / tournamentLevel * (clubLevel / 70)));
        }
Ejemplo n.º 8
0
        public override void DistributeGrants()
        {
            List <Club> ranking = new List <Club>(_clubs);

            ranking.Sort(new ClubRankingComparator(this.matches));
            foreach (Prize d in _prizes)
            {
                CityClub cc = ranking[d.Ranking - 1] as CityClub;
                if (cc != null)
                {
                    cc.ModifyBudget(d.Amount, BudgetModificationReason.TournamentGrant);
                }
            }
        }
Ejemplo n.º 9
0
        public override void DistributeGrants()
        {
            List <Match> matches;

            if (twoLegs)
            {
                matches = new List <Match>(_matches);
            }
            else
            {
                matches = new List <Match>();
                int nbMatches = _matches.Count;
                for (int i = 0; i < nbMatches; i++)
                {
                    matches.Add(_matches[i]);
                }
            }
            foreach (Prize d in _prizes)
            {
                if (d.Ranking == 1)
                {
                    foreach (Match m in matches)
                    {
                        CityClub cv = m.Winner as CityClub;
                        if (cv != null)
                        {
                            cv.ModifyBudget(d.Amount, BudgetModificationReason.TournamentGrant);
                        }
                    }
                }
                if (d.Ranking == 2)
                {
                    foreach (Match m in matches)
                    {
                        CityClub cv = m.Looser as CityClub;
                        if (cv != null)
                        {
                            cv.ModifyBudget(d.Amount, BudgetModificationReason.TournamentGrant);
                        }
                    }
                }
            }
        }
Ejemplo n.º 10
0
        public int Compare(Match x, Match y)
        {
            int res  = 1;
            int diff = DateTime.Compare(x.day, y.day);

            if (diff < 0)
            {
                res = -1;
            }
            else if (diff == 0)
            {
                int      X    = 0;
                int      Y    = 0;
                CityClub home = x.home as CityClub;
                CityClub away = x.away as CityClub;
                if (home != null && home.Championship != null)
                {
                    X += (int)Math.Pow(2, 10 - home.Championship.level);
                }

                if (away != null && away.Championship != null)
                {
                    X += (int)Math.Pow(2, 10 - away.Championship.level);
                }
                home = y.home as CityClub;
                away = y.away as CityClub;
                if (home != null && home.Championship != null)
                {
                    Y += (int)Math.Pow(2, 10 - home.Championship.level);
                }

                if (away != null && away.Championship != null)
                {
                    Y += (int)Math.Pow(2, 10 - away.Championship.level);
                }
                if (X > Y)
                {
                    res = -1;
                }
            }
            return(res);
        }
Ejemplo n.º 11
0
        public static void ExporterClubs()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<p>Clubs</p>");

            foreach (Club c in Session.Instance.Game.kernel.Clubs)
            {
                CityClub cv = c as CityClub;
                if (cv != null)
                {
                    sb.Append("<h2>").Append(cv.name).Append("</h2>");
                    foreach (HistoricEntry eh in cv.history.elements)
                    {
                        sb.Append("<p><b>").Append(eh.date.ToShortDateString()).Append("</b><br>Budget : ")
                        .Append(eh.budget).Append("<br>Centre de formation : ").Append(eh.formationFacilities)
                        .Append("</p>");
                    }
                }
            }
            File.WriteAllText("Output\\Clubs.html", sb.ToString());
        }
Ejemplo n.º 12
0
        public override void Initialise()
        {
            if (!Tournament.IsInternational())
            {
                AddTeamsToRecover();

                if (this.Tournament.isChampionship)
                {
                    foreach (Club c in clubs)
                    {
                        CityClub cc = c as CityClub;
                        if (cc != null)
                        {
                            int potentialSupporters = GetPotentialSupporters(cc, Tournament.level);
                            if (cc.baseCityAttendanceMultiplier == 0)
                            {
                                float cityAttendanceMultiplier = 1;
                                if (cc.supporters > 0)
                                {
                                    cityAttendanceMultiplier = cc.supporters / (potentialSupporters + 0.0f);
                                }
                                cc.baseCityAttendanceMultiplier = cityAttendanceMultiplier;
                            }
                            c.supporters += (int)(((potentialSupporters - c.supporters) * (Session.Instance.Random(5, 12) / 100.0f)) * cc.baseCityAttendanceMultiplier);
                        }
                    }
                }
            }
            //If it's an international tournament (national teams or continental cup eg), we add all teams to recover for all rounds now because ranking can fluctuate after and the same team could be selected for 2 differents rounds
            else if (Tournament.rounds[0] == this)
            {
                foreach (Round r in Tournament.rounds)
                {
                    r.AddTeamsToRecover();
                }
            }
            _matches = Calendar.GenerateCalendar(this.clubs, this, twoLegs);
        }
Ejemplo n.º 13
0
 public void Palmares(CityClub club)
 {
     foreach (Tournament c in Session.Instance.Game.kernel.Competitions)
     {
         int    nombre = 0;
         string annees = "";
         foreach (KeyValuePair <int, Tournament> archive in c.previousEditions)
         {
             if (archive.Value.isChampionship)
             {
                 if (archive.Value.rounds[0].Winner() == club)
                 {
                     nombre++;
                 }
             }
             else
             {
                 Round t = archive.Value.rounds[archive.Value.rounds.Count - 1];
                 if (t.Winner() == club)
                 {
                     nombre++;
                 }
             }
         }
         if (nombre > 0)
         {
             StackPanel spPalmaresEntry = new StackPanel()
             {
                 Orientation = Orientation.Horizontal
             };
             spPalmaresEntry.Children.Add(ViewUtils.CreateLabel(c.name, "StyleLabel2", 12, 175));
             spPalmaresEntry.Children.Add(ViewUtils.CreateLabel(nombre.ToString(), "StyleLabel2", 12, 75));
             spPalmares.Children.Add(spPalmaresEntry);
         }
     }
 }
Ejemplo n.º 14
0
        private void SelectedSponsors(object sender, RoutedEventArgs e)
        {
            spRanking.Children.Clear();
            List <Club> clubs = new List <Club>(_competition.rounds[_indexTour].clubs);

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

            foreach (Club c in clubs)
            {
                CityClub cc = c as CityClub;
                if (cc != 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(cc.sponsor), "StyleLabel2", 12, 100));
                    spRanking.Children.Add(sp);
                }
            }
        }
Ejemplo n.º 15
0
        public Windows_Club(CityClub c)
        {
            InitializeComponent();

            imgBudget.Source        = new BitmapImage(new Uri(System.IO.Directory.GetCurrentDirectory() + "\\" + Utils.imagesFolderName + "\\budget.png"));
            imgCurrentBudget.Source = new BitmapImage(new Uri(System.IO.Directory.GetCurrentDirectory() + "\\" + Utils.imagesFolderName + "\\budget.png"));
            imgBtnQuitter.Source    = new BitmapImage(new Uri(System.IO.Directory.GetCurrentDirectory() + "\\" + Utils.imagesFolderName + "\\return.png"));
            imgManager.Source       = new BitmapImage(new Uri(System.IO.Directory.GetCurrentDirectory() + "\\" + Utils.imagesFolderName + "\\manager.png"));

            _club          = c;
            lbClub.Content = c.name;

            if (c.manager != null)
            {
                lbEntraineur.Content = c.manager.ToString();
            }
            else
            {
                lbEntraineur.Content = FindResource("str_noManager").ToString();
            }

            lbBudget.Content        = Utils.FormatMoney(c.budget);
            lbCurrentBudget.Content = Utils.FormatMoney(c.budget);

            try
            {
                imgLogo.Source = new BitmapImage(new Uri(Utils.Logo(c)));
            }
            catch (Exception e)
            {
                Utils.Debug(e.ToString());
            }
            Palmares(c);
            FillGames();
            FillBudget();



            List <Player> newContracts = new List <Player>();

            foreach (Contract ct in c.allContracts)
            {
                if ((ct.beginning.Year == Session.Instance.Game.date.Year - 1 && ct.beginning.Month < 7) ||
                    (ct.beginning.Year == Session.Instance.Game.date.Year && ct.beginning.Month >= 7))
                {
                    newContracts.Add(ct.player);
                }
            }

            /*TODO
             * ViewPlayers viewNewPlayers = new ViewPlayers(newContracts, 11, false, false, false, true, false, false, false, false, false, true, false, false, false, false, false, false, false);
             * viewNewPlayers.Full(spArrivees);
             */
            ViewPlayers viewPlayers = new ViewPlayers(c.Players(), 12, true, true, true, true, true, false, false, true, false, true, false, false, false, false, false, true, true, true);

            viewPlayers.Full(spPlayers);

            List <HistoriqueClubElement> lhce = new List <HistoriqueClubElement>();

            foreach (Tournament competition in Session.Instance.Game.kernel.Competitions)
            {
                foreach (KeyValuePair <int, Tournament> ancienne in competition.previousEditions)
                {
                    if (ancienne.Value.isChampionship && ancienne.Value.rounds[0].clubs.Contains(c))
                    {
                        int classement = 0;
                        //Si la compétition était active (tour 0 un tour de type championnat, pas inactif)
                        if ((ancienne.Value.rounds[0] as ChampionshipRound) != null)
                        {
                            classement = (ancienne.Value.rounds[0] as ChampionshipRound).Ranking().IndexOf(c) + 1;
                        }
                        else if ((ancienne.Value.rounds[0] as GroupsRound) != null)
                        {
                            GroupsRound rnd = (ancienne.Value.rounds[0] as GroupsRound);
                            for (int j = 0; j < rnd.groupsCount; j++)
                            {
                                if (rnd.groups[j].Contains(c))
                                {
                                    classement = rnd.Ranking(j).IndexOf(c);
                                }
                            }
                        }
                        lhce.Add(new HistoriqueClubElement {
                            Competition = ancienne.Value, Classement = classement, Annee = ancienne.Key
                        });
                    }
                }
            }
            lhce.Sort(new HistoriqueClubComparator());
            foreach (HistoriqueClubElement hce in lhce)
            {
                StackPanel spHistoryEntry = new StackPanel();
                spHistoryEntry.Orientation = Orientation.Horizontal;
                spHistoryEntry.Children.Add(ViewUtils.CreateLabelOpenWindow <Tournament>(hce.Competition, OpenTournament, hce.Annee.ToString(), "StyleLabel2", 11, 75));
                spHistoryEntry.Children.Add(ViewUtils.CreateLabelOpenWindow <Tournament>(hce.Competition, OpenTournament, hce.Competition.name, "StyleLabel2", 11, 125));
                spHistoryEntry.Children.Add(ViewUtils.CreateLabel(hce.Classement.ToString(), "StyleLabel2", 11, 50));
                spHistory.Children.Add(spHistoryEntry);
            }


            ChartValues <int> budgets         = new ChartValues <int>();
            ChartValues <int> centreFormation = new ChartValues <int>();
            ChartValues <int> attendance      = new ChartValues <int>();

            foreach (HistoricEntry eh in c.history.elements)
            {
                budgets.Add(eh.budget);
                centreFormation.Add(eh.formationFacilities);
                attendance.Add(eh.averageAttendance);
            }

            BudgetsCollection = new SeriesCollection
            {
                new LineSeries
                {
                    Title  = FindResource("str_budget").ToString(),
                    Values = budgets,
                }
            };

            //Formation facilities

            CFCollection = new SeriesCollection
            {
                new LineSeries
                {
                    Title  = FindResource("str_level").ToString(),
                    Values = centreFormation,
                }
            };

            //Average attendance

            AttendanceCollection = new SeriesCollection
            {
                new LineSeries
                {
                    Title  = FindResource("str_averageAttendance").ToString(),
                    Values = attendance,
                }
            };

            LabelsAnnees = new string[c.history.elements.Count];
            int i = 0;

            foreach (HistoricEntry eh in c.history.elements)
            {
                LabelsAnnees[i] = c.history.elements[i].date.Year.ToString();
                i++;
            }
            YFormatter = value => value.ToString("C");

            DataContext = this;

            if (c.records.BiggestWin != null)
            {
                lbBiggestWin.Content = c.records.BiggestWin.home.name + " " + c.records.BiggestWin.score1 + " - " + c.records.BiggestWin.score2 + " " + c.records.BiggestWin.away.name;
            }
            if (c.records.BiggestLose != null)
            {
                lbBiggestLose.Content = c.records.BiggestLose.home.name + " " + c.records.BiggestLose.score1 + " - " + c.records.BiggestLose.score2 + " " + c.records.BiggestLose.away.name;
            }
        }
Ejemplo n.º 16
0
        private void Map(Round t)
        {
            AxMapWinGIS.AxMap map = new AxMapWinGIS.AxMap();
            map.Width  = 380;
            map.Height = 380;
            host.Child = map;
            map.Show();
            map.CreateControl();
            map.ShowZoomBar     = false;
            map.ShowCoordinates = MapWinGIS.tkCoordinatesDisplay.cdmNone;
            map.CursorMode      = MapWinGIS.tkCursorMode.cmNone;

            MapWinGIS.Shapefile shapeFileMap = new MapWinGIS.Shapefile();
            shapeFileMap.Open(@"D:\Projets\TheManager\TheManager_GUI\bin\Debug\gis\world\World_Countries.shp", null);
            map.AddLayer(shapeFileMap, true);
            ILocalisation localisation = Session.Instance.Game.kernel.LocalisationTournament(t.Tournament);
            double        logoSize     = 30.0;

            if (localisation as Country != null)
            {
                map.ZoomToShape(0, (localisation as Country).ShapeNumber);
            }
            else
            {
                if (localisation.Name() == "Europe")
                {
                    map.ZoomToShape(0, 68 /*12 101*/);
                    map.CurrentZoom = 4;
                }
                else if (localisation.Name() == "Africa")
                {
                    map.ZoomToShape(0, 40);
                    map.CurrentZoom = 3;
                }
                logoSize = 15.0;
            }

            foreach (Club c in t.clubs)
            {
                CityClub cc = c as CityClub;
                if (cc != null)
                {
                    double projX = -1;
                    double projY = -1;
                    map.DegreesToProj(cc.city.Position.Longitude, cc.city.Position.Latitude, ref projX, ref projY);

                    MapWinGIS.Image img = new MapWinGIS.Image();
                    img.Open(Utils.Logo(c));

                    MapWinGIS.Shapefile sf = new MapWinGIS.Shapefile();
                    sf.CreateNew("", MapWinGIS.ShpfileType.SHP_POINT);
                    sf.DefaultDrawingOptions.AlignPictureByBottom = false;
                    sf.DefaultDrawingOptions.PointType            = MapWinGIS.tkPointSymbolType.ptSymbolPicture;
                    sf.DefaultDrawingOptions.Picture       = img;
                    sf.DefaultDrawingOptions.PictureScaleX = Math.Round(logoSize / img.OriginalWidth, 2);
                    sf.DefaultDrawingOptions.PictureScaleY = Math.Round(logoSize / img.OriginalHeight, 2);
                    sf.CollisionMode = MapWinGIS.tkCollisionMode.AllowCollisions;

                    MapWinGIS.Shape shp = new MapWinGIS.Shape();
                    shp.Create(MapWinGIS.ShpfileType.SHP_POINT);
                    shp.AddPoint(projX, projY);
                    sf.EditAddShape(shp);

                    map.AddLayer(sf, true);
                }
            }
            if (_competition.rounds[_indexTour].clubs.Count > 0 && _competition.rounds[_indexTour].clubs[0] as NationalTeam != null)
            {
                shapeFileMap.StartEditingTable();
                int fieldIndex = shapeFileMap.EditAddField("Qualification", MapWinGIS.FieldType.INTEGER_FIELD, 1, 1);
                shapeFileMap.DefaultDrawingOptions.FillType = MapWinGIS.tkFillType.ftStandard;
                for (int i = 0; i < shapeFileMap.NumShapes; i++)
                {
                    shapeFileMap.EditCellValue(fieldIndex, i, 0);
                }
                Dictionary <NationalTeam, int> clubCourses = new Dictionary <NationalTeam, int>();
                for (int i = 0; i < _competition.rounds.Count; i++)
                {
                    Round round = _competition.rounds[i];
                    foreach (Club c in round.clubs)
                    {
                        NationalTeam nt = c as NationalTeam;
                        if (!clubCourses.ContainsKey(nt))
                        {
                            clubCourses.Add(nt, 1);
                        }
                        clubCourses[nt] = i + 1;
                    }
                }
                foreach (KeyValuePair <NationalTeam, int> kvp in clubCourses)
                {
                    shapeFileMap.EditCellValue(fieldIndex, kvp.Key.country.ShapeNumber, kvp.Value);
                }
                shapeFileMap.Categories.Generate(fieldIndex, MapWinGIS.tkClassificationType.ctUniqueValues, _competition.rounds.Count + 1);
                shapeFileMap.Categories.ApplyExpressions();
                MapWinGIS.ColorScheme colorScheme = new MapWinGIS.ColorScheme();
                colorScheme.SetColors2(MapWinGIS.tkMapColor.AliceBlue, MapWinGIS.tkMapColor.DarkBlue);
                shapeFileMap.Categories.ApplyColorScheme(MapWinGIS.tkColorSchemeType.ctSchemeGraduated, colorScheme);
            }
            map.Redraw();
        }
Ejemplo n.º 17
0
 public Transfer(CityClub from, CityClub to, DateTime date)
 {
     _from = from;
     _to   = to;
     _date = date;
 }
Ejemplo n.º 18
0
        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());
            }
        }