Пример #1
0
        public CPlayer GetPlayerAuto(string name = "")
        {
            CPlayer ph = GetPlayerRealHuman();

            if (name == "Human")
            {
                return(ph);
            }
            return(GetPlayerElo(ph));
        }
Пример #2
0
 public int GetIndex(string name)
 {
     for (int n = 0; n < list.Count; n++)
     {
         CPlayer user = list[n];
         if (user.name == name)
         {
             return(n);
         }
     }
     return(-1);
 }
Пример #3
0
        public int LoadFromIni()
        {
            list.Clear();
            List <string> pl = iniFile.ReadKeyList("player");

            foreach (string name in pl)
            {
                var p = new CPlayer(name);
                p.LoadFromIni();
                list.Add(p);
            }
            return(pl.Count);
        }
Пример #4
0
        public void Add(CPlayer p)
        {
            p.name = p.GetName();
            int index = GetIndex(p.name);

            if (index >= 0)
            {
                list[index] = p;
            }
            else
            {
                list.Add(p);
            }
        }
Пример #5
0
        public static CPlayer SelectPlayer()
        {
            CPlayer p = playerList.GetPlayer(player);

            if (p == null)
            {
                p = SelectRare();
            }
            if ((games >= repetition) && (games > 0))
            {
                p     = playerList.NextTournament(p);
                games = 0;
            }
            return(p);
        }
Пример #6
0
        public void SortPosition(CPlayer player)
        {
            SortElo();
            FillPosition();
            int position = player.position;

            foreach (CPlayer p in list)
            {
                p.position = Math.Abs(position - p.position);
            }
            list.Sort(delegate(CPlayer p1, CPlayer p2)
            {
                return(p1.position - p2.position);
            });
        }
Пример #7
0
        public void SetPlayer(string name)
        {
            CPlayer p = FormChess.playerList.GetPlayer(name);

            if (p != null)
            {
                tournament      = p.tournament;
                engine          = p.engine;
                book            = p.book;
                elo             = p.elo;
                modeValue.mode  = p.modeValue.mode;
                modeValue.value = p.modeValue.value;
                hisElo.Assign(p.hisElo);
            }
        }
Пример #8
0
        public static CPlayer SelectRare()
        {
            int     count  = 0;
            CPlayer result = null;

            foreach (CPlayer p in playerList.list)
            {
                int c = tourList.CountGames(p.name);
                if (count <= c)
                {
                    count  = c;
                    result = p;
                }
            }
            return(result);
        }
Пример #9
0
        private void ButCreate_Click(object sender, EventArgs e)
        {
            string name = tbPlayerName.Text;

            if (FormChess.playerList.GetPlayer(name) == null)
            {
                modeValue.mode = combMode.Text;
                modeValue.SetValue((int)nudValue.Value);
                CPlayer player = new CPlayer(name);
                player.engine = cbEngineList.Text;
                FormChess.playerList.list.Add(player);
                SaveToIni(player);
                MessageBox.Show($"Player {player.name} has been created");
                CData.reset = true;
            }
            else
            {
                MessageBox.Show($"Player {name} already exists");
            }
        }
Пример #10
0
        void SaveToIni(CPlayer p)
        {
            p.name   = tbPlayerName.Text;
            p.engine = cbEngineList.Text;
            p.book   = cbBookList.Text;
            p.SetTournament((int)nudTournament.Value);
            p.elo             = nudElo.Value.ToString();
            p.eloOrg          = p.elo;
            p.modeValue.mode  = modeValue.mode;
            p.modeValue.value = modeValue.value;
            p.SaveToIni();
            UpdateListBox();
            int index = listBox1.FindString(p.name);

            if (index == -1)
            {
                return;
            }
            listBox1.SetSelected(index, true);
        }
Пример #11
0
        void SelectPlayers(int first, int last, bool t)
        {
            int  f = first < last ? first : last;
            int  l = first < last ? last : first;
            bool r = false;

            for (int n = f; n <= l; n++)
            {
                var     item = listBox1.Items[n];
                string  name = item.ToString();
                CPlayer pla  = FormChess.playerList.GetPlayer(name);
                if (pla.SetTournament(t))
                {
                    r = true;
                }
            }
            if (r)
            {
                listBox1.Refresh();
                SelectPlayer();
            }
        }
Пример #12
0
 public void SetPlayer(CPlayer p)
 {
     player = p;
     book   = FormChess.bookList.GetBook(p.book);
     engine = FormChess.engineList.GetEngine(p.engine);
     bookPro.Terminate();
     enginePro.Terminate();
     if (book == null)
     {
         p.book = CData.none;
     }
     else
     {
         bookPro.SetProgram($@"{AppDomain.CurrentDomain.BaseDirectory}Books\{book.exe}", book.GetParameters(engine));
     }
     if (engine == null)
     {
         p.engine = "Human";
     }
     else
     {
         enginePro.SetProgram($@"{AppDomain.CurrentDomain.BaseDirectory}Engines\{engine.file}", engine.parameters, FormOptions.spamOff);
     }
 }
Пример #13
0
        public void SetPlayer(string name)
        {
            CPlayer p = FormChess.playerList.GetPlayer(name);

            SetPlayer(p);
        }
Пример #14
0
 void SelectPlayer(CPlayer p)
 {
     player = p;
     SelectPlayer();
 }