Exemple #1
0
        public CorrectChangedPlayersMarkerForm(HockeyIce game, Marker mk, Marker mk1, Marker mk2)
        {
            InitializeComponent();

            this.game   = game;
            this.Marker = mk;

            OrganizeUI();
        }
Exemple #2
0
 public Marker(HockeyIce game, String code)
     : this(game)
 {
     var tag = code.Split(new char[] { '_' });
     if (tag.Length == 2 || tag.Length == 3)
     {
         this.ActionId   = Convert.ToInt32(tag[0]);
         this.ActionType = Convert.ToInt32(tag[1]);
         if (tag.Length == 3)
         {
             this.Win = Convert.ToInt32(tag[2]);
         }
     }
 }
Exemple #3
0
        public void GetValues(ITypeDescriptorContext context)
        {
            _keys.Clear();
            _values.Clear();

            _keys.Add(null);
            _values.Add("-- НЕ УКАЗАН --");

            var game = new HockeyIce(HockeyIce.GameTypeEnum.Euro, HockeyIce.KIND_1);

            foreach (var half in game.HalfList)
            {
                _keys.Add(half);
                _values.Add(half.Name);
            }
        }
        public SelectOvertimeForm(HockeyIce game)
        {
            InitializeComponent();
            this.game = game;

            Half           = game.Half;
            MaxPlayersNum  = 4;
            OvertimeLength = 5;

            if (game.Markers.Exists(o => o.Compare(18, 5) && o.Half.Index == 4))
            {
                var mkh = game.Markers.First(o => o.Compare(18, 5) && o.Half.Index == 4);
                MaxPlayersNum  = mkh.Num % 10000;
                OvertimeLength = mkh.Num / 10000;
            }

            UpdateUI();
        }
Exemple #5
0
        public DataGridForm(MainForm mainForm, HockeyIce game)
        {
            InitializeComponent();

            this.mainForm = mainForm;
            this.game     = game;

            dataGridView1.Columns.Clear();
            dataGridView1.Columns.Add("col0", "#", 55, HorizontalAlignment.Left, String.Empty);
            dataGridView1.Columns.Add("col1", "Действие", 170, HorizontalAlignment.Left, String.Empty);
            dataGridView1.Columns.Add("col2", "Период", 65, HorizontalAlignment.Center, String.Empty);
            dataGridView1.Columns.Add("col3", "Время", 120, HorizontalAlignment.Center, String.Empty);
            dataGridView1.Columns.Add("col4", "Игрок", 140, HorizontalAlignment.Left, String.Empty);
            dataGridView1.Columns.Add("col5", "Команда", 100, HorizontalAlignment.Left, String.Empty);
            dataGridView1.Columns.Add("col6", "Оппонент", 140, HorizontalAlignment.Left, String.Empty);
            dataGridView1.Columns.Add("col7", "Команда", 100, HorizontalAlignment.Left, String.Empty);
            dataGridView1.Columns.Add("col8", "Pos", 80, HorizontalAlignment.Center, String.Empty);
            dataGridView1.Columns.Add("col9", "Pos Dest", 70, HorizontalAlignment.Center, String.Empty);
        }
        public InsertSubstitutionForm(HockeyIce game)
        {
            InitializeComponent();
            this.game = game;

            var exists = game.Match.Team1.Tactics[0].GetPlayers().OrderBy(o => o.Number)
                         .Concat(game.Match.Team2.Tactics[0].GetPlayers().OrderBy(o => o.Number)).ToList <Player>();

            var exists_no = game.Match.Team1.Players.OrderBy(o => o.Number)
                            .Concat(game.Match.Team2.Players.OrderBy(o => o.Number)).Where(o => exists.IndexOf(o) < 0).ToList <Player>();

            comboBox2.Items.Add("-НЕ ВЫБРАНО-");
            comboBox2.Items.AddRange(exists.ToArray <Player>());
            comboBox2.SelectedIndex = 0;

            comboBox1.Items.Add("-НЕ ВЫБРАНО-");
            comboBox1.Items.AddRange(exists_no.ToArray <Player>());
            comboBox1.SelectedIndex = 0;
        }
Exemple #7
0
        public Team()
        {
            TeamColorsKind = new Dictionary <int, TeamColors>();
            var game = new HockeyIce(HockeyIce.GameTypeEnum.Euro, HockeyIce.KIND_1);

            for (var i = 0; i < 6; i++)
            {
                var t = game.DefaultTactics.Clone();
                t.Name           = "5ka-" + i.ToString();
                t.NameActionType = i;
                if (i > 2)
                {
                    var p = t.GetPlace(game, 21);
                    t.Places.Remove(p);
                }

                Tactics.Add(i, t);
            }
        }
Exemple #8
0
        public List <Marker> GetCurrentTacticsMarker(HockeyIce game, Half half, int time, List <int> tactics_num_list)
        {
            if (tactics_num_list.Count == 0)
            {
                tactics_num_list.AddRange(Tactics.Keys);
            }

            var res = new List <Marker>();

            foreach (var i in tactics_num_list)
            {
                if (!Tactics.ContainsKey(i))
                {
                    continue;
                }

                foreach (var place in Tactics[i].Places)
                {
                    if (place.Player == null && i > 0 && tactics_num_list.Count == Tactics.Count)
                    {
                        continue;
                    }

                    var mk = new Marker(game, 16, place.GetCode() + 100 * i);
                    mk.Half      = half;
                    mk.TimeVideo = time;
                    if (place.Player != null)
                    {
                        mk.Player1 = place.Player;
                        mk.Num     = place.Player.Number;
                    }
                    else
                    {
                        mk.Team1 = this;
                    }
                    res.Add(mk);
                }
            }

            return(res);
        }
Exemple #9
0
 public Marker(HockeyIce game, int action_id, int action_type)
     : base(action_id, action_type)
 {
     this.game = game;
 }
Exemple #10
0
 public MarkerWithProperty(HockeyIce game, int action_id, int action_type, Half half, int video_time) : base(game, action_id, action_type, half, video_time)
 {
 }
Exemple #11
0
 public MarkerWithProperty(HockeyIce game, int action_id, int action_type) : base(game, action_id, action_type)
 {
 }
Exemple #12
0
 public MarkerWithProperty(HockeyIce game, string action_code) : base(game, action_code)
 {
 }
Exemple #13
0
 public MarkerWithProperty(HockeyIce game) : base(game)
 {
 }
Exemple #14
0
 public OnlinerForm(HockeyIce game)
 {
     InitializeComponent();
     this.game = game;
 }
Exemple #15
0
 public GoalPointForm(HockeyIce game, Marker mk)
 {
     InitializeComponent();
     Marker    = mk;
     this.game = game;
 }
Exemple #16
0
 public Marker(HockeyIce game, int action_id, int action_type, Half half, int video_time)
     : base(action_id, action_type, half, video_time)
 {
     this.game = game;
 }
Exemple #17
0
        private void DoLoadMatchData(object ids)
        {
            try
            {
                sync.Execute(() => pictureBox1.Visible = true);
                ShowStatus("Загрузка данных матча...", 0);

                Web.GetTeamColorsKind();

                var   idm = Int32.Parse(ids.ToString());
                SizeF sizef;
                game = Web.GetMatchInfo(idm, out sizef);

                if (game == null)
                {
                    throw new Exception("Нет матча или выбран неверный тип игры!");
                }

                if (game.Match.Team1 == null || game.Match.Team1.Id == 0)
                {
                    throw new Exception("Нет команды 1");
                }
                if (game.Match.Team2 == null || game.Match.Team2.Id == 0)
                {
                    throw new Exception("Нет команды 2");
                }

                if (!sizef.IsEmpty)
                {
                    game.FieldSize = sizef;
                }

                ShowStatus("Загрузка игроков команды " + game.Match.Team2.ToString() + "...", 0);
                Web.GetPlayers(game.Match.Team2);

                if (game.Match.Team2.Players.Count == 0)
                {
                    throw new Exception("Нет состава команды " + game.Match.Team2);
                }

                ShowStatus("Загрузка игроков команды " + game.Match.Team1.ToString() + "...", 0);
                Web.GetPlayers(game.Match.Team1);

                if (game.Match.Team1.Players.Count == 0)
                {
                    throw new Exception("Нет состава команды " + game.Match.Team1);
                }

                ShowStatus("Загрузка параметров матча...", 0);

                game.Match.Team1.FinePlaces.Clear();
                game.Match.Team1.FinePlayers.Clear();

                game.Match.Team2.FinePlaces.Clear();
                game.Match.Team2.FinePlayers.Clear();

                Web.GetTeamColors(game.Match.Team1);
                Web.GetTeamColors(game.Match.Team2);

                var txt = game.Match.Team1.Name + " - " + game.Match.Team2.Name;

                game.Markers.Clear();

                sync.Execute(() =>
                {
                    label1.Text = game.Match.Tournament + " " +
                                  game.Match.Date.ToShortDateString() + " " +
                                  game.Match.Date.ToLongTimeString();

                    textBox4.Text = txt;
                });

                ShowStatus("Загрузка маркеров...", 0);

                var           lstSrv = Web.GetMarkers(game, game.Match.Id);
                List <Marker> lstLoc = MarkerList.LoadFromFile(game, game.Match.Id);

                foreach (Game.Marker mk in lstLoc)
                {
                    mk.game = game;
                }

                foreach (var mk in lstLoc.Where(o => !o.FlagDel).OrderBy(o => o.Half.Index).ThenBy(o => o.TimeVideo))
                {
                    var period = mk.Half.Index;
                    var half   = game.HalfList.FirstOrDefault(o => o.Index == period);
                    mk.Half = half;
                }

                game.Union(lstLoc, lstSrv);

                foreach (Game.Marker mk in game.Markers)
                {
                    mk.row = null;
                }

                ShowStatus("Синхронизация...", 0);
                var pl = game.Match.Team1.Players.Concat(game.Match.Team2.Players).ToList <Player>();

                //Восстановление и контроль составов
                foreach (var mk in game.Markers.Where(o => o.ActionId == 16))
                {
                    Team tm = null;
                    try
                    {
                        tm       = GetTeam(mk.team1_id, mk);
                        mk.Team1 = tm;
                    }
                    catch (TeamMarkerException ex)
                    {
                        mk.FlagDel = true;
                        ShowStatus(ex.Message, FormShowStatusCode.Error);
                        Thread.Sleep(100);
                        continue;
                    }

                    if (pl.Exists(o => o.Id == mk.player1_id))
                    {
                        var p = pl.First(o => o.Id == mk.player1_id);

                        if (mk is Game.Marker)
                        {
                            var mkg = (Game.Marker)mk;
                            if (mkg.Num > 0)
                            {
                                p.Number = mkg.Num;
                            }
                        }

                        var tm2 = game.Match.Team1 == tm ? game.Match.Team2 : game.Match.Team1;
                        if (tm2.Players.Exists(o => o.Id == p.Id))
                        {
                            throw new Exception(String.Format((string)"Ошибка в маркере расстановки {0}. Игрок {1} был в составе {2}, а теперь указан в команде соперника", (object)mk.Id, (object)p, tm2));
                        }

                        p.Team     = tm;
                        mk.Player1 = p;

                        if (!tm.Players.Exists(o => o.Id == p.Id))
                        {
                            tm.Players.Add(p);
                        }
                    }
                    else
                    {
                        if (mk.player1_id <= 0)
                        {
                            continue;
                        }

                        var p = Web.GetPlayer(mk.player1_id);
                        if (p != null)
                        {
                            p.Team     = tm;
                            mk.Player1 = p;

                            if (!tm.Players.Exists(o => o.Id == p.Id))
                            {
                                tm.Players.Add(p);
                            }
                            if (!pl.Exists(o => o.Id == p.Id))
                            {
                                pl.Add(p);
                            }
                        }
                        else
                        {
                            throw new Exception("Критическая ошибка: не могу загрузить игрока ID=" + mk.player1_id + " из состава команды " + tm.Name);
                        }
                    }
                }

                game.Match.Team1.Players.AddRange(
                    pl.Where(o
                             => o.Team != null &&
                             o.Team.Id == game.Match.Team1.Id &&
                             !game.Match.Team1.Players.Exists(o1 => o1.Id == o.Id)));

                game.Match.Team2.Players.AddRange(
                    pl.Where(o
                             => o.Team != null &&
                             o.Team.Id == game.Match.Team2.Id &&
                             !game.Match.Team2.Players.Exists(o1 => o1.Id == o.Id)));

                var errmklist = new List <Marker>();
                foreach (var mk in game.Markers.Where(o => o.ActionId != 16))
                {
                    if (mk.player1_id > 0)
                    {
                        var pla = pl.FirstOrDefault(o => o.Id == mk.player1_id);

                        if (pla == null)
                        {
                            try
                            {
                                mk.Player1 = Web.GetPlayer(mk.player1_id);
                            }
                            catch
                            {
                                mk.FlagDel = true;
                                errmklist.Add(mk);
                            }
                        }
                        else
                        {
                            mk.Player1 = pla;
                        }
                    }
                    else
                    if (mk.team1_id > 0)
                    {
                        try
                        {
                            mk.Team1 = GetTeam(mk.team1_id, mk);
                        }
                        catch (Exception ex)
                        { }
                    }

                    if (mk.player2_id > 0)
                    {
                        var opp = pl.FirstOrDefault(o => o.Id == mk.player2_id);

                        if (opp == null)
                        {
                            try
                            {
                                mk.Player2 = Web.GetPlayer(mk.player2_id);;
                            }
                            catch
                            {
                                mk.FlagDel = true;
                                errmklist.Add(mk);
                            }
                        }
                        else
                        {
                            mk.Player2 = opp;
                        }
                    }
                    else
                    if (mk.team2_id > 0)
                    {
                        try
                        {
                            mk.Team2 = GetTeam(mk.team2_id, mk);
                        }
                        catch (Exception ex)
                        { }
                    }
                }

                game.RefreshOvertimes();

                sync.Execute(() =>
                {
                    label1.Text   = game.Match.Tournament + " " + game.Match.Date.ToShortDateString() + " " + game.Match.Date.ToLongTimeString();
                    textBox4.Text = txt;
                });

                TeamDataRestore(game.Match.Team1);
                TeamDataRestore(game.Match.Team2);

                PlayerConverter.RefreshData(game.Match);
                TeamConverter.RefreshData(game.Match);

                sync.Execute(() =>
                {
                    checkBox1.Checked = !game.Match.Team1.Tactics[1].IsValid;
                    checkBox2.Checked = !game.Match.Team1.Tactics[1].IsValid;

                    comboBox1.Items.Clear();
                    foreach (var tc in game.Match.Team1.TeamColorsKind.Values)
                    {
                        comboBox1.Items.Add(tc);
                        if (tc.Kind == game.Match.Team1.Color.Kind)
                        {
                            comboBox1.SelectedItem = tc;
                        }
                    }

                    comboBox2.Items.Clear();
                    foreach (var tc in game.Match.Team2.TeamColorsKind.Values)
                    {
                        comboBox2.Items.Add(tc);
                        if (tc.Kind == game.Match.Team2.Color.Kind)
                        {
                            comboBox2.SelectedItem = tc;
                        }
                    }

                    changed_colors = false;
                });

                if (errmklist.Count > 0)
                {
                    var errmks = String.Empty;
                    for (var i = 0; i < errmklist.Count; i++)
                    {
                        if (i <= 2)
                        {
                            if (i > 0)
                            {
                                errmks += ",";
                            }
                            errmks += errmklist[i].Id;
                            if (i == 2)
                            {
                                errmks += "...";
                            }
                        }
                    }

                    ShowStatus(String.Format("Ошибочно указаны некоторые игроки. Эти маркеры {0} помечены на удаление.", errmks), FormShowStatusCode.Error);
                }
                else
                {
                }

                game.RecalcActualTime(game.Markers, null);

                sync.Execute(() => hockeyField1.Game = game);
                ShowStatus("Готово", 0);
            }
            catch (Exception ex)
            {
                game = null;
                ShowStatus(ex.Message, FormShowStatusCode.Error);
                HockeyGui.InvalidateRect();
            }
            finally
            {
                sync.Execute(() =>
                {
                    HockeyGui.InvalidateRect();
                    pictureBox1.Visible = false;
                });
                loading = false;
                UpdateUI();
            }
        }
Exemple #18
0
 public static bool IsFine(HockeyIce game, Player p)
 {
     lock (p.Team.FinePlayers)
         return(p != null && p.Team.FinePlayers.Exists(o => o != null && o.Id == p.Id && ((bool)o.Tag)));
 }
Exemple #19
0
 public Marker(HockeyIce game)
     : base()
 {
     this.game = game;
 }