示例#1
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            CompetitionPlayerList new_list  = new CompetitionPlayerList();
            List <int>            to_delete = new List <int>();

            // 1 - создаем текущий список игроков турнира
            foreach (PlayerInfo player in lstPlayers.CheckedObjects)
            {
                CompetitionPlayerInfo cp = new CompetitionPlayerInfo(player);
                new_list.Add(cp.Id, cp);
            }
            // 2 - добавляем тех, кто есть в текущем, но отсутсвует в исходном
            foreach (CompetitionPlayerInfo player in new_list.Values)
            {
                if (!SelectedPlayers.ContainsKey(player.Id))
                {
                    SelectedPlayers.Add(player.Id, player);
                }
            }
            // 3 - формируем список тех, кто есть в исходном списке, но кого нет в текущем списке
            foreach (CompetitionPlayerInfo player in SelectedPlayers.Values)
            {
                if (!new_list.ContainsKey(player.Id))
                {
                    to_delete.Add(player.Id);
                }
            }
            // 4 - удаляем из исходного списка тех, кого нет в текущем
            foreach (int id in to_delete)
            {
                SelectedPlayers.Remove(id);
            }
            DialogResult = DialogResult.OK;
        }
示例#2
0
        public void FillDummy(int playerCount, int seedCount, SeedType type, int aParam)
        {
            List <CompetitionPlayerInfo> players = new List <CompetitionPlayerInfo>();
            Random rnd = new Random();

            for (int i = 0; i < playerCount; i++)
            {
                CompetitionPlayerInfo player = new CompetitionPlayerInfo();
                player.Id       = i + 1;
                player.NickName = "Player " + (i + 1).ToString("d2");
                player.RatingBeforeCompetition = 1500 + rnd.Next(-100, 100);
                players.Add(player);
            }
            SetPlayersList(players.ToArray());
            int[] seed = new int[seedCount];
            for (int i = 0; i < seed.Length; i++)
            {
                if (i % 2 == 0)
                {
                    seed[i] = i / 2 + 1;
                }
                else
                {
                    seed[i] = (seed.Length + 1 + i) / 2;
                }
            }
            SetSeedingOrder(seed, type, aParam);
        }
示例#3
0
        public static int Edit(CompetitionPlayerInfo info, bool setStartPoints)
        {
            fRebuy form = new fRebuy();

            form.txtFullName.Text        = info.FullName;
            form.txtStartPoints.Text     = info.StartPoints.ToString();
            form.txtPoints.Text          = info.Points.ToString();
            form.txtRebuyPoints.Text     = info.RebuyPoints.ToString();
            form.txtAvailablePoints.Text = info.AvailablePoints.ToString();
            form.txtNowAvailable.Text    = info.AvailablePoints.ToString();
            form.txtAddPoints.Text       = "0";
            form.SetEnabled(setStartPoints);
            if (form.ShowDialog() == DialogResult.OK)
            {
                if (setStartPoints)
                {
                    if (form.txtStartPoints.Text == "")
                    {
                        form.txtStartPoints.Text = "0";
                    }
                    return(Convert.ToInt32(form.txtStartPoints.Text));
                }
                else
                {
                    if (form.txtAddPoints.Text == "")
                    {
                        form.txtAddPoints.Text = "0";
                    }
                    return(Convert.ToInt32(form.txtAddPoints.Text));
                }
            }
            return(0);
        }
示例#4
0
 public override void UpdatePlayerInfo(CompetitionPlayerInfo player_info, PlayerResults player_results, int place)
 {
     player_info.Points       = player_results.Points;
     player_info.Tag          = (player_results as PlayerSwissResults).GetBK();
     player_info.Place        = place.ToString("D2");
     player_info.CurrentPlace = place;
 }
示例#5
0
        private void btnRebuy_Click(object sender, EventArgs e)
        {
            CompetitionPlayerInfo player = lvPlayers.SelectedObject as CompetitionPlayerInfo;

            if (player != null)
            {
                player.RebuyPoints += fRebuy.Edit(player, false);
                TA.DB.Manager.DatabaseManager.CurrentDb.CompetitionPlayerInfoSave(player);
                lvPlayers.Invalidate();
            }
        }
示例#6
0
        private void DoOnSelectPlayer(PlayerInfo player)
        {
            if (player == null)
            {
                return;
            }
            CompetitionPlayerInfo cp = new CompetitionPlayerInfo(player);

            cp.CompetitionId = FCompetition.Info.Id;
            DatabaseManager.CurrentDb.CompetitionPlayerInfoSave(cp);
        }
示例#7
0
        /// <summary>
        /// возвращает список ироков для рассеивания
        /// </summary>
        /// <returns>List<CompetitionPlayerInfo> - список игроков для рассеивания</returns>
        protected virtual List <CompetitionPlayerInfo> GetPlayersToSeed()
        {
            List <CompetitionPlayerInfo> players = null;

            if (Competition.Matches.Count == 0)
            {   //Если еще не было матчей, то получаем список игроков по жеребъевке
                List <CompetitionPlayerInfo> players_by_seedno = Competition.Players.GetSortedList(CompetitionPlayerList.SortByField.SeedNo);
                // Получаем порядок формирования пар
                int[] sort_order = GetDrawOrder(players_by_seedno.Count);
                // Создаем пустой список, куда будут добавлены игроки для формирования пар по порядку жребия
                CompetitionPlayerInfo[] players_pairs = new CompetitionPlayerInfo[sort_order.Length];
                for (int i = 0; i < players_pairs.Length; i++)
                {
                    players_pairs[i] = CompetitionPlayerInfo.Dummy;
                }
                foreach (CompetitionPlayerInfo player in players_by_seedno)
                {
                    for (int i = 0; i < sort_order.Length; i++)
                    {
                        if (sort_order[i] == player.SeedNo)
                        {
                            players_pairs[i] = player;
                        }
                    }
                }
                players = new List <CompetitionPlayerInfo>();
                players.AddRange(players_pairs);

                /*
                 * for (int i = 0; i < players_by_seedno.Count; i++)
                 * {
                 *  players.Add(players_by_seedno[sort_order[i] - 1]);
                 * }*/
            }
            else
            {   // если матчи уже были, то получаем список игроков по результатам
                players = Competition.PlayersResults;
            }

            // тут добавим бая
            if (players.Count % 2 != 0)
            {
                players.Add(CompetitionPlayerInfo.Dummy);
            }
            return(players);
        }
 private void grdDest_OnDrawItem(object Sender, WindowSkin.ObjectListItemArgs args)
 {
     if (args.Item is CompetitionPlayerInfo)
     {
         Rectangle rect = args.Bounds;
         rect.Width = 20;
         CompetitionPlayerInfo player = args.Item as CompetitionPlayerInfo;
         args.Graphics.DrawString(player.SeedNo.ToString(), Font, args.TextBrush, rect, args.StringFormat);
         rect = args.Bounds;
         rect.Offset(20, 0);
         rect.Width -= 20;
         args.Graphics.DrawString(player.ToString(), Font, args.TextBrush, rect, args.StringFormat);
     }
     else
     {
         args.Graphics.DrawString(args.Item.ToString(), Font, args.TextBrush, args.Bounds, args.StringFormat);
     }
 }
示例#9
0
        public virtual bool Open(string pathToXml)
        {
            try
            {
                XmlTextReader reader = new XmlTextReader(pathToXml);
                while (reader.Read())
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:        // Узел является элементом.
                        if (reader.Name == "CM_XML")
                        {
                            FDate    = DateTime.ParseExact(reader.GetAttribute("date"), "yyyyMMdd", CultureInfo.InvariantCulture);
                            FAppGuid = new Guid(reader.GetAttribute("app_guid"));
                        }
                        if (reader.Name == "MEMBERS")
                        {
                            FPlayers.Clear();
                        }
                        if (reader.Name == "MEMBER")
                        {
                            PlayerInfo player = new PlayerInfo();
                            player.Identifier     = new Guid(reader.GetAttribute("GUID"));
                            player.NickName       = reader.GetAttribute("nick");
                            player.LastName       = reader.GetAttribute("lname");
                            player.FirstName      = reader.GetAttribute("fname");
                            player.PatronymicName = reader.GetAttribute("pname");
                            player.Country        = reader.GetAttribute("country");
                            player.City           = reader.GetAttribute("city");
                            player.Phone          = reader.GetAttribute("phones");
                            player.EMail          = reader.GetAttribute("email");

                            // в trial версии можно экспортировать за раз не более 10 игроков
                            if (EditionManager.Edition != EditionType.Mini)
                            {
                                if (!EditionManager.IsTrial || FPlayers.Count < 10)     // в trial версии можно экспортировать за раз не более 10 игроков
                                {
                                    FPlayers.Add(player);
                                }
                            }
                        }
                        if (reader.Name == "RATINGS")
                        {
                            // Начинаем экспортирование рейтингов
                            FRatings.Clear();
                        }
                        if (reader.Name == "RATING")
                        {
                            rating_node           = new XmlExporter.RatingNode();
                            rating_node.Game      = new TypeOfSport();
                            rating_node.Game.Id   = Convert.ToInt32(reader.GetAttribute("id"));
                            rating_node.Game.Name = reader.GetAttribute("name");
                            // в trial версии можно экспортировать за раз не более 1 рейтинга
                            if (EditionManager.Edition != EditionType.Mini)
                            {
                                if (!EditionManager.IsTrial || FRatings.Count < 1)
                                {
                                    FRatings.Add(rating_node.Game, rating_node);
                                }
                            }
                        }
                        if (reader.Name == "PLAYER_RATING")
                        {
                            if (EditionManager.Edition != EditionType.Mini)
                            {
                                if (rating_node == null)
                                {
                                    throw new Exception("Не задан рейтинговый лист");
                                }
                                PlayerRating rating = new PlayerRating();
                                string       date   = reader.GetAttribute("date");
                                if (date != "")
                                {
                                    rating.LastRatingDate = DateTime.ParseExact(date, "yyyyMMdd", CultureInfo.InvariantCulture);
                                }
                                rating.Guid        = new Guid(reader.GetAttribute("guid"));
                                rating.RatingBegin = Convert.ToInt32(reader.GetAttribute("start"));
                                rating.Rating      = Convert.ToInt32(reader.GetAttribute("current"));
                                rating.Name        = reader.GetAttribute("name");
                                rating_node.Ratings.Add(rating);
                            }
                        }
                        if (reader.Name == "TOURNAMENTS")
                        {
                            FTournaments.Clear();
                        }
                        if (reader.Name == "TOURNAMENT")
                        {
                            tournament = new Tournament();
                            tournament.Info.DateBegin = DateTime.ParseExact(reader.GetAttribute("begin"), "yyyyMMdd", CultureInfo.InvariantCulture);
                            tournament.Info.DateEnd   = DateTime.ParseExact(reader.GetAttribute("end"), "yyyyMMdd", CultureInfo.InvariantCulture);
                            tournament.Info.Name      = reader.GetAttribute("name");
                            tournament.Info.Place     = reader.GetAttribute("place");

                            if (EditionManager.Edition != EditionType.Mini && EditionManager.Edition != EditionType.Standard)
                            {
                                if (!EditionManager.IsTrial || FTournaments.Count < 1)     // в trial версии можно экспортировать за раз не более 1 турнира
                                {
                                    FTournaments.Add(tournament);
                                }
                            }
                        }
                        if (reader.Name == "COMPETITIONS")
                        {
                            if (tournament == null)
                            {
                                throw new Exception("Tournamet is not initialized");
                            }
                            tournament.Competitions.Clear();
                        }
                        if (reader.Name == "COMPETITION")
                        {
                            TA.Corel.CompetitionInfo ci = new TA.Corel.CompetitionInfo();
                            ci.ChangesRating        = Convert.ToBoolean(reader.GetAttribute("rating"));
                            ci.CompetitionType.Id   = Convert.ToInt32(reader.GetAttribute("type"));
                            ci.CompetitionType.Name = reader.GetAttribute("type_name");
                            ci.Date         = DateTime.ParseExact(reader.GetAttribute("date"), "yyyyMMdd", CultureInfo.InvariantCulture);
                            ci.Name         = reader.GetAttribute("name");
                            ci.SportType.Id = Convert.ToInt32(reader.GetAttribute("sport"));
                            ci.Status       = (TA.Corel.CompetitionInfo.CompetitionState)(Enum.Parse(typeof(TA.Corel.CompetitionInfo.CompetitionState), reader.GetAttribute("status")));
                            competition     = TA.Competitions.CompetitionFactory.CreateCompetition(ci);
                            // в trial версии можно экспортировать за раз не более 1 соревнования
                            if (!EditionManager.IsTrial || tournament.Competitions.Count < 1)
                            {
                                tournament.Competitions.Add(tournament.Competitions.Count + 1, competition);
                            }
                        }
                        if (reader.Name == "PARAMS")
                        {
                            if (competition == null)
                            {
                                throw new Exception("Competition is not initialized");
                            }
                            competition.Info.Properties.Clear();
                        }
                        if (reader.Name == "PARAM")
                        {
                            if (competition == null)
                            {
                                throw new Exception("Competition is not initialized");
                            }
                            competition.Info.Properties.Add(reader.GetAttribute("name"), reader.GetAttribute("value"));
                        }
                        if (reader.Name == "PLAYERS")
                        {
                            if (competition == null)
                            {
                                throw new Exception("Competition is not initialized");
                            }
                            competition.Players.Clear();
                        }
                        if (reader.Name == "PLAYER")
                        {
                            if (competition == null)
                            {
                                throw new Exception("Competition is not initialized");
                            }
                            CompetitionPlayerInfo pi = new CompetitionPlayerInfo();
                            pi.Identifier = new Guid(reader.GetAttribute("guid"));
                            pi.Place      = new TA.Utils.StringAlt(reader.GetAttribute("place"));
                            pi.RatingBeforeCompetition = Convert.ToInt32(reader.GetAttribute("rating"));
                            pi.SeedNo      = Convert.ToInt32(reader.GetAttribute("seed"));
                            pi.StartPoints = Convert.ToInt32(reader.GetAttribute("start_points"));
                            pi.RebuyPoints = Convert.ToInt32(reader.GetAttribute("rebuy_points"));
                            competition.Players.Add(competition.Players.Count + 1, pi);
                        }

                        if (reader.Name == "MATCHES")
                        {
                            if (competition == null)
                            {
                                throw new Exception("Competition is not initialized");
                            }
                            competition.Matches.Clear();
                        }
                        if (reader.Name == "MATCH")
                        {
                            if (competition == null)
                            {
                                throw new Exception("Competition is not initialized");
                            }
                            match             = new MatchInfo();
                            match.Label.Label = reader.GetAttribute("label");
                            match.Loosers_MatchLabel.Label = reader.GetAttribute("looser_label");
                            match.Winners_MatchLabel.Label = reader.GetAttribute("winner_label");
                            match.Winner = (MatchLabel.PlayerLetters)Enum.Parse(typeof(MatchLabel.PlayerLetters), reader.GetAttribute("winner"));
                            competition.Matches.Add(competition.Matches.Count + 1, match);
                        }
                        if (reader.Name == "PLAYER_A")
                        {
                            if (match == null)
                            {
                                throw new Exception("Match is not initialized");
                            }
                            match.PlayerA.Id     = Convert.ToInt32(reader.GetAttribute("id"));
                            match.PlayerA.Guid   = new Guid(reader.GetAttribute("guid"));
                            match.PlayerA.Points = Convert.ToInt32(reader.GetAttribute("points"));
                            match.PlayerA.Tag    = Convert.ToInt32(reader.GetAttribute("tag"));
                        }
                        if (reader.Name == "PLAYER_B")
                        {
                            if (match == null)
                            {
                                throw new Exception("Match is not initialized");
                            }
                            match.PlayerB.Id     = Convert.ToInt32(reader.GetAttribute("id"));
                            match.PlayerB.Guid   = new Guid(reader.GetAttribute("guid"));
                            match.PlayerB.Points = Convert.ToInt32(reader.GetAttribute("points"));
                            match.PlayerB.Tag    = Convert.ToInt32(reader.GetAttribute("tag"));
                        }
                        break;
                    }
                }
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
示例#10
0
 public abstract void UpdatePlayerInfo(CompetitionPlayerInfo player_info, PlayerResults player_results, int place);